溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么將Linux上的PDB數(shù)據(jù)庫(kù)傳輸?shù)絯indows的CDB數(shù)據(jù)庫(kù)

發(fā)布時(shí)間:2021-12-21 17:21:24 來源:億速云 閱讀:176 作者:iii 欄目:關(guān)系型數(shù)據(jù)庫(kù)

本篇內(nèi)容主要講解“怎么將Linux上的PDB數(shù)據(jù)庫(kù)傳輸?shù)絯indows的CDB數(shù)據(jù)庫(kù)”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“怎么將Linux上的PDB數(shù)據(jù)庫(kù)傳輸?shù)絯indows的CDB數(shù)據(jù)庫(kù)”吧!

為了將整個(gè)PDB傳輸?shù)讲煌钠脚_(tái),源平臺(tái)與目標(biāo)平臺(tái)必須使用相同的字節(jié)序。compatible參數(shù)在源CDB數(shù)據(jù)庫(kù)與目標(biāo)CDB數(shù)據(jù)庫(kù)中必須設(shè)置為12.1或更高版本。

下面的例子將Linux平臺(tái)上的RAC CDB中的PDB數(shù)據(jù)庫(kù)(jypdb與testpdb)傳輸?shù)絯indows平臺(tái)上的單實(shí)例CDB數(shù)據(jù)庫(kù)中。 執(zhí)行跨平臺(tái)傳輸?shù)牟僮魅缦?
1.檢查源數(shù)據(jù)庫(kù)與目標(biāo)數(shù)據(jù)庫(kù)的compatible參數(shù)是否設(shè)置為12.0.0或更高版本
源數(shù)據(jù)庫(kù)

SQL> show parameter compatible

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

目標(biāo)數(shù)據(jù)庫(kù)

SQL> show parameter compatible

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

2.檢查源平臺(tái)與目標(biāo)平臺(tái)的字節(jié)序
源平臺(tái)

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

目標(biāo)平臺(tái)

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.將要被傳輸?shù)膒db(jypdb,testpdb)設(shè)置為只讀狀態(tài)

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.備份要傳輸?shù)腜DB數(shù)據(jù)庫(kù),可以使用以下一種方法來跨平臺(tái)傳輸PDB
4.1使用RMAN連接到CDB的root容器,并使用backup for transport ... pluggable database或者backup to platform ... pluggable database命令來為PDB創(chuàng)建跨平臺(tái)備份。

4.2使用RMAN連接到PDB,并使用backup for transport或backup to platform命令來為PDB創(chuàng)建跨平臺(tái)備份。

因?yàn)槲疫@里要傳輸兩個(gè)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.將在源平臺(tái)上使用rman backup命令生成的備份集與備份的控制文件傳輸?shù)侥繕?biāo)平臺(tái)的D:\app\oracle\oradata\pdbs目錄中

6.將PDB(jypdb,testpdb)還原到目標(biāo)數(shù)據(jù)庫(kù)

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 開始
使用目標(biāo)數(shù)據(jù)庫(kù)控制文件替代恢復(fù)目錄
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=1522 設(shè)備類型=DISK

通道 ORA_DISK_1: 正在開始還原數(shù)據(jù)文件備份集
通道 ORA_DISK_1: 正在指定從備份集還原的數(shù)據(jù)文件
通道 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: 還原完成, 用時(shí): 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 開始
使用目標(biāo)數(shù)據(jù)庫(kù)控制文件替代恢復(fù)目錄
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=1522 設(shè)備類型=DISK

通道 ORA_DISK_1: 正在開始還原數(shù)據(jù)文件備份集
通道 ORA_DISK_1: 正在指定從備份集還原的數(shù)據(jù)文件
通道 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: 還原完成, 用時(shí): 00:00:26
在 11-2月 -18 完成了 restore

7.在目標(biāo)主機(jī)上修改metadata_jypdb.xml與metadata_testpdb.xml文件將數(shù)據(jù)文件路徑修改為還原后數(shù)據(jù)文件所在路徑

8.將傳輸過來的PDB(jypdb,testpdb)插入CDB

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

插接式數(shù)據(jù)庫(kù)已創(chuàng)建。


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

插接式數(shù)據(jù)庫(kù)已創(chuàng)建。

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;

插接式數(shù)據(jù)庫(kù)已變更。

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表中的數(shù)據(jù)來驗(yàn)證跨平臺(tái)傳輸PDB是否操作成功

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

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

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

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

到此,相信大家對(duì)“怎么將Linux上的PDB數(shù)據(jù)庫(kù)傳輸?shù)絯indows的CDB數(shù)據(jù)庫(kù)”有了更深的了解,不妨來實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI