怎么将Linux上的PDB数据库传输到windows的CDB数据库
本篇内容主要讲解"怎么将Linux上的PDB数据库传输到windows的CDB数据库",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"怎么将Linux上的PDB数据库传输到windows的CDB数据库"吧!
为了将整个PDB传输到不同的平台,源平台与目标平台必须使用相同的字节序。compatible参数在源CDB数据库与目标CDB数据库中必须设置为12.1或更高版本。
下面的例子将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(jypdb,testpdb)设置为只读状态
SQL> alter pluggable database all close immediate;Pluggable database altered.SQL> set long 200SQL> set linesize 200SQL> select name,open_mode from v$pdbs;NAME OPEN_MODE-------------------------------------------------------------------------------------------------------------------------------- ----------PDB$SEED READ ONLYJYPDB MOUNTEDTESTPDB MOUNTED
4.备份要传输的PDB数据库,可以使用以下一种方法来跨平台传输PDB
4.1使用RMAN连接到CDB的root容器,并使用backup for transport ... pluggable database或者backup to platform ... 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-18using channel ORA_DISK_1running UNPLUG on the specified pluggable database: JYPDBUNPLUG file path : /ora_backup/tpdbs/metadata_jypdb.xmlchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00014 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649input datafile file number=00011 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649input datafile file number=00012 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649input datafile file number=00013 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649input datafile file number=00010 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649input datafile file number=00015 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609input datafile file number=00022 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353input datafile file number=00023 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783channel ORA_DISK_1: starting piece 1 at 11-FEB-18channel ORA_DISK_1: finished piece 1 at 11-FEB-18piece handle=/ora_backup/tpdbs/pdb_8csqvqc5_1_1 tag=TAG20180211T173748 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:56Finished backup at 11-FEB-18starting full resync of recovery catalogfull resync completeRMAN> 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-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=00017 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409input datafile file number=00018 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409input datafile file number=00016 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409input datafile file number=00019 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409input datafile file number=00021 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409input datafile file number=00020 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409channel ORA_DISK_1: starting piece 1 at 11-FEB-18channel ORA_DISK_1: finished piece 1 at 11-FEB-18piece handle=/ora_backup/tpdbs/pdb_8dsqvqpj_1_1 tag=TAG20180211T174458 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:35Finished backup at 11-FEB-18starting full resync of recovery catalogfull resync complete[oracle@jytest1 tpdbs]$ ls -lrttotal 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 完成了 restoreRMAN> 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 200SQL> set linesize 200SQL> select name,open_mode from v$pdbs;NAME OPEN_MODE-------------------------------------------------------------------------------------------------------------------------------- ----------PDB$SEED READ ONLYJYPDB MOUNTEDTESTPDB MOUNTEDSQL> alter pluggable database all open;插接式数据库已变更。SQL> select name,open_mode from v$pdbs;NAME OPEN_MODE-------------------------------------------------------------------------------------------------------------------------------- ----------PDB$SEED READ ONLYJYPDB READ WRITETESTPDB READ WRITE
9.查询tts.t1与cs.t2表中的数据来验证跨平台传输PDB是否操作成功
SQL> select count(*) from tts.t1; COUNT(*)---------- 90SQL> select count(*) from cs.t2; COUNT(*)---------- 92
到此,相信大家对"怎么将Linux上的PDB数据库传输到windows的CDB数据库"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!