分享一个最简便的Oracle PDB克隆/迁移方式

一、克隆/迁移准备

前提:源库启动归档模式

1、源数据库配置

$ sqlplus / as sysdba

SQL> alter session set container=MESPROD;

SQL> grant connect, create pluggable database to system;

2、目标数据库配置

2.1 配置TNS,增加源库CDB的解析:

MESPROD_CDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 源库IP)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

2.2 创建DB Link:

在目标库CBD中创建连接源库CDB的dblink。

$ sqplus / as sysdba

SQL>  create database link cp_link connect to system identified by xxxxxx using 'MESPROD_CDB';

2.3 检查dblink是否可用

SQL> select count(*) from all_users@cp_link;

2.4 创建目标库数据文件目录

$ mkdir -p /u19/app/oracle/oradata/

设置db_create_file_dest参数

SQL> alter system set db_create_file_dest='/u19/app/oracle/oradata';

二、克隆PDB

1、删除目标数据库原PDB

$ sqlplus / as sysdba

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 TESTPDB                        READ WRITE NO

         4 MESTEST                        READ WRITE NO

SQL> alter pluggable database MESTEST close;

Pluggable database altered.

SQL> drop pluggable database MESTEST including datafiles;

Pluggable database dropped.

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 TESTPDB                        READ WRITE NO

2、运行在线克隆

# su - oracle

$ sqlplus / as sysdba

SQL> create pluggable database mestest from mesprod@cp_link;

Pluggable database created.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 TESTPDB                        READ WRITE NO

         4 MESTEST                        MOUNTED

SQL> alter pluggable database MESTEST open;

Pluggable database altered.

SQL> alter pluggable database MESTEST save state;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED

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

         2 PDB$SEED                       READ ONLY  NO

         3 TESTPDB                        READ WRITE NO

         4 MESTEST                        READ WRITE NO

至此,PDB克隆/迁移完成。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值