有整庫備份的情況rman恢復全庫
說明
在利用RMAN備份了整個資料庫後,我們恢復資料庫到備份的狀態,利用之前的全備恢復,需要以下一系列操作。
資料庫恢復
1. 備份全庫
RMAN> list backup;
using target database control file instead of recovery catalog
RMAN> list backup;
RMAN> backup database;
Starting backup at 04-MAR-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=529 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oracle/u01/app/oracle/oradata/orcl/system01.dbf input datafile fno=00003 name=/oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf input datafile fno=00005 name=/oracle/u01/app/oracle/oradata/orcl/admin01.dbf input datafile fno=00002 name=/oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf input datafile fno=00004 name=/oracle/u01/app/oracle/oradata/orcl/users01.dbf input datafile fno=00006 name=/oracle/u01/app/oracle/oradata/orcl/users02.dbf channel ORA_DISK_1: starting piece 1 at 04-MAR-13 channel ORA_DISK_1: finished piece 1 at 04-MAR-13 piece handle=/oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp tag=TAG20130304T165311 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 Finished backup at 04-MAR-13
Starting Control File and SPFILE Autobackup at 04-MAR-13 piece handle=/oracle/u01/app/oracle/backup/c-1324770912-20130304-0d comment=NONE Finished Control File and SPFILE Autobackup at 04-MAR-13 |
備份過程如果沒有設定備份路徑會自動備份到rman預設路徑,通過show all,也可以檢查引數更改備份路徑
2. 檢查備份
RMAN> list backup;
List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 140 Full 963.54M DISK 00:00:42 04-MAR-13 BP Key: 144 Status: AVAILABLE Compressed: NO Tag: TAG20130304T165311 Piece Name: /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp List of Datafiles in backup set 140 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/system01.dbf 2 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf 3 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf 4 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/users01.dbf 5 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/admin01.dbf 6 Full 5925951 04-MAR-13 /oracle/u01/app/oracle/oradata/orcl/users02.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 141 Full 7.52M DISK 00:00:00 04-MAR-13 BP Key: 145 Status: AVAILABLE Compressed: NO Tag: TAG20130304T165357 Piece Name: /oracle/u01/app/oracle/backup/c-1324770912-20130304-0d Control File Included: Ckp SCN: 5925970 Ckp time: 04-MAR-13 SPFILE Included: Modification time: 04-MAR-13 |
通過檢查,已經備份成功,備份集號為141
3. 停庫
SQL> shutdown abort; ORACLE instance shut down. |
此時不用一致性停庫也行,因為模擬實驗,將要刪除整個資料庫檔案。
4. 刪除原庫
[oracle@dev206 oracle]$ rm -rf /oracle/u01/app/oracle/oradata/orcl/* |
5. 測試啟動
SQL> startup ORA-32004: obsolete and/or deprecated parameter(s) specified ORACLE instance started.
Total System Global Area 1224736768 bytes Fixed Size 2020384 bytes Variable Size 352324576 bytes Database Buffers 855638016 bytes Redo Buffers 14753792 bytes ORA-00205: error in identifying control file, check alert log for more info |
此時資料庫已經不能啟動,在啟動到nomount過程中報205錯誤,找不到控制檔案。
6. 進入RMAN恢復控制檔案
[oracle@dev206 ~]$ rman target / RMAN> restore controlfile from '/oracle/u01/app/oracle/backup/c-1324770912-20130304-0d';
Starting restore at 04-MAR-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=540 devtype=DISK
channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 output filename=/oracle/u01/app/oracle/oradata/orcl/control01.ctl output filename=/oracle/u01/app/oracle/oradata/orcl/control02.ctl output filename=/oracle/u01/app/oracle/oradata/orcl/control03.ctl Finished restore at 04-MAR-13 |
檢驗/oracle/u01/app/oracle/oradata/orcl路徑下已經恢復控制檔案。
7. 此時資料庫可以mount
RMAN> alter database mount;
database mounted released channel: ORA_DISK_1 |
8. 恢復資料檔案
RMAN> restore database;
Starting restore at 04-MAR-13 Starting implicit crosscheck backup at 04-MAR-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=540 devtype=DISK Crosschecked 1 objects Finished implicit crosscheck backup at 04-MAR-13
Starting implicit crosscheck copy at 04-MAR-13 using channel ORA_DISK_1 Crosschecked 4 objects Finished implicit crosscheck copy at 04-MAR-13
searching for all files in the recovery area cataloging files... cataloging done
List of Cataloged Files ======================= File Name: /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_ncnnf_TAG20130304T143106_8m8hxc3s_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /oracle/u01/app/oracle/oradata/orcl/system01.dbf restoring datafile 00002 to /oracle/u01/app/oracle/oradata/orcl/undotbs01.dbf restoring datafile 00003 to /oracle/u01/app/oracle/oradata/orcl/sysaux01.dbf restoring datafile 00004 to /oracle/u01/app/oracle/oradata/orcl/users01.dbf restoring datafile 00005 to /oracle/u01/app/oracle/oradata/orcl/admin01.dbf restoring datafile 00006 to /oracle/u01/app/oracle/oradata/orcl/users02.dbf channel ORA_DISK_1: reading from backup piece /oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/oracle/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_03_04/o1_mf_nnndf_TAG20130304T165311_8m8r7r82_.bkp tag=TAG20130304T165311 channel ORA_DISK_1: restore complete, elapsed time: 00:00:36 Finished restore at 04-MAR-13 |
檢驗/oracle/u01/app/oracle/oradata/orcl路徑下已經恢復資料檔案。
9. 開啟資料庫
RMAN> alter database open resetlogs;
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 03/04/2013 17:05:30 ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/oracle/u01/app/oracle/oradata/orcl/system01.dbf' |
因為我們只是在物理層恢復了資料檔案,還需要在邏輯上恢復資料庫。
10. 恢復資料庫
RMAN> recover database;
Starting recover at 04-MAR-13 using channel ORA_DISK_1
starting media recovery
unable to find archive log archive log thread=1 sequence=3 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 03/04/2013 17:06:34 RMAN-06054: media recovery requesting unknown log: thread 1 seq 3 lowscn 5925 |
報錯是因為找不到到日誌檔案,繼續下一步。
11. 重做日誌檔案開啟資料庫
RMAN> alter database open resetlogs;
database opened |
檢驗/oracle/u01/app/oracle/oradata/orcl路徑下已經恢復了日誌檔案
此時資料庫已經啟動完成。
12. 重啟資料庫
SQL>startup force |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26252014/viewspace-755277/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE DG從庫 Rman備份恢復Oracle
- RMAN備份恢復典型案例——資料庫卡頓資料庫
- RMAN備份恢復技巧
- rman 增量備份恢復
- RMAN備份異機恢復
- 備份與恢復:polardb資料庫備份與恢復資料庫
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- 資料庫備份恢復資料庫
- RMAN備份整庫和歸檔日誌的方法
- RMAN備份恢復效能優化優化
- RMAN備份與恢復測試
- rman備份異機恢復(原創)
- Oracle 備份恢復篇之RMAN catalogOracle
- 在DG備庫備份資料庫並恢復到一個主機上,報錯RMAN-06820資料庫
- PostgreSql資料庫的備份和恢復SQL資料庫
- RMAN備份恢復典型案例——異機恢復未知DBID
- Mysql資料庫備份及恢復MySql資料庫
- 達夢資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- 利用innobackupex備份集恢復指定庫
- 使用RMAN備份資料庫資料庫
- RMAN備份恢復典型案例——快速檢查資料庫一致性資料庫
- RMAN備份恢復典型案例——ORA-00245
- 12 使用RMAN備份和恢復檔案
- 【RMAN】在多租戶環境下的RMAN備份及恢復
- pg_dump 備份,恢復資料庫資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- 資料庫備份與恢復技術資料庫
- 利用RMAN備份重建資料庫資料庫
- 備份恢復Lesson 04.Using the RMAN Recovery Catalog
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- Linux下MySQL資料庫的備份與恢復LinuxMySql資料庫
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- PG-pg_dump備份/恢復資料庫資料庫
- MySQL-19.資料庫備份與恢復MySql資料庫
- vivo 資料庫備份恢復系統演化資料庫
- 使用Mysqldump備份和恢復MySQL資料庫MySql資料庫
- dg丟失歸檔,使用rman增量備份恢復
- 透過RMAN備份standby database成功恢復還原Database