pdb跨cdb遷移數據庫
目錄結構 c#
1、遷移說明session
2、遷移圖示oracle
3、進行遷移動做的先決條件ide
4、遠程cdb遷移一個pdb到本地cdb測試
1、 遷移說明spa
一、While the PDB is being relocated, current DML and DDL operations will pause while they are redirected to the PDB’s new location Queries continue to run with no pauseblog
二、You must use a database link to relocate the PDB. The database link must be created in the CDB that will contain the relocated PDBci
三、When you issue the CREATE PLUGGABLE Creating a PDB by Relocating It DATABASE statement from the root of the CDB that will contain the relocated PDB, you must specify a database link to the remote CDB that contains the PDB being relocated in the FROM clauserem
四、The database link must connect to the root of the remote CDB
五、To redirect connections from the old location of the PDB to the new location, specify the AVAILABILITY MAX clause
2、遷移圖示
2.一、遷移圖示
2.二、實驗環境簡介
本地 192.168.5.40:1521 mycdb pdb:mypdb一、mypdb2 數據文件路徑 /opt/oracle/oradata/mycdb/
遠程 192.168.5.41:1521 youcdb pdb:youpdb 數據文件路徑 /opt/oracle/oradata/youcdb/
3、進行遷移動做的先決條件
一、當前操做用戶必須在包含待遷移 pdb 的 cdb 中具備 create pluggable database 系統權限
二、pdb 必須具備 local undo mode 權限
三、若 cdb 不是歸檔模式則 pdb 必須打開爲只讀模式,不然遷移過去pdb打開會要求恢復。數據不一致。
四、關於數據庫鏈接必須知足條件
數據庫鏈接必須鏈接到 cdb 的 root 容器
數據庫鏈接用戶必須具備create pluggable database系統權限和sysoper管理員權限
數據庫鏈接用戶必須是一個公共用戶
五、源cdb平臺和目標cdb平臺的字節順序必須兼容
4、遠程cdb遷移一個pdb到本地cdb
4.一、在遠程 cdb 中建立公共用戶
create user c##useradmin identified by Passw0rd;
grant CREATE PLUGGABLE DATABASE to c##useradmin container=all;
grant connect,resource,dba,sysoper to c##useradmin container=all;
4.二、在遷移的pdb中查詢是否存在建立的公共用戶
SELECT A.CON_ID,A.PDB_NAME,B.USERNAME FROM CDB_PDBS A ,CDB_USERS B WHERE A.CON_ID=B.CON_ID AND USERNAME='C##USERADMIN';
CON_ID PDB_NAME USERNAME
---------- -------------------- --------------------------------------------------
3 YOUPDB C##USERADMIN
4.三、在本地cdb建立指向遠程cdb的數據庫鏈接
一、create public database link relocpdb connect to c##useradmin identified by Passw0rd using '192.168.5.41:1521/youcdb';
Database link created.
二、數據庫連接的測試
SQL> select sysdate from dual@relocpdb;
SYSDATE 二、數據庫連接的測試
SQL> select sysdate from dual@relocpdb;
SYSDATE
---------
23-MAY-20
4.四、執行遷移(注意這裏遷移庫指定pdb名字應該和原來保持一致)
一、遷移源
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 YOUPDB READ WRITE NO
二、目標庫
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 MYPDB1 READ WRITE NO
4 MYPDB2 READ WRITE NO
三、執行以下遷移語句
CREATE PLUGGABLE DATABASE youpdb FROM youpdb@relocpdb RELOCATE AVAILABILITY MAX file_name_convert=('/opt/oracle/oradata/youcdb/youpdb/','/opt/oracle/oradata/mycdb/youpdb/');
Pluggable database created.
四、遷移後,遷移pdb在目標庫mycdb打開後,源pdb狀態變化以下
SQL> alter pluggable database youpdb open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 MYPDB1 READ WRITE NO
4 MYPDB2 READ WRITE NO
5 YOUPDB READ WRITE NO
SQL> alter session set container=youpdb;
Session altered.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/opt/oracle/oradata/mycdb/youpdb/system01.dbf
/opt/oracle/oradata/mycdb/youpdb/sysaux01.dbf
/opt/oracle/oradata/mycdb/youpdb/undotbs01.dbf
/opt/oracle/oradata/mycdb/youpdb/users01.dbf
遷移後源pdb自動mounted狀態
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 YOUPDB MOUNTED