Oracle 12c RMAN Performing Cross-Platform Transport of a PDB Using Inconsistent

可以使用不一致与一致备份来传输PDB并将其插入到不同平台的CDB中。不一致备份能减少停机时间因为当PDB为open状态时可以创建跨平台不一致备份。第一次备份为增量0级备份。后续备份为增量1级备份它包含自上次增量备 份以来所有发生的改变。对于不一致1级备份的次数没有限制。最后关闭PDB,创建最终一致的增量1级备份与插入PDB到目标CDB中所需要的元数据XML文件。

源CDB与目标CDB的compatible参数必须设置为12.2。源CDB与目标CDB必须有相同的字节序。

下面的例子将Linux平台上的RAC CDB中的PDB数据库(jypdb与testpdb)传输到windows平台上的单实例CDB数据库中。 执行跨平台传输的操作如下:
1.检查源数据库与目标数据库的compatible参数是否设置为12.0.0或更高版本
源数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

目标数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

2.检查源平台与目标平台的字节序
源平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                                         ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Linux x86 64-bit                                                                                      Little

目标平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                       ENDIAN_FORMAT
--------------------------------------------------------------------------------    --------------
Microsoft Windows x86 64-bit                                                        Little

3.确保被传输的PDB(testpdb)为读写状态

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
TESTPDB                                                                                                                          READ WRITE

4.在创建0级增量备份之前记录数据库的SCN

SQL> SELECT CHECKPOINT_CHANGE# FROM V$DATABASE;

CHECKPOINT_CHANGE#
------------------
          21580167

5.对传输PDB(testpdb)创建不一致的跨平台的增量0级备份

RMAN> backup incremental level 0 for transport allow inconsistent pluggable database testpdb format '/ora_backup/tpdbs/testpdb_level0.bck';

Starting backup at 12-FEB-18
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1525 instance=jy1 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00047 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00048 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00046 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00049 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00051 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00050 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 12-FEB-18
channel ORA_DISK_1: finished piece 1 at 12-FEB-18
piece handle=/ora_backup/tpdbs/testpdb_level0.bck tag=TAG20180212T001250 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 12-FEB-18

[oracle@jytest1 tpdbs]$ ls -lrt
total 693420
-rw-r----- 1 oracle asmadmin 710049792 Feb 11 18:13 testpdb_level0.bck

6.关闭PDB

SQL> alter pluggable database testpdb close immediate;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                         READ ONLY
JYPDB                                                                                                                            READ WRITE
TESTPDB                                                                                                                          MOUNTED

7.创建一致的跨平台增量备份。增量备份的时间点就是步骤4记录的SCN号。使用unplug into子句来生成插入PDB到目标CDB中所需要的元数据XML文件。

RMAN> backup incremental from scn 21580167 for transport unplug into '/ora_backup/tpdbs/metadata_testpdb.xml' pluggable database testpdb format '/ora_backup/tpdbs/testpdb_level1_con.bck';

Starting backup at 12-FEB-18
starting full resync of recovery catalog
full resync complete
using channel ORA_DISK_1
running UNPLUG on the specified pluggable database: TESTPDB
UNPLUG file path : /ora_backup/tpdbs/metadata_testpdb.xml
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00047 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00048 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00046 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00049 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00051 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00050 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 12-FEB-18
channel ORA_DISK_1: finished piece 1 at 12-FEB-18
piece handle=/ora_backup/tpdbs/testpdb_level1_con.bck tag=TAG20180212T002650 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 12-FEB-18
starting full resync of recovery catalog
full resync complete

8.将在源平台上使用rman backup命令生成的备份集与备份的控制文件传输到目标平台的D:\app\oracle\oradata\pdbs目录中

9.确保目标CDB为读写状态

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
JY        READ WRITE

10.还原不一致的跨平台增量0级备份

RMAN> restore foreign pluggable database testpdb format 'D:\APP\ORACLE\ORADATA\JY\DATAFILE\%U' from backupset 'D:\app\oracle\oradata\pdbs\testpdb_level0.bck';

从位于 12-2月 -18 的 restore 开始
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=2654 设备类型=DISK

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\pdbs\testpdb_level0.bck
通道 ORA_DISK_1: 将外部文件 47 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSAUX_FNO-47_4USR0JDU
通道 ORA_DISK_1: 将外部文件 48 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDOTBS1_FNO-48_01SR0JDU
通道 ORA_DISK_1: 将外部文件 46 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSTEM_FNO-46_5ESR0JDU
通道 ORA_DISK_1: 将外部文件 49 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDO_2_FNO-49_2JSR0JDU
通道 ORA_DISK_1: 将外部文件 51 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-TEST_FNO-51_9RSR0JDU
通道 ORA_DISK_1: 将外部文件 50 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-USERS_FNO-50_EKSR0JDU
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\pdbs\testpdb_level0.bck
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:16
在 12-2月 -18 完成了 restore

11.给步骤10所还原的外部数据文件应用一致的跨平台增量1级备份

RMAN> recover using 'D:\app\oracle\oradata\pdbs\metadata_testpdb.xml' foreign datafilecopy 'D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSAUX_FNO-47_4USR0JDU','D:\APP \ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDOTBS1_FNO-48_01SR0JDU','D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA
_D-JY_I-979425723_TS-SYSTEM_FNO-46_5ESR0JDU','D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDO_2_FNO-49_2JSR0JDU','D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I- 979425723_TS-TEST_FNO-51_9RSR0JDU','D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-USERS_FNO-50_EKSR0JDU'
2> from backupset 'D:\app\oracle\oradata\pdbs\testpdb_level1_con.bck';

从位于 12-2月 -18 的 restore 开始
使用通道 ORA_DISK_1

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原外部文件 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSAUX_FNO-47_4USR0JDU
通道 ORA_DISK_1: 正在还原外部文件 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDOTBS1_FNO-48_01SR0JDU
通道 ORA_DISK_1: 正在还原外部文件 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSTEM_FNO-46_5ESR0JDU
通道 ORA_DISK_1: 正在还原外部文件 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDO_2_FNO-49_2JSR0JDU
通道 ORA_DISK_1: 正在还原外部文件 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-TEST_FNO-51_9RSR0JDU
通道 ORA_DISK_1: 正在还原外部文件 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-USERS_FNO-50_EKSR0JDU
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\pdbs\testpdb_level1_con.bck
通道 ORA_DISK_1: 将外部文件 47 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSAUX_FNO-47_4USR0JDU
通道 ORA_DISK_1: 将外部文件 48 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDOTBS1_FNO-48_01SR0JDU
通道 ORA_DISK_1: 将外部文件 46 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSTEM_FNO-46_5ESR0JDU
通道 ORA_DISK_1: 将外部文件 49 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDO_2_FNO-49_2JSR0JDU
通道 ORA_DISK_1: 将外部文件 51 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-TEST_FNO-51_9RSR0JDU
通道 ORA_DISK_1: 将外部文件 50 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-USERS_FNO-50_EKSR0JDU
通道 ORA_DISK_1: 外部片段句柄 = D:\APP\ORACLE\ORADATA\PDBS\TESTPDB_LEVEL1_CON.BCK
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:02
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409 插入文件 46
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409 插入文件 47
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409 插入文件 48
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.967852409 插入文件 4
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409 插入文件 49
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409 插入文件 50
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409 插入文件 51
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: 位于 02/12/2018 01:00:33 的 restore 命令失败
RMAN-00600: internal error, arguments [5304] [+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.967852409] [] [] []

