可以使用不一致与一致备份来传输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就完成了。