Orcle 12c 新特性 --- 支持克隆远端PDB

1 说明

The new release of Oracle Multitenant fully supports remote full and snapshot clones over a database link. A non-multitenant container database (CDB) can be adopted as a pluggable database (PDB) simply by cloning it over a database link. Remote snapshot cloning is also supported across two CDBs sharing the same storage.

从12c开始,就支持通过dblink来克隆远端的PDB,从12.1.0.2开始,支持克隆远端non-CDB.

图1 通过克隆远程的PDB来创建PDB
在这里插入图片描述
克隆之前,要注意前提条件:

  • Complete the prerequisites described in “Preparing for PDBs”.

  • The current user must have the CREATE PLUGGABLE DATABASE system privilege in the root of the CDB that will contain the target PDB.

  • The source PDB or source non-CDB must be in open read-only mode.

  • A database link must enable a connection from the CDB that will contain the target PDB to the remote source. If the source is a remote PDB, then the database link can connect to either the root of the remote CDB or to the remote source PDB.

  • The user that the database link connects with at the remote source must have the CREATE PLUGGABLE DATABASE system privilege in the source PDB or in the non-CDB.

  • If the database link connects to the root in a remote CDB, then the user that the database link connects with must be a common user.

  • The source and target platforms must meet these requirements:

    • They must have the same endianness.

    • The database options installed on the source platform must be the same as, or a subset of, the database options installed on the target platform.

  • The source and target must have compatible character sets and national character sets. To be compatible, the character sets and national character sets must meet all of the requirements specified in Oracle Database Globalization Support Guide.

  • If you are creating a PDB by cloning a non-CDB, then both the CDB and the non-CDB must be running Oracle Database 12c Release 1 (12.1.0.2) or later.

更多信息查看官方文档:http://docs.oracle.com/database/121/ADMIN/cdb_plug.htm#ADMIN13593

2 实验

源库:192.168.1.55,CNDBA_PDB
目标库:192.168.1.110,CNDBA_PDB_NEW

注意:以下所有操作都在CDB级别进行。

2.1 查看源库PDB

SQL> show pdbs;
    CON_ID CON_NAME	  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
 2 PDB$SEED	  READ ONLY  NO

 3 PDB1  	MOUNTED

 4 CNDBA_PDB MOUNTED   --这里我们的目标

2.2 创建dblink

目标库创建dblink指向远端库

SQL> create public database link cndba_pdb connect to SYSTEM identified by oracle using 'CNDBA_PDB';

Database link created.

—测试dblink是否正常

SQL> select * from v$version@cndba_pdb where rownum=1;

BANNER	CON_ID
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production  0

2.3 将源库PDB以只读模式打开

SQL> alter pluggable database cndba_pdb open read only;
Pluggable database altered.

SQL> show pdbs;

    CON_ID CON_NAME	  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
 2 PDB$SEED	  READ ONLY  NO
 3 PDB1   MOUNTED
 4 CNDBA_PDB READ ONLY  NO

2.4 克隆远端PDB

由于没有启用OMF,必须制定file_name_convert

–目标端创建新PDB的数据文件存放目录

SQL> !mkdir -p /u01/app/oracle/oradata/orcl/sihong/cndba_pdb_new/

–开始克隆

SQL> CREATE PLUGGABLE DATABASE cndba_pdb_new FROM cndba_pdb@cndba_pdb
file_name_convert=('/u01/app/oracle/oradata/cndba_pdb/','/u01/app/oracle/oradata/orcl/sihong/cndba_pdb_new/');  2  

Pluggable database created.

2.5 验证是否克隆成功

SQL> alter session set container=CNDBA_PDB_NEW;

Session altered.

–数据也传输过来了

SQL> select count(*) from lei.cndba;

  COUNT(*)
----------
       200

到现在就克隆成功了。

注意:如果是克隆远端的non-CDB,在打开PDB之前,需要执行$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql脚本。

猜你喜欢

转载自blog.csdn.net/qianglei6077/article/details/92978689