上面的错误是因为XMl文件所描述的数据文件名是源数据库中的文件名,手功修改XML文件中的数据文件名为目标数据库中的数据文件名,并执行下面的命令来创建PDB

SQL> create pluggable database testpdb using 'D:\app\oracle\oradata\pdbs\metadata_testpdb.xml';

插接式数据库已创建。

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                     OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                 READ ONLY
JYPDB                                                                                                                    READ WRITE
TESTPDB                                                                                                                  MOUNTED

SQL> alter pluggable database testpdb open;

插接式数据库已变更。

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                     OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                 READ ONLY
JYPDB                                                                                                                    READ WRITE
TESTPDB                                                                                                                  READ WRITE


12.查询tts.t1与cs.t2表中的数据来验证跨平台传输PDB是否操作成功

SQL> select count(*) from tts.t1;

  COUNT(*)
----------
        90

SQL> select count(*) from cs.t2;

  COUNT(*)
----------
        92

到此,跨平台传输PDB就完成了。

Oracle 12c RMAN Cross-Platform Transport of a Closed PDB

PDB可以被传输并插入到与源平台不同的目标CDB数据库中。除了需要对PDB创建备份外还需要将PDB插入到目标CDB中所需要的元数据。源CDB与目标CDB中的compatible参数必须设置为12.2,并且源平台与目标平台有相同的字节 序。

下面的例子将Linux平台上的RAC CDB中的PDB数据库(jypdb与testpdb)传输到windows平台上的单实例CDB数据库中。 执行跨平台传输的操作如下:
1.检查源数据库与目标数据库的compatible参数是否设置为12.0.0或更高版本
源数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

目标数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

2.检查源平台与目标平台的字节序
源平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                                         ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Linux x86 64-bit                                                                                      Little

目标平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                       ENDIAN_FORMAT
--------------------------------------------------------------------------------    --------------
Microsoft Windows x86 64-bit                                                        Little

3.将要被传输的pdb(jypdb,testpdb)设置为关闭状态

SQL> alter pluggable database jypdb close immediate;

Pluggable database altered.

SQL> alter pluggable database testpdb close immediate;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                         READ ONLY
JYPDB                                                                                                                            MOUNTED
TESTPDB                                                                                                                          MOUNTED

4.使用backup pluggable database命令来为PDB(jypdb,testpdb)创建跨平台完全备份
下面的例子是为PDB(jypdb,testpdb)创建跨平台传输备份目标平台为Microsoft Windows x86 64-bit。使用unplug into子句将生成将PDB插入目标CDB中所需要的元数据XML文件。

RMAN> backup to platform='Microsoft Windows x86 64-bit' unplug into '/ora_backup/tpdbs/metadata_jypdb.xml' pluggable database jypdb format '/ora_backup/tpdbs/transport_jypdb.bck';

Starting backup at 11-FEB-18
using channel ORA_DISK_1
running UNPLUG on the specified pluggable database: JYPDB
UNPLUG file path : /ora_backup/tpdbs/metadata_jypdb.xml
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00028 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
input datafile file number=00025 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
input datafile file number=00026 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
input datafile file number=00027 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
input datafile file number=00024 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
input datafile file number=00029 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
input datafile file number=00030 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353
input datafile file number=00031 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783
channel ORA_DISK_1: starting piece 1 at 11-FEB-18
channel ORA_DISK_1: finished piece 1 at 11-FEB-18
piece handle=/ora_backup/tpdbs/transport_jypdb.bck tag=TAG20180211T223539 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 11-FEB-18
starting full resync of recovery catalog
full resync complete

RMAN> backup to platform='Microsoft Windows x86 64-bit' unplug into '/ora_backup/tpdbs/metadata_testpdb.xml' pluggable database testpdb format '/ora_backup/tpdbs/transport_testpdb.bck';

Starting backup at 11-FEB-18
using channel ORA_DISK_1
running UNPLUG on the specified pluggable database: TESTPDB
UNPLUG file path : /ora_backup/tpdbs/metadata_testpdb.xml
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00033 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00034 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00032 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00035 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00037 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00036 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 11-FEB-18
channel ORA_DISK_1: finished piece 1 at 11-FEB-18
piece handle=/ora_backup/tpdbs/transport_testpdb.bck tag=TAG20180211T223830 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 11-FEB-18
starting full resync of recovery catalog
full resync complete


[oracle@jytest1 tpdbs]$ ls -lrt
total 1707044
-rw-r--r-- 1 oracle asmadmin      11417 Feb 11 16:36 metadata_jypdb.xml
-rw-r----- 1 oracle asmadmin 1038204928 Feb 11 16:37 transport_jypdb.bck
-rw-r--r-- 1 oracle asmadmin       9575 Feb 11 16:38 metadata_testpdb.xml
-rw-r----- 1 oracle asmadmin  709779456 Feb 11 16:39 transport_testpdb.bck


5.将步骤4生成的备份文件与XML文件传输到目标主机上的D:\app\oracle\oradata\pdbs目录中

6.确保目标CDB数据库的状态为读写状态

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

7.执行dbms_pdb.check_plug_compatibility过程来判断被传输的PDB与目标CDB是否兼容。

SQL> declare
  2    c boolean;
  3  begin
  4    c:=dbms_pdb.check_plug_compatibility('D:\app\oracle\oradata\pdbs\metadata_jypdb.xml','JYPDB');
  5    if (c) then dbms_output.put_line('True');
  6      else dbms_output.put_line('False');
  7    end if;
  8  end;
  9  /

PL/SQL 过程已成功完成。

SQL> declare
  2    c boolean;
  3  begin
  4    c:=dbms_pdb.check_plug_compatibility('D:\app\oracle\oradata\pdbs\metadata_testpdb.xml','TESTPDB');
  5    if (c) then dbms_output.put_line('True');
  6      else dbms_output.put_line('False');
  7    end if;
  8  end;
  9  /

PL/SQL 过程已成功完成。

8.还原PDB备份
使用using子句来存储将源PDB插入目标CDB所需要的元数据所在的XML文件名。为了将数据文件复制到与XML文件所描述的不同位置使用file_name_convert子句。

RMAN> restore using 'D:\app\oracle\oradata\pdbs\metadata_jypdb.xml'   foreign pluggable database JYPDB format 'D:\APP\ORACLE\ORADATA\JY\DATAFILE\%U' from backupset 'D:\app\oracle\oradata \pdbs\transport_jypdb.bck';

