cp方式恢復控制檔案

skyin_1603發表於2016-11-08

使用cp方式恢復控制檔案並恢復資料庫,這是線上備份的方式。
--備份控制檔案到指定的路徑:

sys@PROD>alter database backup controlfile to '/home/oracle/control_bak.ctl';

Database altered.
--檢視生成的控制檔案備份:

sys@PROD>!ls /home/oracle/control_bak.ctl

/home/oracle/control_bak.ctl


 --先只刪除一個控制檔案:

!rm /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!rm /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!ls /u01/app/oracle/oradata/PROD/control01.ctl

ls: /u01/app/oracle/oradata/PROD/control01.ctl: No such file or directory

sys@PROD>shutdown immediate;

--嘗試關庫:

Database closed.

ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/oradata/PROD/control01.ctl'

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

sys@PROD>

sys@PROD>

sys@PROD>shutdown abort;

ORACLE instance shut down.

 

--將備份的控制檔案複製到控制檔案原目錄

!cp /home/oracle/control_bak.ctl /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!cp /home/oracle/control_bak.ctl /u01/app/oracle/oradata/PROD/control01.ctl

sys@PROD>!ls /u01/app/oracle/oradata/PROD/control01.ctl

/u01/app/oracle/oradata/PROD/control01.ctl

 

--資料庫啟動到mount模式

sys@PROD>startup mount;

ORACLE instance started.

 

Total System Global Area  835104768 bytes

Fixed Size                  2257840 bytes

Variable Size             507513936 bytes

Database Buffers          322961408 bytes

Redo Buffers                2371584 bytes

ORA-00214: control file '/u01/app/oracle/fast_recovery_area/PROD/control02.ctl'

version 1904 inconsistent with file

'/u01/app/oracle/oradata/PROD/control01.ctl' version 1901

#版本不一致。

 

--刪除其中一個控制檔案,從備份中複製一份:

sys@PROD>!rm /u01/app/oracle/fast_recovery_area/PROD/control02.ctl

sys@PROD>!cp /home/oracle/control_bak.ctl /u01/app/oracle/fast_recovery_area/PROD/control02.ctl

sys@PROD>!ls /u01/app/oracle/fast_recovery_area/PROD/control02.ctl

/u01/app/oracle/fast_recovery_area/PROD/control02.ctl

 #這裡為了兩個控制檔案的版本一致性,刪除版本號大的日誌檔案,然後從備份中複製一份。

--關閉重啟例項到mount狀態:

sys@PROD>startup mount;

ORA-01081: cannot start already-running ORACLE - shut it down first

sys@PROD>shutdown abort;    

ORACLE instance shut down.

sys@PROD>

sys@PROD>

sys@PROD>startup mount;

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size                  2257840 bytes

Variable Size             507513936 bytes

Database Buffers          322961408 bytes

Redo Buffers                2371584 bytes

Database mounted.

sys@PROD>

 

--嘗試open資料庫

sys@PROD>alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

 

sys@PROD>alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01152: file 1 was not restored from a sufficiently old backup

ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'

sys@PROD>recover database;

ORA-00283: recovery session canceled due to errors

ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

 

--使用歸檔日誌恢復系統資料檔案:

sys@PROD>recover database using backup controlfile until cancel;

ORA-00279: change 1784270 generated at 11/07/2016 16:33:19 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/PROD/archivelog/2016_11_07/o1_mf_1_1_%u_.arc

ORA-00280: change 1784270 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

cancel

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01152: file 1 was not restored from a sufficiently old backup

ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'

ORA-01112: media recovery not started

 #提示需要從日誌檔案恢復系統資料檔案。

--檢視當前的日誌組:

sys@PROD>select group#,status from v$log where status='CURRENT';

    GROUP# STATUS

---------- ----------------

         1 CURRENT

sys@PROD>recover database using backup controlfile until cancel;

ORA-00279: change 1784270 generated at 11/07/2016 16:33:19 needed for thread 1

ORA-00289: suggestion :

/u01/app/FRA/PROD/archivelog/2016_11_07/o1_mf_1_1_%u_.arc

ORA-00280: change 1784270 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

/u01/app/oracle/oradata/PROD/redo01.log         #輸入第一組日誌檔案的絕對路徑#

Log applied.

Media recovery complete.

sys@PROD>

--再次嘗試開啟資料庫:

sys@PROD>alter database open;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

sys@PROD>alter database open RESETLOGS;

Database altered.

#成功開啟資料庫。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2127991/,如需轉載,請註明出處,否則將追究法律責任。

相關文章