rman還原控制檔案(一)
如果丟失或損壞所有的控制檔案就需要從備份中還原控制檔案。restore controlfile命令用來還原控制檔案。在還原控制檔案後需要對資料畝執行完全介質恢復並以resetlog選項來開啟資料庫。RMAN可以將控制檔案還原到它的預設儲存位置,也可以使用restore controlfile ... to destination來指定位置。
從已經知的控制檔案備份中還原控制檔案
SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /u01/app/oracle/oradata/test/c ontrol01.ctl, /u01/app/oracle/ oradata/test/control02.ctl, /u 01/app/oracle/oradata/test/con trol03.ctl
顯示當前可用的備份
RMAN> list backup; List of Backup Sets =================== BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 77 693.50K DISK 00:00:02 28-JAN-15 BP Key: 75 Status: AVAILABLE Compressed: YES Tag: TAG20150128T131713 Piece Name: /u02/test_df870182233_s95_s1 List of Archived Logs in backup set 77 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 13 2928236 28-JAN-15 2928830 28-JAN-15 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 78 Full 166.91M DISK 00:01:19 28-JAN-15 BP Key: 76 Status: AVAILABLE Compressed: YES Tag: TAG20150128T131716 Piece Name: /u02/test_df870182236_s96_s1 List of Datafiles in backup set 78 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 2928835 28-JAN-15 /u01/app/oracle/oradata/test/system01.dbf 2 Full 2928835 28-JAN-15 /u01/app/oracle/oradata/test/undotbs01.dbf 3 Full 2928835 28-JAN-15 /u01/app/oracle/oradata/test/sysaux01.dbf 4 Full 2928835 28-JAN-15 /u01/app/oracle/oradata/test/users01.dbf 5 Full 2928835 28-JAN-15 /u01/app/oracle/oradata/test/example01.dbf 6 Full 2928835 28-JAN-15 /u01/app/oracle/oradata/test/test01.dbf BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 79 7.50K DISK 00:00:01 28-JAN-15 BP Key: 77 Status: AVAILABLE Compressed: YES Tag: TAG20150128T131841 Piece Name: /u02/test_df870182321_s97_s1 List of Archived Logs in backup set 79 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 14 2928830 28-JAN-15 2928868 28-JAN-15 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 80 Full 9.42M DISK 00:00:02 28-JAN-15 BP Key: 78 Status: AVAILABLE Compressed: NO Tag: TAG20150128T131843 Piece Name: /u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150128-0d Control File Included: Ckp SCN: 2928874 Ckp time: 28-JAN-15 SPFILE Included: Modification time: 28-JAN-15
從上面的資訊可以看到備份集80是控制檔案與spfile檔案的備份
下面來刪除當前資料庫的所有控制檔案:
[root@oracle11g ~]# cd /u01/app/oracle/oradata/test/ [root@oracle11g test]# ls -lrt total 2213868 -rw-r----- 1 oracle oinstall 11804672 Feb 1 11:36 users01.dbf -rw-r----- 1 oracle oinstall 52436992 Feb 1 11:36 test01.dbf -rw-r----- 1 oracle oinstall 52429312 Feb 1 11:36 redo02.log -rw-r----- 1 oracle oinstall 52429312 Feb 1 11:36 redo01.log -rw-r----- 1 oracle oinstall 104865792 Feb 1 11:36 example01.dbf -rw-r----- 1 oracle oinstall 20979712 Feb 1 11:37 temp01.dbf -rw-r----- 1 oracle oinstall 838868992 Feb 1 19:05 system01.dbf -rw-r----- 1 oracle oinstall 492838912 Feb 1 19:05 undotbs01.dbf -rw-r----- 1 oracle oinstall 576724992 Feb 1 19:05 sysaux01.dbf -rw-r----- 1 oracle oinstall 52429312 Feb 1 19:10 redo03.log -rw-r----- 1 oracle oinstall 9814016 Feb 1 19:11 control03.ctl -rw-r----- 1 oracle oinstall 9814016 Feb 1 19:11 control02.ctl -rw-r----- 1 oracle oinstall 9814016 Feb 1 19:11 control01.ctl [root@oracle11g test]# rm -rf control*.ctl [root@oracle11g test]# ls -lrt total 2185068 -rw-r----- 1 oracle oinstall 52429312 Feb 1 11:36 redo02.log -rw-r----- 1 oracle oinstall 20979712 Feb 1 11:37 temp01.dbf -rw-r----- 1 oracle oinstall 52429312 Feb 1 19:13 redo03.log -rw-r----- 1 oracle oinstall 11804672 Feb 1 19:14 users01.dbf -rw-r----- 1 oracle oinstall 492838912 Feb 1 19:14 undotbs01.dbf -rw-r----- 1 oracle oinstall 52436992 Feb 1 19:14 test01.dbf -rw-r----- 1 oracle oinstall 838868992 Feb 1 19:14 system01.dbf -rw-r----- 1 oracle oinstall 576724992 Feb 1 19:14 sysaux01.dbf -rw-r----- 1 oracle oinstall 52429312 Feb 1 19:14 redo01.log -rw-r----- 1 oracle oinstall 104865792 Feb 1 19:14 example01.dbf
向測試表t2中插入一些資料庫
SQL> insert into t2 select * from dba_objects; 51319 rows created. SQL> select count(*) from t2; COUNT(*) ---------- 102560 SQL> commit; Commit complete.
這裡因為是從linux作業系統層面刪除了所有控制檔案,因為在資料庫沒有關閉的情況下檔案的控制程式碼沒有釋放所以資料庫還能執行。
人為將資料庫異常終止
[root@oracle11g test]# ps -ef | grep smon oracle 3463 1 0 22:30 ? 00:00:00 ora_smon_test root 3179 3123 0 22:45 pts/3 00:00:00 grep smon [root@oracle11g test]# kill -9 3463
啟動資料庫:
SQL> startup ORACLE instance started. Total System Global Area 327155712 bytes Fixed Size 1273516 bytes Variable Size 138412372 bytes Database Buffers 184549376 bytes Redo Buffers 2920448 bytes ORA-00205: error in identifying control file, check alert log for more info
alert日誌的內容如下:
ORA-00210: cannot open the specified control file ORA-00202: control file: '/u01/app/oracle/oradata/test/control01.ctl' ORA-27037: unable to obtain file status Linux Error: 2: No such file or directory Additional information: 3 Sun Feb 01 19:18:18 CST 2015 ORA-205 signalled during: ALTER DATABASE MOUNT...
找不到控制檔案不能將資料庫置於mount狀態.現在透過備份來還原控制檔案執行完全資料庫恢復:
RMAN> restore controlfile from '/u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150128-0d'; Starting restore at 01-FEB-15 using channel ORA_DISK_1 channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:05 output filename=/u01/app/oracle/oradata/test/control01.ctl output filename=/u01/app/oracle/oradata/test/control02.ctl output filename=/u01/app/oracle/oradata/test/control03.ctl Finished restore at 01-FEB-15 RMAN> sql 'alter database mount'; sql statement: alter database mount released channel: ORA_DISK_1 SQL> select status from v$instance; STATUS ------------------------ MOUNTED
執行完全恢復
RMAN> recover database; Starting recover at 01-FEB-15 Starting implicit crosscheck backup at 01-FEB-15 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=155 devtype=DISK Crosschecked 3 objects Finished implicit crosscheck backup at 01-FEB-15 Starting implicit crosscheck copy at 01-FEB-15 using channel ORA_DISK_1 Crosschecked 6 objects Finished implicit crosscheck copy at 01-FEB-15 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 starting media recovery archive log thread 1 sequence 17 is already on disk as file /u01/app/oracle/oradata/test/redo02.log archive log thread 1 sequence 18 is already on disk as file /u01/app/oracle/oradata/test/redo03.log archive log thread 1 sequence 19 is already on disk as file /u01/app/oracle/oradata/test/redo01.log archive log filename=/u02/1_15_870133266.dbf thread=1 sequence=15 archive log filename=/u02/1_16_870133266.dbf thread=1 sequence=16 archive log filename=/u01/app/oracle/oradata/test/redo02.log thread=1 sequence=17 archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=18 archive log filename=/u01/app/oracle/oradata/test/redo01.log thread=1 sequence=19 media recovery complete, elapsed time: 00:00:06 Finished recover at 01-FEB-15 RMAN> sql 'alter database open resetlogs'; sql statement: alter database open resetlogs SQL> select status from v$instance; STATUS ------------ OPEN SQL> select count(*) from t2; COUNT(*) ---------- 102560
表t2中的記錄與恢復之前相同,說明恢復成功。
當還原控制檔案時,控制檔案的預設位置是由引數control_files控制的。如果沒有設定control_files引數,那麼資料庫判斷還原控制檔案儲存位置的規則將會與沒有設定control_files引數時建立控制檔案時使用的規則一樣。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-1423239/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- rman還原控制檔案(四)
- rman還原控制檔案(三)
- rman還原控制檔案(二)
- 使用RMAN在還原控制檔案後開啟資料庫資料庫
- 從控制檔案自動備份還原引數檔案
- ORACLE RMAN 還原歸檔日誌Oracle
- RMAN恢復控制檔案
- 使用DBMS_BACKUP_RESTORE來還原控制檔案和資料檔案REST
- 使用rman恢復控制檔案
- rman 還原歸檔日誌(restore archivelogRESTHive
- rman 還原歸檔日誌(restore archivelog)RESTHive
- rman恢復控制檔案的一個小錯誤
- 從ASM磁碟中還原出檔案(一)ASM
- RMAN備份資料檔案+控制檔案+歸檔日誌
- RMAN備份恢復之控制檔案的恢復(一)
- RMAN - "丟失控制檔案的恢復"
- rman恢復控制檔案測試--log
- 控制檔案丟失的RMAN恢復
- RMAN說,我能備份(4)--RMAN備份資料檔案和控制檔案
- rman還原恢復操作
- ASM儲存使用RMAN複製控制檔案ASM
- 控制檔案快照和rman利用快照恢復
- RMAN 恢復之控制檔案篇(1/5)
- RMAN 恢復之控制檔案篇(2/5)
- RMAN 恢復之控制檔案篇(3/5)
- RMAN 恢復之控制檔案篇(4/5)
- RMAN 恢復之控制檔案篇(5/5)
- rman備份丟失控制檔案恢復
- 記一次逆向分析解密還原Class檔案解密
- 檔案還原工具ForemostREM
- SVN還原已刪除檔案
- ORACLE RMAN備份及還原Oracle
- RMAN恢復表空間,資料檔案,歸檔檔案,控制檔案等介紹
- rman還原歸檔時報RMAN-20242錯誤分析和處理
- 【RMAN】Oracle中如何備份控制檔案?備份控制檔案的方式有哪幾種?Oracle
- Oracle RMAN 備份控制檔案報錯問題Oracle
- rman恢復--丟失控制檔案的恢復
- win10如何還原刪除的檔案_win10怎麼還原被刪檔案Win10