从位于 11-2月 -18 的 restore 开始
使用通道 ORA_DISK_1

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\pdbs\transport_jypdb.bck
通道 ORA_DISK_1: 将外部文件 28 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-USERS_FNO-28_IASR0EH6
通道 ORA_DISK_1: 将外部文件 25 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSAUX_FNO-25_EGSR0EH6
通道 ORA_DISK_1: 将外部文件 26 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDOTBS1_FNO-26_TESR0EH6
通道 ORA_DISK_1: 将外部文件 27 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDO_2_FNO-27_D2SR0EH6
通道 ORA_DISK_1: 将外部文件 24 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSTEM_FNO-24_FFSR0EH6
通道 ORA_DISK_1: 将外部文件 29 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-TEST_FNO-29_OMSR0EH6
通道 ORA_DISK_1: 将外部文件 30 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-TTS_FNO-30_SUSR0EH6
通道 ORA_DISK_1: 将外部文件 31 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-CS_FNO-31_7LSR0EH6
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\pdbs\transport_jypdb.bck
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:36
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649 插入文件 24
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649 插入文件 25
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649 插入文件 26
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/TEMPFILE/temp.258.967837571 插入文件 5
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649 插入文件 27
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649 插入文件 28
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609 插入文件 29
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353 插入文件 30
通道 ORA_DISK_1: 正在为 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783 插入文件 31
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: 位于 02/11/2018 23:22:50 的 restore 命令失败
RMAN-00600: internal error, arguments [5302] [] [] [] []





RMAN> restore using 'D:\app\oracle\oradata\pdbs\metadata_testpdb.xml'   foreign pluggable database testpdb format 'D:\APP\ORACLE\ORADATA\JY\DATAFILE\%U' from backupset 'D:\app\oracle \oradata\pdbs\transport_testpdb.bck';

从位于 11-2月 -18 的 restore 开始
使用通道 ORA_DISK_1

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\pdbs\transport_testpdb.bck
通道 ORA_DISK_1: 将外部文件 33 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSAUX_FNO-33_N4SR0EOK
通道 ORA_DISK_1: 将外部文件 34 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDOTBS1_FNO-34_S1SR0EOK
通道 ORA_DISK_1: 将外部文件 32 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-SYSTEM_FNO-32_KTSR0EOK
通道 ORA_DISK_1: 将外部文件 35 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-UNDO_2_FNO-35_PGSR0EOK
通道 ORA_DISK_1: 将外部文件 37 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-TEST_FNO-37_1MSR0EOK
通道 ORA_DISK_1: 将外部文件 36 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\DATA_D-JY_I-979425723_TS-USERS_FNO-36_9ASR0EOK
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\pdbs\transport_testpdb.bck
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:16
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409 插入文件 32
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409 插入文件 33
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409 插入文件 34
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.276.967837623 插入文件 6
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409 插入文件 35
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409 插入文件 36
通道 ORA_DISK_1: 正在为 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409 插入文件 37
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: 位于 02/11/2018 23:26:28 的 restore 命令失败
RMAN-00600: internal error, arguments [5302] [] [] [] []

上面的错误是因为XMl文件所描述的数据文件名是源数据库中的文件名,手功修改XML文件中的数据文件名为目标数据库中的数据文件名,并执行下面的命令来创建PDB


SQL> create pluggable database jypdb using 'D:\app\oracle\oradata\pdbs\metadata_jypdb.xml';

插接式数据库已创建。

SQL> create pluggable database testpdb using 'D:\app\oracle\oradata\pdbs\metadata_testpdb.xml';

插接式数据库已创建。



SQL> alter pluggable database all open;

插接式数据库已变更。

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                     OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                 READ ONLY
JYPDB                                                                                                                    READ WRITE
TESTPDB                                                                                                                  READ WRITE

9.查询tts.t1与cs.t2表中的数据来验证跨平台传输PDB是否操作成功

SQL> select count(*) from tts.t1;

  COUNT(*)
----------
        90

SQL> select count(*) from cs.t2;

  COUNT(*)
----------
        92

到此,跨平台传输PDB就完成了。

Oracle 12C RMAN Cross-Platform Transport of PDBs

为了将整个PDB传输到不同的平台,源平台与目标平台必须使用相同的字节序。compatible参数在源CDB数据库与目标CDB数据库中必须设置为12.1或更高版本。

下面的例子将Linux平台上的RAC CDB中的PDB数据库(jypdb与testpdb)传输到windows平台上的单实例CDB数据库中。 执行跨平台传输的操作如下:
1.检查源数据库与目标数据库的compatible参数是否设置为12.0.0或更高版本
源数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

目标数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

2.检查源平台与目标平台的字节序
源平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                                         ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Linux x86 64-bit                                                                                      Little

目标平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                       ENDIAN_FORMAT
--------------------------------------------------------------------------------    --------------
Microsoft Windows x86 64-bit                                                        Little

3.将要被传输的pdb(jypdb,testpdb)设置为只读状态

SQL> alter pluggable database all close immediate;

Pluggable database altered.

SQL> set long 200
SQL> set linesize 200
SQL>  select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                         READ ONLY
JYPDB                                                                                                                            MOUNTED
TESTPDB                                                                                                                          MOUNTED

4.备份要传输的PDB数据库,可以使用以下一种方法来跨平台传输PDB
4.1使用RMAN连接到CDB的root容器,并使用backup for transport ***230; pluggable database或者backup to platform ***230; pluggable database命令来为PDB创建跨平台备份。

4.2使用RMAN连接到PDB,并使用backup for transport或backup to platform命令来为PDB创建跨平台备份。

因为我这里要传输两个PDB所以选择第一种方法

RMAN> backup for transport unplug into '/ora_backup/tpdbs/metadata_jypdb.xml' pluggable database jypdb  format '/ora_backup/tpdbs/pdb_%U';

Starting backup at 11-FEB-18
using channel ORA_DISK_1
running UNPLUG on the specified pluggable database: JYPDB
UNPLUG file path : /ora_backup/tpdbs/metadata_jypdb.xml
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
input datafile file number=00011 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
input datafile file number=00012 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
input datafile file number=00013 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
input datafile file number=00010 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
input datafile file number=00015 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
input datafile file number=00022 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353
input datafile file number=00023 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783
channel ORA_DISK_1: starting piece 1 at 11-FEB-18
channel ORA_DISK_1: finished piece 1 at 11-FEB-18
piece handle=/ora_backup/tpdbs/pdb_8csqvqc5_1_1 tag=TAG20180211T173748 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:56
Finished backup at 11-FEB-18
starting full resync of recovery catalog
full resync complete

RMAN> backup for transport unplug into '/ora_backup/tpdbs/metadata_testpdb.xml' pluggable database testpdb  format '/ora_backup/tpdbs/pdb_%U';

