不同CDB之间迁移PDB

发布时间:2020-07-16 17:32:06 作者:湛康颖
来源:网络 阅读:3611


测试环境

源环境
目标环境

主机操作系统 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
--------------------------------------------------------------------------------
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>

完成测试,因为时间原因没有详细解释,先将就一下看吧。

推荐阅读:
  1. oracle cdb、pdb参考
  2. Oracle 12C CDB、PDB常用管理命令

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

不同 cdb 直接迁移

上一篇:阿里云ssh远程连接短时间就会断掉怎么办

下一篇:js6的未来(一)

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》