• Oracle 12C 多种方式创建PDB


    1、从PDB$SEED创建新PDB

    SQL> create pluggable database PDB3 admin user pdb3admin identified by oracle 
    file_name_convert=('/u01/oradata/cdb1/pdbseed','/u01/oradata/cdb1/pdb3') ;

    2、克隆本地PDB

    SQL> show pdbs
        CON_ID CON_NAME			  OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
    	 2 PDB$SEED			  READ ONLY  NO
    	 3 PDB1 			  READ WRITE NO
    	 4 PDB2 			  MOUNTED
    	 6 PDB3 			  MOUNTED
    SQL> alter pluggable database pdb1 close;
    插接式数据库已变更。
    SQL> alter pluggable database pdb1 open read only;
    插接式数据库已变更。
    SQL> create pluggable database pdb4 from pdb1 file_name_convert=('/u01/oradata/cdb1/pdb1','/u01/oradata/cdb1/pdb4') ;
    插接式数据库已创建。
    SQL> 
    

      

    3、克隆远程 PDB
    该操作有一些限制。源和目标 CDB 平台必须满足以下要求:它们必须安装有相同的 endian 格式和兼容的数据库项,并使用相同的字符集和国家字符集。

    Check the CHARACTERSET of remote and local CDB

    col parameter for a30
    col value for a30
    select * from nls_database_parameters where parameter='NLS_CHARACTERSET'
    or parameter='NLS_LANGUAGE' or parameter='NLS_NCHAR_CHARACTERSET';

    Check the remote CDB is in local undo mode and archivelog mode.

    COLUMN property_name FORMAT A30
    COLUMN property_value FORMAT A30
    
    SELECT property_name, property_value
    FROM database_properties
    WHERE property_name = 'LOCAL_UNDO_ENABLED';
    
    PROPERTY_NAME PROPERTY_VALUE
    ------------------------------ ------------------------------
    LOCAL_UNDO_ENABLED TRUE
    
    SELECT log_mode
    FROM v$database;
    
    LOG_MODE
    ------------
    ARCHIVELOG
    
    SQL>

    whitch of two is not be provided ,need to turn the remote database into read-only mode.

    on remote source CDB:

    SQL> alter session set container=pdb2;
    Session altered.
    SQL> show pdbs
    CON_ID CON_NAME	OPEN MODE RESTRICTED
    ---------- ------------------------------ ---------- ----------
    4 PDB2 READ WRITE NO
    
    SQL> create user pdbclone identified by welcome123;
    SQL> grant create session,create pluggable database to pdbclone;
    SQL> alter pluggable database pdb2 close;
    SQL> alter pluggable database pdb2 open read only;
    SQL> show pdbs;
    
    CON_ID CON_NAME	OPEN MODE RESTRICTED
    ---------- ------------------------------ ---------- ----------
    4 PDB2 READ ONLY NO

    on local destination CDB:

    SQL> create database link clone_link connect to pdbclone identified by welcome123 using '192.168.56.33:1521/pdb2';
    SQL> create pluggable database pdblk from PDB2@clone_link file_name_convert=('/u01/oradata/cdb1/pdb2','/u01/oradata/cdb1/pdblk') ;
    插接式数据库已创建。
    SQL> ! ls /u01/oradata/cdb1/pdblk
    sysaux01.dbf system01.dbf temp01.dbf	undotbs01.dbf users01.dbf
    SQL>

    on remote source CDB ,Switch the source PDB back to read/write

    SQL> alter pluggable database pdb2 close;
    Pluggable database altered.
    SQL> alter pluggable database pdb2 open;
    Pluggable database altered.
    SQL> show pdbs
    CON_ID CON_NAME	OPEN MODE RESTRICTED
    ---------- ------------------------------ ---------- ----------
    4 PDB2 READ WRITE NO

    4、克隆远程 Non-CDB
    该操作有一些限制。源和目标 CDB 平台必须满足以下要求:它们必须安装有相同的 endian 格式和兼容的数据库项,并使用相同的字符集和国家字符集。
    Check the CHARACTERSET of remote Non-CDB and local CDB

    col parameter for a30
    col value for a30
    select * from nls_database_parameters where parameter='NLS_CHARACTERSET'
    or parameter='NLS_LANGUAGE' or parameter='NLS_NCHAR_CHARACTERSET';

    Check the remote Non-CDB is in archivelog mode.If not need to turn the remote database into read-only mode.

    SQL> SELECT log_mode
    FROM v$database;
    LOG_MODE
    ------------
    ARCHIVELOG
    SQL> create user nocdbclone identified by welcome123;
    SQL> grant create session,create pluggable database to nocdbclone;
    SQL> startup mount;
    SQL> alter database open read only;
    Database altered.
    

    Create a new PDB in the local database by cloning the remote non-CDB. 

    SQL>create database link clone_link connect to nocdbclone identified by welcome123 using '192.168.56.33:1521/ora12c';
    SQL> CREATE PLUGGABLE DATABASE nocdbtopdb FROM NON$CDB@clone_link file_name_convert=('/u01/oradata/ora12c','/u01/oradata/cdb1/nocdbtopdb') ; 
    插接式数据库已创建。
    SQL> !ls /u01/oradata/cdb1/nocdbtopdb
    sysaux01.dbf system01.dbf temp01.dbf	undotbs01.dbf users01.dbf
    SQL> show pdbs
    CON_ID CON_NAME	OPEN MODE RESTRICTED
    ---------- ------------------------------ ---------- ----------
    2 PDB$SEED	READ ONLY NO
    3 PDB1 READ ONLY NO
    4 PDB2 MOUNTED
    5 PDB4 MOUNTED
    6 PDB3 MOUNTED
    7 PDBLK	MOUNTED
    8 NOCDBTOPDB	MOUNTED
    SQL> ALTER SESSION SET CONTAINER=NOCDBTOPDB;
    
    会话已更改。
    SQL>@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
    SQL> ALTER PLUGGABLE DATABASE nocdbtopdb open;
    
    插接式数据库已变更。
    
    SQL> show pdbs
    
    CON_ID CON_NAME OPEN MODE RESTRICTED
    ---------- ------------------------------ ---------- ----------
    8 NOCDBTOPDB READ WRITE NO

    5、Unplugging PDB & Plug Unplugging PDB

    SQL> alter session set container=pdb1; 
    SQL> select name from v$datafile;
    SQL> alter session set container=CDB$ROOT;
    SQL> show con_name
    
    CON_NAME
    ------------------------------
    CDB$ROOT
    SQL> alter pluggable database PDB1 close immediate;
    SQL> alter pluggable database PDB1 unplug into '/tmp/PDB1.xml';
    SQL> drop pluggable database PDB1 keep datafiles;
    
    SQL> set serveroutput on
    DECLARE
    l_result BOOLEAN;
    BEGIN
    l_result := DBMS_PDB.check_plug_compatibility(pdb_descr_file => '/tmp/PDB1.xml',pdb_name => 'PDB10');
    IF l_result THEN
    DBMS_OUTPUT.PUT_LINE('Yes');
    ELSE
    DBMS_OUTPUT.PUT_LINE('No');
    END IF;
    END;
    /
    #这里的 PDB 可以同名也可以不同名
    SQL> create pluggable database PDB10 using '/tmp/PDB1.xml' nocopy ;
    SQL> alter pluggable database pdb10 open;

    6、其他
      The local and remote databases must have the same endianness.
      The local and remote databases must either have the same options installed, or the remote database must have a subset of those present on the local database.
      If the character set of the local CDB is AL32UTF8, the remote database can be any character set. If the local CDB does not use AL32UTF8, the character sets of the remote and local databases much match.
      If the remote database uses Transparent Data Encryption (TDE) the local CDB must be configured appropriately before attempting the clone. If not you will be left with a new PDB that will only open in restricted mode.
      Bug 19174942 is marked as fixed in 12.2. I can't confirm this, so just in case I'll leave this here, but it should no longer be the case. The default tablespaces for each common user in the remote PDB *must* exist in local CDB. If this is not true, create the missing tablespaces in the root container of the local PDB. If you don't do this your new PDB will only be able to open in restricted mode (Bug 19174942).
      When cloning from a non-CDB, both the the local and remote databases must using version 12.1.0.2 or higher.

    Related articles.
    https://oracle-base.com/articles/12c/multitenant-hot-clone-remote-pdb-or-non-cdb-12cr2#cloning-remote-pdb

    也许我已经迷失很久了,早已丢失了自己的影子。
  • 相关阅读:
    Java面试题及答案整理(持续更新)
    CentOS6.4-mini系统服务列表
    Linux内核编译,模块尺寸变大的解决办法
    Configuration Opennebula3.8 & 4.x Virtual Machines Contextualizing
    CentOS6.3上Opennebula 3.8 VLAN配置
    Ubuntu 12.04 LTS主机名、IP、DNS配置总结
    Linux su
    Git安装配置总结
    Linux CentOS添加163yum源
    Linux 内核编译 modules ehci-hcd, ohci-hcd, uhci-hcd not found
  • 原文地址:https://www.cnblogs.com/JcLevy/p/11237404.html
Copyright © 2020-2023  润新知