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 還原歸檔日誌(restore archivelogRESTHive
- rman恢復控制檔案的一個小錯誤
- 【RMAN】Oracle中如何備份控制檔案?備份控制檔案的方式有哪幾種?Oracle
- 【RMAN】如果控制檔案損壞那麼如何恢復?恢復控制檔案的方式有哪幾種?
- 【備份】RMAN中對控制檔案的幾種備份方法
- 記一次逆向分析解密還原Class檔案解密
- win10如何還原刪除的檔案_win10怎麼還原被刪檔案Win10
- oracle 還原 .dmp 格式備份檔案Oracle
- win10備份檔案後怎麼還原_win10備份檔案還原的方法Win10
- [重慶思莊每日技術分享]-RMAN修改控制檔案自動備份路徑報錯RMAN-06492
- 透過RMAN備份standby database成功恢復還原Database
- 如何透過.dbf檔案還原資料庫資料庫
- 替換掉的檔案怎麼恢復,兩個方法還原檔案
- SQL Server資料庫還原過程記錄,bak檔案+mdf檔案SQLServer資料庫
- 記一次 IIS 站點配置檔案備份和還原,物理路徑檔案批量備份
- 【DG】備庫RMAN還原方式搭建DG(不使用duplicate命令)
- 2012-06-03 20:40 catalog start with rman備份集直接匯入控制檔案中
- Oracle 控制檔案Oracle
- 12 使用RMAN備份和恢復檔案
- Sqlserver資料庫使用 .bak 檔案還原資料庫SQLServer資料庫
- 如何還原鐵威馬NAS上刪除的檔案?
- 2.6.4 指定控制檔案
- 【常用命令】 Git 還原修改檔案到原始狀態Git
- 圖形化還原崩潰地址 iOS的crash檔案分析iOS
- Oracle使用RMAN將普通資料檔案轉成ASMOracleASM
- 【VMware VCF】透過備份的配置檔案還原 SDDC Manager 元件。元件
- DM7使用dmrestore執行並行對映檔案還原REST並行
- 【DG】在Linux平臺上搭建單例項的dataguard--rman還原方式Linux單例
- Oracle RMAN還原測試錯誤ORA-19571 ORA-19600 ORA-19601Oracle
- 控制檔案不一致引發的“血案”
- veeambackup通過虛擬機器還原系統檔案操作說明虛擬機
- 控制檔案損壞處理
- ORACLE 控制檔案(Control Files)概述Oracle
- pdf是圖片還是文件 pdf格式是文字檔案還是影像檔案
- 【原創】多專案控制的困惑
- RMAN備份恢復典型案例——資料檔案存在壞快
- ElementPlus upload元件限制上傳一個檔案,重新選擇替換原來檔案元件
- 【/proc/檔案淺析】另類辦法恢復資料檔案和控制檔案
- windwos檔案控制代碼數限制