Starting backup at 11-FEB-18
starting full resync of recovery catalog
full resync complete
using channel ORA_DISK_1
running UNPLUG on the specified pluggable database: TESTPDB
UNPLUG file path : /ora_backup/tpdbs/metadata_testpdb.xml
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00018 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00016 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00019 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00021 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00020 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 11-FEB-18
channel ORA_DISK_1: finished piece 1 at 11-FEB-18
piece handle=/ora_backup/tpdbs/pdb_8dsqvqpj_1_1 tag=TAG20180211T174458 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 11-FEB-18
starting full resync of recovery catalog
full resync complete


[oracle@jytest1 tpdbs]$ ls -lrt
total 1707488
-rw-r--r-- 1 oracle asmadmin      11413 Feb 11 11:38 metadata_jypdb.xml
-rw-r----- 1 oracle asmadmin 1038368768 Feb 11 11:39 pdb_8csqvqc5_1_1
-rw-r--r-- 1 oracle asmadmin       9569 Feb 11 11:45 metadata_testpdb.xml
-rw-r----- 1 oracle asmadmin  710066176 Feb 11 11:45 pdb_8dsqvqpj_1_1

5.将在源平台上使用rman backup命令生成的备份集与备份的控制文件传输到目标平台的D:\app\oracle\oradata\pdbs目录中

6.将PDB(jypdb,testpdb)还原到目标数据库

RMAN> restore from platform 'Linux x86 64-bit'   foreign pluggable database jypdb  to new from backupset 'D:\app\oracle\oradata\pdbs\pdb_8csqvqc5_1_1';

从位于 11-2月 -18 的 restore 开始
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=1522 设备类型=DISK

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\pdbs\pdb_8csqvqc5_1_1
通道 ORA_DISK_1: 将外部文件 14 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_USERS_F805GPMS_.DBF
通道 ORA_DISK_1: 将外部文件 11 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_SYSAUX_F805GPMS_.DBF
通道 ORA_DISK_1: 将外部文件 12 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_UNDOTBS1_F805GPMS_.DBF
通道 ORA_DISK_1: 将外部文件 13 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_UNDO_2_F805GPMS_.DBF
通道 ORA_DISK_1: 将外部文件 10 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_SYSTEM_F805GPN8_.DBF
通道 ORA_DISK_1: 将外部文件 15 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_TEST_F805GPN8_.DBF
通道 ORA_DISK_1: 将外部文件 22 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_TTS_F805GPN8_.DBF
通道 ORA_DISK_1: 将外部文件 23 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_CS_F805GPN8_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\pdbs\pdb_8csqvqc5_1_1
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:36
在 11-2月 -18 完成了 restore


RMAN> restore from platform 'Linux x86 64-bit'   foreign pluggable database testpdb  to new from backupset 'D:\app\oracle\oradata\pdbs\pdb_8dsqvqpj_1_1';

从位于 11-2月 -18 的 restore 开始
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=1522 设备类型=DISK

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\pdbs\pdb_8dsqvqpj_1_1
通道 ORA_DISK_1: 将外部文件 17 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_SYSAUX_F806C6WT_.DBF
通道 ORA_DISK_1: 将外部文件 18 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_UNDOTBS1_F806C6WT_.DBF
通道 ORA_DISK_1: 将外部文件 16 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_SYSTEM_F806C6WT_.DBF
通道 ORA_DISK_1: 将外部文件 19 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_UNDO_2_F806C6XB_.DBF
通道 ORA_DISK_1: 将外部文件 21 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_TEST_F806C6XB_.DBF
通道 ORA_DISK_1: 将外部文件 20 还原到 D:\APP\ORACLE\ORADATA\JY\DATAFILE\O1_MF_USERS_F806C6XB_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\pdbs\pdb_8dsqvqpj_1_1
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:26
在 11-2月 -18 完成了 restore

7.在目标主机上修改metadata_jypdb.xml与metadata_testpdb.xml文件将数据文件路径修改为还原后数据文件所在路径

8.将传输过来的PDB(jypdb,testpdb)插入CDB

SQL> create pluggable database jypdb using 'D:\app\oracle\oradata\pdbs\metadata_jypdb.xml' nocopy;

插接式数据库已创建。


SQL> create pluggable database testpdb using 'D:\app\oracle\oradata\pdbs\metadata_testpdb.xml' nocopy ;

插接式数据库已创建。

SQL> set long 200
SQL> set linesize 200
SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                     OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                 READ ONLY
JYPDB                                                                                                                    MOUNTED
TESTPDB                                                                                                                  MOUNTED

SQL> alter pluggable database all open;

插接式数据库已变更。

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                     OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                 READ ONLY
JYPDB                                                                                                                    READ WRITE
TESTPDB                                                                                                                  READ WRITE

9.查询tts.t1与cs.t2表中的数据来验证跨平台传输PDB是否操作成功

SQL> select count(*) from tts.t1;

  COUNT(*)
----------
        90

SQL> select count(*) from cs.t2;

  COUNT(*)
----------
        92

到此,跨平台传输PDB就完成了。

Oracle 12C使用备份集执行只读表空间的跨平台传输

使用带用for transport或to platform子句的backup命令来创建备份集来将只读表空间从一个平台传输到另一个平台。当传输只读表空间时,必须要导出这些表空间的元数据。这些元数据会在将表空间附加到目标数据库时需要使用。当跨平台传输表空间时,源平台与目标平台可以使用不同的字节序。可以还原跨平台备份中的所有数据文件或表空间或者它们中的一部分。在还原这些对象之后,可以为被还原的数据文件指定路径与名称。

使用备份集执行跨平台传输表空间的先决条件
.源数据库与目标数据库的spfile参数文件中的compatible参数必须设置为12.0.0或更高版本。

.被传输的表空间必须是自包含。执行dbms_tts.transport_set_check过程来检查依赖性。如果transport_set_violations视图包含指定表空间的相关行记录,那么必须在创建跨平台备份之前解决这种依赖性。

.被传输的表空间必须是只读模式,除非在backup命令中使用了allow inconsistent子句。

下面的例子将Linux平台上的RAC CDB中的jypdb的表空间tts与cs传输到windows平台上的单实例CDB的jypdb数据库中。使用备份集对只读表空间执行跨平台传输的操作如下:
1.检查源数据库与目标数据库的compatible参数是否设置为12.0.0或更高版本
源数据库

SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

目标数据库
SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      12.2.0
noncdb_compatible                    boolean     FALSE

2.对源数据库中的要被传输的表空间tts与cs执行自包含检查

SQL> alter session set container=jypdb;

Session altered.

SQL> exec sys.dbms_tts.transport_set_check('TTS,CS',true);

PL/SQL procedure successfully completed.

SQL> select * from sys.transport_set_violations;

no rows selected

3.检查源平台与目标平台的字节序
源平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where tp.platform_name=d.platform_name;

PLATFORM_NAME                                                                                         ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Linux x86 64-bit                                                                                      Little

目标平台

SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d  where t

PLATFORM_NAME                                                                       ENDIAN_FORMAT
--------------------------------------------------------------------------------    --------------
Microsoft Windows x86 64-bit                                                        Little

4.将要被传输的表空间(tts,cs)设置为只读状态

SQL> alter tablespace tts read only;

Tablespace altered.

SQL> alter tablespace cs read only;

Tablespace altered.


SQL> select tablespace_name,status from user_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
UNDO_2                         ONLINE
USERS                          ONLINE
TEST                           ONLINE
TTS                            READ ONLY
CS                             READ ONLY

9 rows selected.

5.给RMAN备份输出文件选择命名方法,使用backup命令的format子句来为备份输出文件选择输出方法。

6.启动RMAN连接到源数据库(整个RAC CDB)并将重启源数据库并以只读方式打开

[oracle@jytest1 ~]$ rman target sys/abcd@jy catalog rco/abcd@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Feb 5 23:22:24 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: JY (DBID=979425723)
connected to recovery catalog database

7.在backup命令中使用for transport或to platform子句来备份表空间。下面的例子对表空间tts与cs创建跨平台传输备份。备份可以被还原到Microsoft Windows IA (64-bit)平台。Data Pump导出dump文件包含了附加表空间到目标数据库中所需要的元数据。备份文件与dump文件存储在/ora_backup/tts目录中。

RMAN> backup to platform 'Microsoft Windows x86 64-bit' format '/ora_backup/tts/trans_ts.bck' datapump format '/ora_backup/tts/trans_ts_dmp.bck' tablespace JYPDB:'TTS',JYPDB:'CS';

Starting backup at 05-FEB-18
using channel ORA_DISK_1
Running TRANSPORT_SET_CHECK on specified tablespaces
TRANSPORT_SET_CHECK completed successfully

Performing export of metadata for specified tablespaces...
   EXPDP> Starting "SYS"."TRANSPORT_EXP_JY_xput":  
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
   EXPDP> Master table "SYS"."TRANSPORT_EXP_JY_xput" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TRANSPORT_EXP_JY_xput is:
   EXPDP>   /u01/app/oracle/product/12.2.0/db/dbs/backup_tts_JY_38873.dmp
   EXPDP> ******************************************************************************
   EXPDP> Datafiles required for transportable tablespace CS:
   EXPDP>   +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783
   EXPDP> Datafiles required for transportable tablespace TTS:
   EXPDP>   +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353
   EXPDP> Job "SYS"."TRANSPORT_EXP_JY_xput" successfully completed at Mon Feb 5 23:57:57 2018 elapsed 0 00:03:08
Export completed

channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00022 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353
input datafile file number=00023 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783
channel ORA_DISK_1: starting piece 1 at 05-FEB-18
channel ORA_DISK_1: finished piece 1 at 05-FEB-18
piece handle=/ora_backup/tts/trans_ts.bck tag=TAG20180205T235319 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
input Data Pump dump file=/u01/app/oracle/product/12.2.0/db/dbs/backup_tts_JY_38873.dmp
channel ORA_DISK_1: starting piece 1 at 05-FEB-18
channel ORA_DISK_1: finished piece 1 at 05-FEB-18
piece handle=/ora_backup/tts/trans_ts_dmp.bck tag=TAG20180205T235319 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-FEB-18
starting full resync of recovery catalog
full resync complete


[oracle@jytest1 tts]$ ls -lrt
total 2472
-rw-r----- 1 oracle asmadmin 2318336 Feb  5 17:57 trans_ts.bck
-rw-r----- 1 oracle asmadmin  212992 Feb  5 17:57 trans_ts_dmp.bck

因为在backup命令中使用了to platform子句,因此将数据文件转换成目标平台字节序的操作在源平台执行。

8.将backup命令生成的备份集与Data Pump导出的dump文件传输到目标平台的D:\app\oracle\oradata\tts目录中

9.使用rman连接到目标数据库(单实例CDB中的JYPDB)

C:\Users\Administrator>rman target sys/abcd@jypdb

恢复管理器: Release 12.2.0.1.0 - Production on 星期一 2月 5 00:22:31 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

已连接到目标数据库: JY:JYPDB (DBID=4203494064)

10.使用有foreign tablespace子句的restore命令来还原从源平台传输过来的备份集

RMAN> restore foreign tablespace TTS,CS to new from backupset 'D:\app\oracle\oradata\tts\trans_ts.bck' dump file from backupset 'D:\app\oracle\oradata\tts\trans_ts_dmp.bck';

从位于 06-2月 -18 的 restore 开始
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=8 设备类型=DISK

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原外部表空间 TTS 中的所有文件
通道 ORA_DISK_1: 正在还原外部表空间 CS 中的所有文件
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\tts\trans_ts.bck
通道 ORA_DISK_1: 将外部文件 22 还原到 D:\APP\ORACLE\ORADATA\JY\5F9AC6865E87549FE053AB828A0ADE94\DATAFILE\O1_MF_TTS_F7K17RGW_.DBF
通道 ORA_DISK_1: 将外部文件 23 还原到 D:\APP\ORACLE\ORADATA\JY\5F9AC6865E87549FE053AB828A0ADE94\DATAFILE\O1_MF_CS_F7K17RHC_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\tts\trans_ts.bck
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:02
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在将数据泵转储文件还原到 D:\app\oracle\product\12.2.0\dbhome_1/dbs/backup_tts_JY_38586.dmp
通道 ORA_DISK_1: 正在读取备份片段 D:\app\oracle\oradata\tts\trans_ts_dmp.bck
通道 ORA_DISK_1: 外部片段句柄 = D:\app\oracle\oradata\tts\trans_ts_dmp.bck
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:02

正在执行元数据导入...
   IMPDP> 已成功加载/卸载了主表 "SYS"."TSPITR_IMP_JY_pfCp"
   IMPDP> 启动 "SYS"."TSPITR_IMP_JY_pfCp":
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/PLUGTS_BLK
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/TABLE
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/INDEX/INDEX
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/INDEX_STATISTICS
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/TABLE_STATISTICS
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/STATISTICS/MARKER
   IMPDP> 处理对象类型 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   IMPDP> 作业 "SYS"."TSPITR_IMP_JY_pfCp" 已于 星期二 2月 6 00:24:02 2018 elapsed 0 00:00:33 成功完成
导入完毕

在 05-2月 -18 完成了 restore

11.在目标数据库中查询表tts.t1与cs.t2记录是否与源数据库中一致,如果一致说用表空间tts与cs跨平台传输成功
源数据库

SQL> alter session set container=jypdb;

会话已更改。

SQL> select count(*) from tts.t1;

  COUNT(*)
----------
        45

SQL> select count(*) from cs.t2;

  COUNT(*)
