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 compatibleNAME TYPE VALUE------------------------------------ ----------- ------------------------------compatible string 12.2.0noncdb_compatible boolean FALSE
目标数据库
SQL> show parameter compatibleNAME TYPE VALUE------------------------------------ ----------- ------------------------------compatible string 12.2.0noncdb_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-18starting full resync of recovery catalogfull resync completeallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=1525 instance=jy1 device type=DISKchannel ORA_DISK_1: starting incremental level 0 datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00047 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409input datafile file number=00048 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409input datafile file number=00046 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409input datafile file number=00049 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409input datafile file number=00051 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409input datafile file number=00050 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409channel ORA_DISK_1: starting piece 1 at 12-FEB-18channel ORA_DISK_1: finished piece 1 at 12-FEB-18piece handle=/ora_backup/tpdbs/testpdb_level0.bck tag=TAG20180212T001250 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:35Finished backup at 12-FEB-18[oracle@jytest1 tpdbs]$ ls -lrttotal 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 ONLYJYPDB READ WRITETESTPDB 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-18starting full resync of recovery catalogfull resync completeusing channel ORA_DISK_1running UNPLUG on the specified pluggable database: TESTPDBUNPLUG file path : /ora_backup/tpdbs/metadata_testpdb.xmlchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00047 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409input datafile file number=00048 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409input datafile file number=00046 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409input datafile file number=00049 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409input datafile file number=00051 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409input datafile file number=00050 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409channel ORA_DISK_1: starting piece 1 at 12-FEB-18channel ORA_DISK_1: finished piece 1 at 12-FEB-18piece handle=/ora_backup/tpdbs/testpdb_level1_con.bck tag=TAG20180212T002650 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:15Finished backup at 12-FEB-18starting full resync of recovery catalogfull 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 插入文件 51RMAN-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 ONLYJYPDB READ WRITETESTPDB MOUNTEDSQL> alter pluggable database testpdb open;插接式数据库已变更。SQL> select name,open_mode from v$pdbs;NAME OPEN_MODE-------------------------------------------------------------------------------------------------------------------------------- ----------PDB$SEED READ ONLYJYPDB READ WRITETESTPDB READ WRITE
12.查询tts.t1与cs.t2表中的数据来验证跨平台传输PDB是否操作成功
SQL> select count(*) from tts.t1; COUNT(*)---------- 90SQL> select count(*) from cs.t2; COUNT(*)---------- 92
到此,跨平台传输PDB就完成了。