发布于:2021-02-09 09:50:20
0
597
0
oracle19c中的一个新特性是能够使用DBCA执行PDB的远程克隆,还可以将PDB从一个容器数据库重新定位到另一个容器数据库。
让我们看一个例子,首先克隆一个PDB,然后将PDB重新定位到另一个CDB。
这是我们最初的环境
容器数据库CDB1(host02):PDB$SEED,PDB1
容器数据库CDB2(host03):PDB$SEED
这是预期的最终环境
容器数据库CDB1(host02):PDB$SEED
容器数据库CDB2(host03):PDB$SEED、PDB1、PDB2
SQL> select name from v$database;
NAME
---------
CDB1
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
SQL> select name from v$database;
NAME
---------
CDB2
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
远程克隆CDB1/PDB1到CDB2/PDB2
创建将用于数据库链接的公共用户。
SQL> create user c##link_user identified by Oracle4U;
User created.
SQL> GRANT CREATE SESSION, RESOURCE, CREATE ANY TABLE, UNLIMITED TABLESPACE TO c##link_user CONTAINER=ALL;
Grant succeeded.
SQL> GRANT CREATE PLUGGABLE DATABASE TO c##link_user CONTAINER=ALL;
Grant succeeded.
SQL> GRANT SYSOPER TO c##link_user CONTAINER=ALL;
Grant succeeded.
在CDB2中创建连接到CDB1的数据库链接。
SQL> create database link cdb1_link
2 connect to c##link_user identified by Oracle4U
3 using 'CDB1';
Database link created.
SQL> select * from dual@cdb1_link;
D
-
X
在静默模式下运行DBCA执行远程克隆(从CDB2运行此操作)。
[oracle@host03 admin]$ dbca
-silent
-createPluggableDatabase
-createFromRemotePDB
-sourceDB cdb2
-remotePDBName pdb1
-remoteDBConnString host02:1521/cdb1.localdomain
-remoteDBSYSDBAUserName SYS
-remoteDBSYSDBAUserPassword G#vin1
-dbLinkUsername c##link_user
-dbLinkUserPassword Oracle4U
-sysDBAUserName SYS
-sysDBAPassword G#vin1
-pdbName pdb2
-pdbDatafileDestination '/u01/app/oracle/oradata/CDB2/pdb2/'
Prepare for db operation
50% complete
Create pluggable database using remote clone operation
100% complete
Pluggable database "pdb2" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb2/cdb2.log" for further details.
在CDB2中,验证是否创建了可插入数据库PDB2,并注意PDB2的数据文件的位置。
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB2 READ WRITE NO
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/CDB2/system01.dbf
/u01/app/oracle/oradata/CDB2/sysaux01.dbf
/u01/app/oracle/oradata/CDB2/undotbs01.dbf
/u01/app/oracle/oradata/CDB2/pdbseed/system01.dbf
/u01/app/oracle/oradata/CDB2/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/CDB2/users01.dbf
/u01/app/oracle/oradata/CDB2/pdbseed/undotbs01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/system01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/sysaux01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/undotbs01.dbf
/u01/app/oracle/oradata/CDB2/pdb2/users01.dbf
将PDB1从CDB1重新定位到CDB2
以静默模式运行DBCA以执行重新定位(从CDB2运行此操作)。
[oracle@host03 admin]$ dbca
-silent
-relocatePDB
-sourceDB cdb2
-remotePDBName pdb1
-remoteDBConnString host02:1521/cdb1.localdomain
-remoteDBSYSDBAUserName SYS
-remoteDBSYSDBAUserPassword G#vin1
-dbLinkUsername c##link_user
-dbLinkUserPassword Oracle4U
-sysDBAUserName SYS
-sysDBAPassword G#vin1
-pdbName pdb1
-pdbDatafileDestination '/u01/app/oracle/oradata/CDB2/pdb1/'
Prepare for db operation
50% complete
Create pluggable database using relocate PDB operation
100% complete
Pluggable database "pdb1" plugged successfully.
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/cdb2/pdb1/cdb20.log" for further details.
克隆和重新定位后验证环境。
SQL> select name from v$database;
NAME
---------
CDB2
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB2 READ WRITE NO
4 PDB1 READ WRITE NO
SQL> select name from v$database;
NAME
---------
CDB1
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
作者介绍