您好,登錄后才能下訂單哦!
小編給大家分享一下如何使用RMAN對PDB中的表空間或數據文件執行完全恢復,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
因為不同PDB中的表空間可以有相同的名字,為了消除這種混淆你必須直接連接到PDB來恢復PDB的表空間。相反,因為數據文件號與路徑名是跨CDB唯一標識的,所以可以連接到root容器或PDB來恢復PDB的數據文件。如果連接到CDB的root容器,那么可以使用單個命令來恢復多個PDB中的數據文件。如果連接到PDB,只能恢復PDB中的數據文件。
還原與恢復PDB中的non-SYSTEM表空間
1.啟動RMAN并連接到目標數據庫
[oracle@jytest1 ~]$ rman target sys/xxxxx@jypdb Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 11 17:59:27 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: JY:JYPDB (DBID=4203494064)
2.如果數據庫的狀態為open,那么將要恢復的表空間置于脫機狀態
SQL> alter tablespace test offline immediate; Tablespace altered.
3.使用show命令來查看是否配置了預先設置的通道。如果需要的設置類型與通道被配置,那么不需要執行任何操作。否則可以使用configure命令來配置自動通道,或都使用包含allocate channel命令的run塊
RMAN> show all; RMAN configuration parameters for database with db_unique_name JY are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+test/rman_backup/%F'; CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+test/jy/snapcf_jy.f';
4.還原與恢復表空間
.如果將數據文件還原到原始位置,那么執行restore tablespace與recover tablespace命令
.如果將數據文件還原到新目錄,那么在run命令塊中執行restore tablespace與recover tablespace命令,并且使用set newname命令來重命名數據文件。
RMAN> restore tablespace 'TEST'; Starting restore at 11-DEC-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00015 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609 channel ORA_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_20171211_0osls830_1_1 channel ORA_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_20171211_0osls830_1_1 tag=TAG20171211T164446 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 Finished restore at 11-DEC-17 RMAN> recover tablespace 'TEST'; Starting recover at 11-DEC-17 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 11-DEC-17
5.檢查輸出結果查看是否恢復成功。如果恢復成功將表空間設置為聯機狀態
RMAN> alter tablespace test online; Statement processed
還原與恢復PDB中的SYSTEM表空間
1.啟動RMAN并使用有sysdba或sysbackup權限的公共用戶連接到root容器。
[oracle@jytest1 ~]$ rman target/ catalog rco/abcd@jypdb_173 Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 11 18:11:55 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: JY (DBID=979425723) connected to recovery catalog database
2.關閉CDB并重啟到mount狀態
SQL> conn / as sysdba Connected. SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 6442450944 bytes Fixed Size 8807168 bytes Variable Size 1895828736 bytes Database Buffers 4529848320 bytes Redo Buffers 7966720 bytes Database mounted.
3.還原與恢復PDB中SYSTEM表空間的數據文件
[oracle@jytest1 ~]$ rman target/ catalog rco/abcd@jypdb_173 Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 11 18:20:30 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: JY (DBID=979425723, not open) connected to recovery catalog database RMAN> report schema; starting full resync of recovery catalog full resync complete Report of database schema for database with db_unique_name JY List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 830 SYSTEM YES +DATA/JY/DATAFILE/system.317.962209603 3 1230 SYSAUX NO +DATA/JY/DATAFILE/sysaux.298.962209605 4 75 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 50 UNDOTBS2 YES +DATA/JY/DATAFILE/undotbs2.312.962209605 10 260 JYPDB:SYSTEM YES +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649 11 460 JYPDB:SYSAUX NO +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649 12 100 JYPDB:UNDOTBS1 YES +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649 13 100 JYPDB:UNDO_2 YES +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649 14 5 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 460 TESTPDB:SYSAUX NO +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409 18 100 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 142 TEMP 32767 +DATA/JY/TEMPFILE/temp.299.961976339 2 64 PDB$SEED:TEMP 32767 +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/TEMPFILE/temp.297.962209865 3 135 JYPDB:TEMP 32767 +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/TEMPFILE/temp.276.962210519 4 135 TESTPDB:TEMP 32767 +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.962469435 RMAN> restore tablespace 'JYPDB:SYSTEM'; Starting restore at 11-DEC-17 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=10 instance=jy1 device type=DISK RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 12/11/2017 18:21:09 RMAN-06004: ORACLE error from recovery catalog database: RMAN-20202: Tablespace not found in the recovery catalog RMAN-06019: could not translate tablespace name "JYPDB:SYSTEM"
這里在還原SYSTEM表空間時使用表空間名時會報錯,如是使用restore datafile與recover datafile方法來還原與恢復SYSTEM表空間
RMAN> restore datafile 10; Starting restore at 11-DEC-17 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649 channel ORA_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_20171211_0osls830_1_1 channel ORA_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_20171211_0osls830_1_1 tag=TAG20171211T164446 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 Finished restore at 11-DEC-17 RMAN> recover datafile 10; Starting recover at 11-DEC-17 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 11-DEC-17
4.打開CDB中的所有PDB
RMAN> alter database open; Statement processed starting full resync of recovery catalog full resync complete RMAN> alter pluggable database all open read write; Statement processed starting full resync of recovery catalog full resync complete
看完了這篇文章,相信你對“如何使用RMAN對PDB中的表空間或數據文件執行完全恢復”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。