ResetLogs 選項學習與測試

gdutllf2006發表於2010-03-06

ResetLogs 選項學習與測試

 

目錄

1 ResetLogs Overview

2 When do we need ResetLog

3 ResetLog的作用

4 RMAN OPEN RESETLOGS SQLPLUSOPEN RESETLOGS 的區別

5 在重建控制檔案的時候使用ResetLog

 

1 ResetLogs Overview

       The primary function of resetlogs is to discard the redo that was not applied during incomplete recovery, ensuring that the skipped redo can never be accidentally applied by a subsequent recovery. To accomplish this, resetlogs effectively invalidates all existing redo in all online and archived redo logfiles. This has the side effect of making any existing datafile backups unusable for future recovery operations.Resetlogs also reinitializes the controlfile information about online logs and redo threads, clears the contents of any existing online redo log files, creates the online redo log files if they do not currently exist, and resets the log sequence number in all threads to one.

 

2 When do we need ResetLog

以下條件需要使用resetlog

1)在不完全恢復(介質恢復)

 

2)使用備份控制檔案(backup的控制檔案一般從日誌檔案和資料庫的資訊以及SCN的資訊,相比目前的狀態都已經過期了)

 

3 ResetLog的作用

(1) 將重做日誌的序列號設為1

 

(2) 一般以該子句開啟資料庫後,要立即備份資料庫,因為這個子句會使資料庫以前的備份不能用.

 

(3) 在重做日誌當前日誌組出現錯誤時,要以該子句開啟資料庫.該子句會重新設定重做日誌檔案的狀態.

 

(4) 讓資料庫系統歸檔初始化,重新生成歸檔檔案.

 

 

4 RMAN OPEN RESETLOGS SQLPLUSOPEN RESETLOGS 的區別

 

1) If you run the RMAN command (not the SQL statement) ALTER DATABASE OPEN RESETLOGS, then RMAN automatically creates a new database incarnation record in the recovery catalog. RMAN implicitly and automatically issues a RESET DATABASE command, which specifies that this new incarnation of the database is the current incarnation. RMAN associates all subsequent backups and log archiving done by the target database with the new database incarnation.

 

2) If you issue the SQL statement (not the RMAN command) ALTER DATABASE OPEN RESETLOGS, then RMAN does not automatically run a RESET DATABASE command. Hence, RMAN cannot access the recovery catalog because it cannot distinguish between a RESETLOGS command and an accidental restore of an old control file. To solve this problem, you must manually run the RESET DATABASE command in RMAN after executing the SQL statement ALTER DATABASE OPEN RESETLOGS.

 

The RESET DATABASE command updates the repository to indicate that the target database has been opened with the RESETLOGS option. In the rare situation in which you wish to restore backups of a prior incarnation of the database, use the RESET DATABASE TO INCARNATION key command to change the current incarnation to an older incarnation. For example, if you accidentally drop a table immediately after the most recent RESETLOGS, then you may want to

recover the database to just before the time of the most recent RESETLOGS and then open it with the RESETLOGS option, thereby creating a new incarnation.

 

5 在重建控制檔案的時候使用ResetLog

create controlfile resetlogs/noresetlogs

  1) noresetlogs重建控制檔案時,控制檔案中 datafile checkpoint scn來自online logs中的Current log

 

  2) resetlogs重建控制檔案時,控制檔案中datafile Checkpoint SCN來自各資料檔案頭(Start SCN)

 

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

相關文章