RMAN備份介質的移動與再恢復測試 [ catalog start with ‘dir’ ]
阿新 • • 發佈:2018-11-05
https://www.cnblogs.com/jackhub/p/3331673.html 由於目前生產環境中沒有集中的備份條件,所以備份要考慮到可以移動再恢復性.這裡要測試的就是,RMAN全部備份的介質,我關注是否可以定期的移動到其他儲存介質中,到要恢復的時候再拿過來.
1. 備份現有資料庫和控制檔案.
RMAN> backup database include current controlfile;
2. 移走備份集,到另外的目錄/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp
3. 檢視過期的備份介質.
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 1 15-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_15/o1_mf_1_2_93cc8thy_.arc
Archive Log 2 15-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_15/o1_mf_1_3_93ck0mxm_.arc
Archive Log 3 16-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_16/o1_mf_1_4_93ftwxqj_.arc
Archive Log 4 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_5_93o9xt7k_.arc
Backup Set 1 19-SEP-13
Backup Piece 1 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp
Archive Log 5 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_6_93qgls17_.arc
Backup Set 2 19-SEP-13
Backup Piece 2 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_ncsnf_TAG20130919T011640_93odvkkc_.bkp
Archive Log 6 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_7_93qh7sqx_.arc
Archive Log 7 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_8_93qs3s52_.arc
Archive Log 8 20-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_20/o1_mf_1_1_93qzp568_.arc
Backup Set 3 19-SEP-13
Backup Piece 3 19-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_19/o1_mf_s_826585286_93qs5xdg_.bkp
Archive Log 15 20-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_20/o1_mf_1_1_93t8b5jm_.arc
Backup Set 4 20-SEP-13
Backup Piece 4 20-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826666416_93t8gcfz_.bkp
Backup Set 6 21-SEP-13
Backup Piece 6 21-SEP-13 /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_21/o1_mf_ncnnf_TAG20130920T235853_93tkd6kk_.bkp
4. 刪除過期的備份介質.
RMAN> delete obsolete(nopormt指定無需確認立即刪除)
5. 由於我們已經講備份的介質移走了,但是RMAN的備份記錄中依然存在,清除這些資訊。
RMAN> crosscheck backup;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_20/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp RECID=5 STAMP=826675137
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_21/o1_mf_s_826675611_93tkdfgw_.bkp RECID=7 STAMP=826675613
Crosschecked 2 objects
6. 刪除過期的備份資訊。
RMAN> delete expired backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
5 5 1 1 EXPIRED DISK /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_20/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_20/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp RECID=5 STAMP=826675137
Deleted 1 EXPIRED objects
7. 關閉資料庫刪除控制檔案和資料檔案。
8. 啟動資料庫到nomount下,恢復控制檔案。
RMAN> startup nomount;
Oracle instance started
.
.
RMAN> restore controlfile from autobackup;
Starting restore at 21-SEP-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
recovery area destination: /u01/app/oracle/flash_recovery_area/august
database name (or database unique name) used for search: AUGUST
channel ORA_DISK_1: AUTOBACKUP /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_21/o1_mf_s_826675611_93tkdfgw_.bkp found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20130921
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_21/o1_mf_s_826675611_93tkdfgw_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/august/august/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/august/august/control02.ctl
Finished restore at 21-SEP-13
9. 改變資料庫到mount狀態,從備份集中恢復資料庫。
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> restore database from '/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp';
Starting restore at 21-SEP-13
Starting implicit crosscheck backup at 21-SEP-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 21-SEP-13
Starting implicit crosscheck copy at 21-SEP-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 21-SEP-13
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_1_93tlk8cg_.arc
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_4_93tlvr76_.arc
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_2_93tlkfwz_.arc
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_3_93tlkqgj_.arc
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_20/o1_mf_s_826618674_93rss9os_.bkp
File Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/autobackup/2013_09_21/o1_mf_s_826675611_93tkdfgw_.bkp
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/21/2013 00:46:57
RMAN-06509: only SPFILE or control file can be restored from AUTOBACKUP
--看提示是說oracle不能這樣恢復資料庫。
那如何使用這個備份集恢復呢?
10. 需要先將備份集catalog到RMAN備份記錄中去。
RMAN> catalog start with '/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp';
searching for all files that match the pattern /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp
no files found to be unknown to the database
--檢視現有的備份資訊,此備份集已經能夠被識別了。
RMAN> list backup of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 953.57M DISK 00:07:36 21-SEP-13
BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20130920T235853
Piece Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp
List of Datafiles in backup set 5
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 859599 20-SEP-13 /u01/app/oracle/oradata/august/august/system01.dbf
2 Full 859599 20-SEP-13 /u01/app/oracle/oradata/august/august/sysaux01.dbf
3 Full 859599 20-SEP-13 /u01/app/oracle/oradata/august/august/undotbs01.dbf
4 Full 859599 20-SEP-13 /u01/app/oracle/oradata/august/august/users01.dbf
11. 將備份集資訊編目後,就可以使用restore開始恢復資料庫了。
RMAN> restore database;
Starting restore at 21-SEP-13
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 00001 to /u01/app/oracle/oradata/august/august/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/august/august/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/august/august/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/august/august/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/o1_mf_nnndf_TAG20130920T235853_93tjxkb9_.bkp tag=TAG20130920T235853
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:05:36
Finished restore at 21-SEP-13
12. 進行介質恢復。
RMAN> recover database;
Starting recover at 21-SEP-13
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_1_93tlk8cg_.arc
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_2_93tlkfwz_.arc
archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_3_93tlkqgj_.arc
archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_4_93tlvr76_.arc
archived log for thread 1 with sequence 5 is already on disk as file /u01/app/oracle/oradata/august/august/redo02.log
archived log file name=/u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_1_93tlk8cg_.arc thread=1 sequence=1
archived log file name=/u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_2_93tlkfwz_.arc thread=1 sequence=2
archived log file name=/u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_3_93tlkqgj_.arc thread=1 sequence=3
archived log file name=/u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_21/o1_mf_1_4_93tlvr76_.arc thread=1 sequence=4
archived log file name=/u01/app/oracle/oradata/august/august/redo02.log thread=1 sequence=5
media recovery complete, elapsed time: 00:00:24
Finished recover at 21-SEP-13
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 09/21/2013 01:45:51
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
RMAN> alter database open noresetlogs;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "resetlogs, ;"
RMAN-01008: the bad identifier was: noresetlogs
RMAN-01007: at line 1 column 21 file: standard input
RMAN> alter database open resetlogs;
database opened
--之前講過,在使用了備份的控制檔案進行恢復之後,是需要用resetlogs方式開啟的。
所以總結來說,利用備份集的移動是沒有問題的,恢復時只需要重新編目到備份集資訊中即可。 [catalog start with ‘dir’]