----------
        46

目标数据库

SQL> alter session set container=jypdb;

会话已更改。

SQL> select count(*) from tts.t1;

  COUNT(*)
----------
        45

SQL> select count(*) from cs.t2;

  COUNT(*)
----------
        46

到此使用备份集跨平台传输只读表空间操作就完成了。

Oracle 12C RMAN Duplicating Tablespaces Within a PDB

使用RMAN复制对CDB中的PDB的表空间操作如下
1.检查源RAC CDB(jy)的参数文件,数据文件,联机日志文件,控制文件,归档日志文件的存储目录

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------------------------------------------
spfile                               string      +DATA/JY/PARAMETERFILE/spfile.303.961976713

RMAN> report schema;

Report of database schema for database with db_unique_name JY

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    840      SYSTEM               YES     +DATA/JY/DATAFILE/system.317.962209603
3    2340     SYSAUX               NO      +DATA/JY/DATAFILE/sysaux.298.962209605
4    1015     UNDOTBS1             YES     +DATA/JY/DATAFILE/undotbs1.277.962209605
5    250      PDB$SEED:SYSTEM      NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
6    340      PDB$SEED:SYSAUX      NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
7    5        USERS                NO      +DATA/JY/DATAFILE/users.301.962209605
8    100      PDB$SEED:UNDOTBS1    NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
9    1350     UNDOTBS2             YES     +DATA/JY/DATAFILE/undotbs2.312.962209605
10   270      JYPDB:SYSTEM         YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
11   590      JYPDB:SYSAUX         NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
12   205      JYPDB:UNDOTBS1       YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
13   310      JYPDB:UNDO_2         YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
14   1267     JYPDB:USERS          NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
15   100      JYPDB:TEST           NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
16   260      TESTPDB:SYSTEM       YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
17   550      TESTPDB:SYSAUX       NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
18   245      TESTPDB:UNDOTBS1     YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
19   100      TESTPDB:UNDO_2       YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
20   5        TESTPDB:USERS        NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
21   100      TESTPDB:TEST         NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    144      TEMP                 32767       +DATA/JY/TEMPFILE/temp.299.961976339
2    64       PDB$SEED:TEMP        32767       +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/TEMPFILE/temp.297.962209865
3    137      JYPDB:TEMP           32767       +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/TEMPFILE/temp.276.962210519
4    135      TESTPDB:TEMP         32767       +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.962469435

SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------------------------------
control_files                        string      +DATA/JY/CONTROLFILE/current.272.961976315


SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/JY/ONLINELOG/group_2.302.961976321
+DATA/JY/ONLINELOG/group_1.261.961976319
+DATA/JY/ONLINELOG/group_3.263.961976697
+DATA/JY/ONLINELOG/group_4.262.961976705


SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +TEST/arch
Oldest online log sequence     127
Next log sequence to archive   128
Current log sequence           128

2.在目标主机上创建存储目标数据库(dupjy)相关数据库文件的目录,目标主机上的/u01/app/oracle/oradata/dupjy目录用来存储数据库的数据文件,控制文件,联机重做日志文件),/u01/app/oracle/arch/dupjy目录用来存储数据库的归档重做日志文件。

3.将源数据库的密码文件复制到目标主机的相应目录中并修改为目标数据库(dupjy)对应的文件名

[grid@jytest1 ~]$ srvctl config database -db jy
Database unique name: jy
Database name: jy
Oracle home: /u01/app/oracle/product/12.2.0/db
Oracle user: oracle
Spfile: +DATA/JY/PARAMETERFILE/spfile.303.961976713
Password file: +DATA/JY/PASSWORD/pwdjy.274.961976109
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: jy1,jy2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

[grid@jytest1 ~]$ asmcmd cp  +DATA/JY/PASSWORD/pwdjy.274.961976109 /home/grid/pwddupjy
copying +DATA/JY/PASSWORD/pwdjy.274.961976109 -> /home/grid/pwddupjy


[oracle@shard1 dbs]# scp grid@10.138.130.171:/home/grid/pwddupjy /u01/app/oracle/product/12.2.0/db/dbs/
The authenticity of host '10.138.130.171 (10.138.130.171)' can't be established.
ECDSA key fingerprint is 7a:62:58:8b:77:98:52:94:d6:d5:0c:c4:6c:87:a6:7f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.171' (ECDSA) to the list of known hosts.
grid@10.138.130.171's password:
pwddupjy

[oracle@shard1 dbs]$ mv pwddupjy orapwdupjy

4.使用源数据库的spfile文件来创建目标数据库要使用的spfile文件
在源数据库中执行下面的命令来创建pfile参数文件

SQL> create pfile from spfile;

File created.

[root@shard1 ~]# scp oracle@10.138.130.171:/u01/app/oracle/product/12.2.0/db/dbs/initjy1.ora /u01/app/oracle/product/12.2.0/db/dbs/
grid@10.138.130.171's password:
initjy1.ora                                                                                                                                                                                   

             100% 1731     1.7KB/s   00:00
[root@shard1 ~]#


[oracle@shard1 dbs]$ cat initdupjy.ora
*.audit_file_dest='/u01/app/oracle/admin/dupjy/adump'
*.cluster_database=false
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/dupjy/control01.ctl'
*.db_block_size=8192
*.db_name='dupjy'
*.diagnostic_dest='/u01/app/oracle'
*.enable_pluggable_database=true
*.open_cursors=300
*.pga_aggregate_target=1g
*.processes=2000
*.remote_login_passwordfile='exclusive'
*.sga_max_size=2147483648
*.sga_target=2147483648
db_file_name_convert= 

('+DATA/JY/DATAFILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATA 

FILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/','/u01/app/oracle/oradata/dupjy/')
log_file_name_convert=('+DATA/JY/ONLINELOG/','/u01/app/oracle/oradata/dupjy/')



[oracle@shard1 dbs]$ export ORACLE_SID=dupjy
[oracle@shard1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 19:06:00 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdupjy.ora'
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes

SQL> create spfile from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdupjy.ora';

File created.

5.使用spfile参数文件来启动目标数据库实例(辅助实例dupjy)

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes


SQL> show parameter spfile

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- -----------------------------------------------------
spfile                               string                 /u01/app/oracle/product/12.2.0/db/dbs/spfiledupjy.ora

6.给目标数据库配置静态监听

[oracle@shard1 admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = shard1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = dupjy)
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0/db)
      (GLOBAL_DBNAME=dupjy)
    )
  )


[oracle@shard1 admin]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-JAN-2018 20:30:34

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/12.2.0/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/shard1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=shard1)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=shard1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                18-JAN-2018 20:30:34
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/shard1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=shard1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "dupjy" has 1 instance(s).
  Instance "dupjy", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully



7.在目标主机上配置tns,用来通过网络服务名来连接源数据库与目标数据库

[oracle@shard1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.171)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
    )
  )

