12c多租户管理七(pdb跨cdb迁移)

pdb跨cdb迁移



目录结构 


一、迁移说明

二、迁移图示

三、进行迁移动作的先决条件

四、远程cdb迁移一个pdb到本地cdb


 

一、 迁移说明


1、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 pause

2、You must use a database link to relocate the PDB. The database link must be created in the CDB that will contain the relocated PDB

3、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 clause

4、The database link must connect to the root of the remote CDB

5、To redirect connections from the old location of the PDB to the new location, specify the AVAILABILITY MAX clause


二、迁移图示

2.1、迁移图示

image.png


2.2、实验环境简介

本地  192.168.5.40:1521  mycdb   pdb:mypdb1、mypdb2 数据文件路径 /opt/oracle/oradata/mycdb/

远程  192.168.5.41:1521  youcdb  pdb:youpdb         数据文件路径  /opt/oracle/oradata/youcdb/



三、进行迁移动作的先决条件


1、当前操作用户必须在包含待迁移 pdb 的 cdb 中具有 create pluggable database 系统权限

2、pdb 必须具有 local undo mode 权限

3、若 cdb 不是归档模式则 pdb 必须打开为只读模式,否则迁移过去pdb打开会要求恢复。数据不一致。

4、关于数据库连接必须满足条件

     数据库连接必须连接到 cdb 的 root 容器

     数据库连接用户必须具有create pluggable database系统权限和sysoper管理员权限

     数据库连接用户必须是一个公共用户

5、源cdb平台和目标cdb平台的字节顺序必须兼容


四、远程cdb迁移一个pdb到本地cdb


4.1、在远程 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.2、在迁移的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.3、在本地cdb创建指向远程cdb的数据库连接


1、create public database link relocpdb connect to c##useradmin identified by Passw0rd using '192.168.5.41:1521/youcdb';


Database link created. 


2、数据库链接的测试

SQL> select sysdate from dual@relocpdb;


SYSDATE 2、数据库链接的测试

SQL> select sysdate from dual@relocpdb;


SYSDATE

---------

23-MAY-20


4.4、执行迁移(注意这里迁移库指定pdb名字应该和原来保持一致)


1、迁移源

SQL> show pdbs;


    CON_ID CON_NAME   OPEN MODE  RESTRICTED

---------- ------------------------------ ---------- ----------

2 PDB$SEED        READ ONLY  NO

3 YOUPDB        READ WRITE NO

 

2、目标库

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

 

3、执行如下迁移语句


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.


4、迁移后,迁移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


猜你喜欢

转载自blog.51cto.com/jiujian/2497982