控制檔案恢復—從自動或二進位制備份中恢復
說明
資料庫在NOCATALOG模式下,RMAN備份資訊會儲存在控制檔案中,如果控制檔案丟失,備份資訊也會找不到,如果有控制檔案備份我們可以執行恢復,如果沒有控制檔案備份我們也可以利用建立控制檔案指令碼來恢復資料庫。
從自動或二進位制備份中恢復
1 建立新的表空間、資料檔案、使用者
SQL>create tablespace ttt datafile ‘/oracle/u01/app/oracle/oradata/orcl/ttt.dbf’ size 10m; SQL>grant connect,resource to ttt identified by ttt; SQL>alter user ttt default tablespace ttt; SQL>alter user ttt account unlock; |
2 構造資料
SQL>conn ttt/ttt; SQL>create table ttt (id int); SQL> insert into ttt values(1); 1 row created. SQL> insert into ttt values(2); 1 row created. SQL> insert into ttt values(3); 1 row created. SQL> commit; Commit complete. SQL>select * from ttt; ID ---- 1 2 3 |
ttt使用者預設表空間為ttt,建立表ttt,並插入3資料。
3 切換日誌
SQL>conn / as sysdba; SQL>alter system switch logfile; |
切換日誌,保證資料都寫到DBF中。
4 開啟控制檔案自動備份
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/u01/app/oracle/backup/%F';
new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/u01/app/oracle/backup/%F'; new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/u01/app/oracle/backup/%U';
new RMAN configuration parameters: CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/u01/app/oracle/backup/%U'; new RMAN configuration parameters are successfully stored released channel: ORA_DISK_1 |
5 備份資料庫
RMAN>backup database;
Starting backup at 07-MAR-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=540 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/ttt.dbf channel ORA_DISK_1: starting piece 1 at 07-MAR-13 channel ORA_DISK_1: finished piece 1 at 07-MAR-13 piece handle=/oracle/u01/app/oracle/backup/0lo3uo4l_1_1 tag=TAG20130307T175741 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 Finished backup at 07-MAR-13
Starting Control File and SPFILE Autobackup at 07-MAR-13 piece handle=/oracle/u01/app/oracle/backup/c-1324770912-20130307-08 comment=NONE Finished Control File and SPFILE Autobackup at 07-MAR-13
|
資料庫備份集於/oracle/u01/app/oracle/backup/下
控制檔案自動備份於/oracle/u01/app/oracle/backup/c-1324770912-20130307-08
6 再插入一些資料
SQL>conn ttt/ttt; SQL> insert into ttt values(4); 1 row created. SQL> insert into ttt values(5); 1 row created. SQL> insert into ttt values(6); 1 row created. SQL> commit; Commit complete. SQL>select * from ttt;
|
7 模擬丟失控制檔案
SQL>conn / as sysdba; SQL>shutdown immediate; [oracle@dev206 ~]$ rm -rf /oracle/u01/app/oracle/oradata/orcl/control0*.ctl SQL> startup ORA-32004: obsolete and/or deprecated parameter(s) specified 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狀態。
8 恢復控制檔案
如果開啟了控制檔案自動備份可以利用autobackup來恢復控制檔案或者
利用備份集來恢復控制檔案。
RMAN>set dbid=1324770912 RMAN> restore controlfile from autobackup;
Starting restore at 07-MAR-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=540 devtype=DISK
recovery area destination: /oracle/u01/app/oracle/flash_recovery_area database name (or database unique name) used for search: ORCL channel ORA_DISK_1: no autobackups found in the recovery area channel ORA_DISK_1: looking for autobackup on day: 20130307 channel ORA_DISK_1: looking for autobackup on day: 20130306 channel ORA_DISK_1: looking for autobackup on day: 20130305 channel ORA_DISK_1: looking for autobackup on day: 20130304 channel ORA_DISK_1: looking for autobackup on day: 20130303 channel ORA_DISK_1: looking for autobackup on day: 20130302 channel ORA_DISK_1: looking for autobackup on day: 20130301 channel ORA_DISK_1: no autobackup in 7 days found RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 03/07/2013 18:00:34 RMAN-06172: no autobackup found or specified handle is not a valid copy or piece |
此時找不到控制檔案,因為我們更改了自動備份控制檔案路徑,可以手動
拷貝備份到./product/dbs下或者指定檔案。
RMAN> restore controlfile from '/oracle/u01/app/oracle/backup/c-1324770912-20130307-08';
Starting restore at 07-MAR-13 using channel ORA_DISK_1
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 07-MAR-13
或者指定備份集來恢復控制檔案 RMAN> restore controlfile from '/oracle/u01/app/oracle/backup/0lo3uo4l_1_1d';
|
控制檔案提取完成,啟動資料庫到mount狀態。
RMAN>alter database mount; |
利用RMAN恢復資料庫
RMAN>recover database; |
啟動資料庫
RMAN>alter database open resetlogs; |
9 檢查資料
SQL> select count(*) from ttt.ttt; ID ---------- 1 2 3 4 5 6 |
資料庫恢復完成.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26252014/viewspace-755621/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN備份恢復之控制檔案的恢復(二)
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(二)
- 備份與恢復--利用備份的控制檔案恢復
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(三)
- 【管理篇備份恢復】rman恢復測試(二) 控制檔案恢復(一)
- 控制檔案恢復—從快照中恢復
- 控制檔案恢復—從trace檔案中恢復
- 測試恢復5==使用2進位制形式檔案恢復控制檔案
- 【備份與恢復】控制檔案的恢復(不完全恢復)
- 備份與恢復系列 十一 控制檔案的備份與恢復
- RMAN備份恢復之控制檔案的恢復(三)
- RMAN備份恢復之控制檔案的恢復(一)
- 【備份恢復】利用 備份控制檔案到指定目錄下的控制檔案 恢復控制檔案
- 【備份恢復】所有控制檔案丟失後 利用trace中的控制檔案備份執行恢復
- 【備份恢復】丟失所有控制檔案,利用RMAN進行恢復操作
- Oracle備份與恢復【丟失控制檔案的恢復】Oracle
- 【備份恢復】 控制檔案多路徑
- 利用備份的控制檔案恢復
- 備份與恢復--重建控制檔案
- 控制檔案的備份和恢復
- 循序漸進oracle第7章:備份與恢復之利用控制檔案快照恢復控制檔案Oracle
- 【備份恢復】 丟失一個控制檔案 之恢復操作
- 【rman 備份與恢復】恢復丟失所有的控制檔案
- 【備份與恢復】恢復受損的複用控制檔案
- 備份與恢復(Parameter 檔案恢復篇)
- 備份與恢復--從備份的歸檔日誌中恢復資料
- 恢復之利用備份在所有控制檔案丟失情況下恢復(二)
- 【實驗】從RMAN備份中恢復controlfile控制檔案
- rman備份丟失控制檔案恢復
- 【備份恢復】從備份恢復資料庫資料庫
- Oracle 11g RAMN恢復-控制檔案的備份和恢復Oracle
- 如何從Active Backup for Business備份中恢復檔案
- 【實驗】從RMAN備份中恢復spfile檔案
- 備份與恢復--重建控制檔案後資料檔案損壞的恢復
- 使用舊的控制檔案備份來恢復控制檔案
- Oracle手工不完全恢復(二):使用備份控制檔案Oracle
- oralce備份與恢復1 控制檔案(轉)
- 從dataguard備份的恢復機制