Performing Cancel-Based Incomplete Recovery

文档地址:http://docs.oracle.com/cd/B19306_01/backup.102/b14191/osrecov.htm#i1007299

Performing Cancel-Based Incomplete Recovery

 

In cancel-based recovery, recovery proceeds by prompting youwith the suggested filenames of archived redo log files. Recoverystops when you specify CANCEL instead of a filename orwhen all redo has been applied to the datafiles.

Cancel-based recovery is better than change-based ortime-based recovery if you want to control which archived logterminates recovery. For example, you may know that you have lostall logs past sequence 1234, so you want to cancel recovery afterlog 1233 is applied.

 

--注意:

 

1、当前因为磁盘失败而失去序列号为1234的日志,所以在应用1233日志序列号以后,就需要取消恢复。即只能恢复到1233上,而不包括1234的日志,因为此日志文件已损坏。

2、不管RMAN或者用户托管的不完全恢复,假设损坏的日志序列号为:1234,都只能恢复到日志序列号1233的日志,而又不包括序列号1234的日志。

3、基于撤销的不完全恢复,有可能是完全恢复(如果所有日志都还在并且不损坏,那么RECOVER DATABASEUNTIL CANCEL就是完全恢复),但数据库系统的SCN号已经被改变,所以还是需要用ALTER DATABASE OPENRESETLOGS;打开数据库。实验例子(当前日志文件序列号:60,并且没归档,文件为:REDO03.LOG)--如图:

 

 

 

4、基于撤销的不完全恢复,当你使用用户托管的命令来做恢复,即在SQL*PLUS上输入命令:RECOVERDATABASE UNTILCANCEL;来进行恢复,系统会提示你建议使用指定地址下的归档日志文件,当你将此文件应用到已还原的文件上,系统会再次提示你建议使用下一个指定地址下的归档日志文件。直至应用到你损坏的那个文件,但又不包括那个日志文件。然后,你就可以输入CANCEL终止恢复,使用ALTERDATABASE OPENRESETLOGS打开数据库,再次整个备份数据库。当然你也可以在没到损坏的日志序列号之前,输入CANCEL退出,然后使用ALTERDATABASE OPEN RESETLOGS打开数据库,但结果会丢失更多的数据。

 

实验例子(当前日志文件序列号:60,并且没归档,文件为:REDO03.LOG,此日志损坏)--如图:为了尽可能少损失数据,我做实验的时候,在59的时候CANCEL,用ALTERDATABASE OPEN RESETLOGS打开数据库。如下图:

 

 

 

如果你不按照系统提示的建议归档日志文件,给个错误文件,系统会报错,直接退出。(如果你想继续做不完全恢复,那么在SQL>  上输入RECOVER DATABASE UNTIL CANCEL。)如下图:

 

 

 

 

 

You should perform cancel-based media recovery in thesestages:

Prepare for recovery by backing up the database and correct anymedia failures as described in "Preparing for Incomplete Recovery".

Restore backup datafiles as described in "Restoring Datafiles Before Performing Incomplete Recovery". Ifyou have a current control file, then do not restore a backupcontrol file.

Perform media recovery on the restored database backup asdescribed in the following procedure.

To perform cancel-based recovery:

Start SQL*Plus and connect to the database with administratorprivileges, then start a new instance and mount thedatabase:

STARTUP MOUNT

Begin cancel-based recovery by issuing the followingcommand:

RECOVER DATABASE UNTIL CANCEL

If you are using a backup control file with this incompleterecovery, then specify the USING BACKUPCONTROLFILE option in the RECOVERcommand.

RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE

Note:

If you fail to specify the UNTIL clause on the RECOVER command, then the database assumes a completerecovery and will not open until all redo is applied.

 

The database applies the necessary redo log files to reconstructthe restored datafiles. The database supplies the name it expectsto find from LOG_ARCHIVE_DEST_1 and requests you tostop or proceed with applying the log file. Note that if thecontrol file is a backup, then you must supply the names of theonline logs if you want to apply the changes in these logs.

 

Note:

If you use a Real Application Clusters (RAC) configuration, and youare performing incomplete recovery or using a backup control file,then the database can only compute the name of the first archivedredo log file from the first thread. The first redolog file from the other threads must be supplied by the user. Afterthe first log file in a given thread has been supplied, thedatabase can suggest the names of the subsequent log files in thisthread.

Continue applying redo log files until the last log has beenapplied to the restored datafiles, then cancel recovery byexecuting the following command:

CANCEL

The database indicates whether recovery is successful. If youcancel before all the datafiles have been recovered to a consistentSCN and then try to open the database, you will get anORA-1113 error if more recovery is necessary. Asexplained in "Determining Which Datafiles Require Recovery", you can queryV$RECOVER_FILE to determine whether more recovery isneeded, or if a backup of a datafile was not restored prior tostarting incomplete recovery.

Open the database with the RESETLOGS option. Youmust always reset the logs after incomplete recovery or recoverywith a backup control file. For example:

ALTER DATABASE OPEN RESETLOGS;

See Also:

"Openingthe Database with the RESETLOGS Option"

你可能感兴趣的:(做程序员时积累的Oracle)