DUPJY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.180)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dupjy)
    )
  )

8.在目标主机上测试是否可以通过使用网络服务名来连接源数据库与目标数据库

[oracle@shard1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 21:02:53 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@shard1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 21:04:51 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

SQL> conn sys/abcd@dupjy as sysdba
Connected.
SQL> conn sys/abcd@jy as sysdba
Connected.

9.在源主机上配置目标数据库的tns名

[oracle@jytest1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.


JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = jytest-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
    )
  )



DUPJY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.180)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dupjy)
      (UR = A)
    )
  )

10.在源主机上测试能否可以使用网络服务名来连接源数据库与目标数据库

[oracle@jytest1 admin]$ sqlplus /nolog
SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 19 03:16:59 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

SQL> conn sys/abcd@jy as sysdba
Connected.
SQL> conn sys/abcd@dupjy as sysdba
Connected.

11.对PDB的表空间进行复制(将复制jypdb数据库与testpdb数据库中的test表空间(TESTPDB:TEST)

[oracle@jytest1 ~]$ rman target sys/abcd@jy catalog rco/abcd@jypdb_173 auxiliary sys/abcd@dupjy

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Jan 23 23:20:22 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: JY (DBID=979425723)
connected to recovery catalog database
connected to auxiliary database: DUPJY (not mounted)

RMAN> duplicate database to dupjy pluggable database jypdb tablespace TESTPDB:'TEST' from active database nofilenamecheck using compressed backupset;

Starting Duplicate Db at 23-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
current log archived

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''JY'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''DUPJY'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'jy' using compressed backupset
   primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''JY'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''DUPJY'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes

Starting restore at 23-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2269 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:06
output file name=/u01/app/oracle/oradata/dupjy/control01.ctl
Finished restore at 23-JAN-18

database mounted
Automatically adding tablespace SYSTEM
Automatically adding tablespace SYSAUX
Automatically adding tablespace PDB$SEED:SYSTEM
Automatically adding tablespace PDB$SEED:SYSAUX
Automatically adding tablespace TESTPDB:SYSTEM
Automatically adding tablespace TESTPDB:SYSAUX
RMAN-05519: warning: tablespace TESTPDB:SYSTEM is always included when duplicating
Automatically adding tablespace TESTPDB:UNDOTBS1
Automatically adding tablespace UNDOTBS1
Automatically adding tablespace TESTPDB:UNDO_2
Automatically adding tablespace UNDOTBS2
Checking that duplicated tablespaces are self-contained
Skipping tablespace USERS
Skipping tablespace TESTPDB:USERS
RMAN-05529: warning: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

contents of Memory Script:
{
   sql clone 'alter database flashback off';
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/dupjy/system.317.962209603";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/dupjy/sysaux.298.962209605";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/dupjy/system.256.962209675";
   set newname for datafile  6 to 
 "/u01/app/oracle/oradata/dupjy/sysaux.270.962209675";
   set newname for datafile  8 to 
 "/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675";
   set newname for datafile  9 to 
 "/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605";
   set newname for datafile  10 to 
 "/u01/app/oracle/oradata/dupjy/system.271.962209649";
   set newname for datafile  11 to 
 "/u01/app/oracle/oradata/dupjy/sysaux.316.962209649";
   set newname for datafile  12 to 
 "/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649";
   set newname for datafile  13 to 
 "/u01/app/oracle/oradata/dupjy/undo_2.268.962209649";
   set newname for datafile  14 to 
 "/u01/app/oracle/oradata/dupjy/users.278.962209649";
   set newname for datafile  15 to 
 "/u01/app/oracle/oradata/dupjy/test.275.962210609";
   set newname for datafile  16 to 
 "/u01/app/oracle/oradata/dupjy/system.260.962469409";
   set newname for datafile  17 to 
 "/u01/app/oracle/oradata/dupjy/sysaux.259.962469409";
   set newname for datafile  18 to 
 "/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409";
   set newname for datafile  19 to 
 "/u01/app/oracle/oradata/dupjy/undo_2.266.962469409";
   set newname for datafile  21 to 
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   restore
   from  nonsparse   from service 
 'jy'   using compressed backupset
   clone database
   skip forever tablespace  "USERS",
 "TESTPDB":"USERS"   ;
   sql 'alter system archive log current';
}
executing Memory Script

sql statement: alter database flashback off

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 23-JAN-18
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/dupjy/system.317.962209603
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/dupjy/sysaux.298.962209605
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:36
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/dupjy/system.256.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/dupjy/sysaux.270.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:26
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/dupjy/system.271.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/dupjy/sysaux.316.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00013 to /u01/app/oracle/oradata/dupjy/undo_2.268.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00014 to /u01/app/oracle/oradata/dupjy/users.278.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:26
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00015 to /u01/app/oracle/oradata/dupjy/test.275.962210609
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00016 to /u01/app/oracle/oradata/dupjy/system.260.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00017 to /u01/app/oracle/oradata/dupjy/sysaux.259.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00018 to /u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00019 to /u01/app/oracle/oradata/dupjy/undo_2.266.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00021 to /u01/app/oracle/oradata/dupjy/test.269.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 23-JAN-18

sql statement: alter system archive log current
current log archived

contents of Memory Script:
{
   restore clone force from service  'jy' using compressed backupset
   archivelog from scn  15749326;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 23-JAN-18
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=172
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=173
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=150
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=151
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=152
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 23-JAN-18

datafile 1 switched to datafile copy
input datafile copy RECID=22 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/system.317.962209603
datafile 3 switched to datafile copy
input datafile copy RECID=23 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=24 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 5 switched to datafile copy
input datafile copy RECID=25 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/system.256.962209675
datafile 6 switched to datafile copy
input datafile copy RECID=26 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 8 switched to datafile copy
input datafile copy RECID=27 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=28 STAMP=966187520 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 10 switched to datafile copy
input datafile copy RECID=29 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/system.271.962209649
datafile 11 switched to datafile copy
input datafile copy RECID=30 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=31 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=32 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=33 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=34 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609
datafile 16 switched to datafile copy
input datafile copy RECID=35 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/system.260.962469409
datafile 17 switched to datafile copy
input datafile copy RECID=36 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=37 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=38 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=39 STAMP=966187521 file name=/u01/app/oracle/oradata/dupjy/test.269.962469409

contents of Memory Script:
{
   set until scn  15754741;
   recover
   clone database
   skip forever tablespace  "USERS",
 "TESTPDB":"USERS"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 23-JAN-18
using channel ORA_AUX_DISK_1

Executing: alter database datafile 7 offline drop
Executing: alter database datafile 20 offline drop
starting media recovery

archived log for thread 1 with sequence 172 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_172_961976319.dbf
archived log for thread 1 with sequence 173 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_173_961976319.dbf
archived log for thread 2 with sequence 151 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_151_961976319.dbf
archived log for thread 2 with sequence 152 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_152_961976319.dbf
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_172_961976319.dbf thread=1 sequence=172
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_151_961976319.dbf thread=2 sequence=151
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_173_961976319.dbf thread=1 sequence=173
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_152_961976319.dbf thread=2 sequence=152
media recovery complete, elapsed time: 00:00:09
Finished recover at 23-JAN-18
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''DUPJY'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
}
executing Memory Script

sql statement: alter system set  db_name =  ''DUPJY'' comment= ''Reset to original value by RMAN'' scope=spfile
starting full resync of recovery catalog
full resync complete

sql statement: alter system reset  db_unique_name scope=spfile
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPJY" RESETLOGS ARCHIVELOG 
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/u01/app/oracle/oradata/dupjy/group_1.261.961976319' ) SIZE 200 M  REUSE,
  GROUP   2 ( '/u01/app/oracle/oradata/dupjy/group_2.302.961976321' ) SIZE 200 M  REUSE
 DATAFILE
  '/u01/app/oracle/oradata/dupjy/system.317.962209603',
  '/u01/app/oracle/oradata/dupjy/system.256.962209675',
  '/u01/app/oracle/oradata/dupjy/system.271.962209649',
  '/u01/app/oracle/oradata/dupjy/system.260.962469409'
 CHARACTER SET ZHS16GBK

sql statement: ALTER DATABASE ADD LOGFILE 
  
  INSTANCE 'i2' 
  GROUP   3 ( '/u01/app/oracle/oradata/dupjy/group_3.263.961976697' ) SIZE 200 M  REUSE,
  GROUP   4 ( '/u01/app/oracle/oradata/dupjy/group_4.262.961976705' ) SIZE 200 M  REUSE

contents of Memory Script:
{
   set newname for tempfile  1 to 
 "+DATA";
   set newname for tempfile  2 to 
 "+DATA";
   set newname for tempfile  3 to 
 "+DATA";
   set newname for tempfile  4 to 
 "+DATA";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/oracle/oradata/dupjy/sysaux.298.962209605", 
 "/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605", 
 "/u01/app/oracle/oradata/dupjy/sysaux.270.962209675", 
 "/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675", 
 "/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605", 
 "/u01/app/oracle/oradata/dupjy/sysaux.316.962209649", 
 "/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649", 
 "/u01/app/oracle/oradata/dupjy/undo_2.268.962209649", 
 "/u01/app/oracle/oradata/dupjy/users.278.962209649", 
 "/u01/app/oracle/oradata/dupjy/test.275.962210609", 
 "/u01/app/oracle/oradata/dupjy/sysaux.259.962469409", 
 "/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409", 
 "/u01/app/oracle/oradata/dupjy/undo_2.266.962469409", 
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to +DATA in control file
renamed tempfile 2 to +DATA in control file
renamed tempfile 3 to +DATA in control file
renamed tempfile 4 to +DATA in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605 RECID=1 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605 RECID=2 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675 RECID=3 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675 RECID=4 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605 RECID=5 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649 RECID=6 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649 RECID=7 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649 RECID=8 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.278.962209649 RECID=9 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.275.962210609 RECID=10 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409 RECID=11 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409 RECID=12 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409 RECID=13 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.269.962469409 RECID=14 STAMP=966187586

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 8 switched to datafile copy
input datafile copy RECID=4 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=5 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 11 switched to datafile copy
input datafile copy RECID=6 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=7 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=8 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=9 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=10 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609
datafile 17 switched to datafile copy
input datafile copy RECID=11 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=12 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=13 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=14 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/test.269.962469409

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened

contents of Memory Script:
{
   sql clone "alter pluggable database all open";
}
executing Memory Script

sql statement: alter pluggable database all open
Dropping offline and skipped tablespaces
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Finished Duplicate Db at 23-JAN-18

12.检查源数据库中的PDB(jypdb)是否被成功复制到目标数据库dupjy中

[oracle@shard1 dupjy]$ export ORACLE_SID=dupjy
[oracle@shard1 dupjy]$ rman target/

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Jan 23 17:34:24 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DUPJY (DBID=1349553641)

RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name DUPJY

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    840      SYSTEM               YES     /u01/app/oracle/oradata/dupjy/system.317.962209603
3    2340     SYSAUX               NO      /u01/app/oracle/oradata/dupjy/sysaux.298.962209605
4    1015     UNDOTBS1             YES     /u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
5    250      PDB$SEED:SYSTEM      NO      /u01/app/oracle/oradata/dupjy/system.256.962209675
6    340      PDB$SEED:SYSAUX      NO      /u01/app/oracle/oradata/dupjy/sysaux.270.962209675
8    100      PDB$SEED:UNDOTBS1    NO      /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
9    1350     UNDOTBS2             YES     /u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
10   270      JYPDB:SYSTEM         YES     /u01/app/oracle/oradata/dupjy/system.271.962209649
11   590      JYPDB:SYSAUX         NO      /u01/app/oracle/oradata/dupjy/sysaux.316.962209649
12   205      JYPDB:UNDOTBS1       YES     /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
13   310      JYPDB:UNDO_2         YES     /u01/app/oracle/oradata/dupjy/undo_2.268.962209649
14   1267     JYPDB:USERS          NO      /u01/app/oracle/oradata/dupjy/users.278.962209649
15   100      JYPDB:TEST           NO      /u01/app/oracle/oradata/dupjy/test.275.962210609
16   260      TESTPDB:SYSTEM       YES     /u01/app/oracle/oradata/dupjy/system.260.962469409
17   550      TESTPDB:SYSAUX       NO      /u01/app/oracle/oradata/dupjy/sysaux.259.962469409
18   245      TESTPDB:UNDOTBS1     YES     /u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
19   100      TESTPDB:UNDO_2       YES     /u01/app/oracle/oradata/dupjy/undo_2.266.962469409
21   100      TESTPDB:TEST         NO      /u01/app/oracle/oradata/dupjy/test.269.962469409

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    144      TEMP                 32767       +DATA
2    64       PDB$SEED:TEMP        32767       +DATA
3    137      JYPDB:TEMP           32767       +DATA
4    135      TESTPDB:TEMP         32767       +DATA

SQL> alter session set container=testpdb;

Session altered.

SQL> select count(*) from jy.t1;

  COUNT(*)
----------
        39

SQL> select table_name,tablespace_name from dba_tables where owner='JY';

TABLE_NAME                                                                                                                       TABLESPACE_NAME
-------------------------------------------------------------------------------------------------------------------------------- ------------------------------
T1    

从上面的输出结果可以看到,虽然只复制jypdb数据库与testpdb数据库中的test表空间,但其实还为了让testpdb的test表空间可以使用还是复制了testpdb中的system,sysaux,undo,temp表空间,到此复制RAC CDB数据库中PDB的表空间到单实例CDB数据库就操作完成。

Proudly powered by WordPress | Indrajeet by Sus Hill.