不同CDB之間遷移PDB
阿新 • • 發佈:2018-08-03
2.2.0 lease release 解釋 oot rest too ont pdb
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter session set container=orcl1;
SQL> select * from zky.aa;
USERNAME
--------------------------------------------------------------------------------
ZKY
1 rows selected.
SQL> create user cp identified by cp;
User created.
SQL> grant create session,create pluggable database to cp;
Grant succeeded.
SQL> alter session set container=CDB$ROOT;
SQL> alter pluggable database orcl1 close;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL1 READ ONLY NO
4 ORCL2 READ WRITE NO
SQL>
目的端
[oracle@zhanky2 ~]$ vi /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
[oracle@zhanky2 ~]$ cat /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_CS =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171/215)(PORT = 1521))
CS1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171.215)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cs1.zhanky.com)
)
)
CS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171.215)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cs.zhanky.com)
)
)
orcl1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171.214)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl1.zhanky.com)
)
)
[oracle@zhanky2 ~]$
SQL> create database link cp_link connect to cp identified by cp using 'orcl1';
Database link created.
SQL> select count(*) from all_users@cp_link;
COUNT(*)
----------
41
SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata/cs/cs2';
System altered.
SQL> create pluggable database cs2 from orcl1@cp_link;
Pluggable database created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 CS1 READ WRITE NO
4 CS2 MOUNTED
SQL> alter session set container=cs2;
Session altered.
SQL> startup
Pluggable Database opened.
SQL> select * from zky.aa;
USERNAME
--------------------------------------------------------------------------------
ZKY
1 rows selected.
SQL>
完成測試,因為時間原因沒有詳細解釋,先將就一下看吧。
測試環境
源環境 | 目標環境 |
主機操作系統 Oracle Linux 7.2 主機名zhankys Oracle版本 11.2.0.1 x64 IP:172.16.171.214 CDB=orcl 被克隆的PDB=orcl1 | 主機操作系統 Oracle Linux 7.2 主機名zhanky2 Oracle版本 11.2.0.1 x64 IP:172.16.171.215 CDB=cs 克隆後的PDB=cs2 |
測試思路
1、源端建立CP擁有create pluggable database和create session的權限(在PDB orcle1下創建用戶)
2、將源端設置為只讀模式(CDB模式下設置)
3、在目標端添加orcl1的tnsnames(在tnsnames.ora中添加)
4、在目標端創建orcle1的dblink:cp_link (在CDB模式下運行)
5、在目標端指定db_create_file_dest路徑(在CDB模式下運行,如果目錄不存在需事先創建)
6、執行克隆PDB語句(在CDB模式下運行)
7、檢查數據是否正確(在PDB模式下運行)
源端
[oracle@zhanky ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 3 16:21:35 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter session set container=orcl1;
SQL> select * from zky.aa;
USERNAME
--------------------------------------------------------------------------------
1 rows selected.
SQL> create user cp identified by cp;
User created.
SQL> grant create session,create pluggable database to cp;
Grant succeeded.
SQL> alter session set container=CDB$ROOT;
SQL> alter pluggable database orcl1 close;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 ORCL1 READ ONLY NO
4 ORCL2 READ WRITE NO
SQL>
目的端
[oracle@zhanky2 ~]$ vi /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
[oracle@zhanky2 ~]$ cat /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_CS =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171/215)(PORT = 1521))
CS1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171.215)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cs1.zhanky.com)
)
)
CS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171.215)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cs.zhanky.com)
)
)
orcl1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.171.214)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl1.zhanky.com)
)
)
[oracle@zhanky2 ~]$
SQL> create database link cp_link connect to cp identified by cp using 'orcl1';
Database link created.
SQL> select count(*) from all_users@cp_link;
COUNT(*)
----------
41
SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata/cs/cs2';
System altered.
SQL> create pluggable database cs2 from orcl1@cp_link;
Pluggable database created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 CS1 READ WRITE NO
4 CS2 MOUNTED
SQL> alter session set container=cs2;
Session altered.
SQL> startup
Pluggable Database opened.
SQL> select * from zky.aa;
USERNAME
--------------------------------------------------------------------------------
ZKY
1 rows selected.
SQL>
完成測試,因為時間原因沒有詳細解釋,先將就一下看吧。
不同CDB之間遷移PDB