大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

不同CDB之间迁移PDB

测试环境

创新互联主营霸州网站建设的网络公司,主营网站建设方案,成都app软件开发,霸州h5微信小程序搭建,霸州网站营销推广欢迎霸州等地区企业咨询

源环境
目标环境

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

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


新闻名称:不同CDB之间迁移PDB
URL标题:http://dzwzjz.com/article/iegspi.html
在线咨询
服务热线
服务热线:028-86922220
TOP