一.建立控制檔案時:Resetlogs和Noresetlogs
當我們將控制檔案備份到trace 檔案時,可以看到裡麵包含了2部分的重建語句,一個是使用resetlogs,另一個是使用noresetlogs。
備份控制檔案的SQL 如下:
SQL>alterdatabase backup controlfile to trace
有關控制檔案的詳細說明,參考:
Oracle 控制檔案
http://blog.csdn.net/tianlesoftware/article/details/4974440
Set #1. NORESETLOGS case
The followingcommands will create a new control file and use it to open the database. Dataused by Recovery Manager will be lost.
Additional logsmay be required for media recovery of offline.
Use this only ifthe current versions of all online logs are available.
--使用noresetlogs僅是當前所有的online logs可用時。
Set #2. RESETLOGS case
The followingcommands will create a new control file and use it to open the database. Dataused by Recovery Manager will be lost.
The contents ofonline logs will be lost and all backups will be invalidated. Use this only ifonline logs are damaged.
--使用resetlogs,將導致online logs裡的內容丟失,並且所有的備份失效,僅當online logs 隨壞的情況下,才使用resetlos模式。
CREATE CONTROLFILE REUSE DATABASE"DAVE" RESETLOGS/NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1'/u01/app/oracle/oradata/dave/redo01.log' SIZE 50M,
GROUP 2'/u01/app/oracle/oradata/dave/redo02.log' SIZE 50M,
GROUP 3'/u01/app/oracle/oradata/dave/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/dave/system01.dbf',
'/u01/app/oracle/oradata/dave/undotbs01.dbf',
'/u01/app/oracle/oradata/dave/sysaux01.dbf',
'/u01/app/oracle/oradata/dave/users01.dbf'
CHARACTER SET ZHS16GBK
;
二.開啟資料庫時:Resetlogs 和Noresetlogs
2.1 說明
Use RESETLOGSafter incomplete recovery (when the entire redo stream wasn't applied).RESETLOGS will initialize the logs, reset your log sequence number, and start anew "incarnation" of the database.
--RESETLOGS會初始化logs,重設log sequence號,建立一個新的incarnation。
Use NORESETLOGSwhen doing complete recovery (when the entire redo stream was applied). Oraclewill continue using the existing (valid) log files.
--NORESETLOGS 會繼續使用已經存在,且有效log files。
可以使用RMAN命令查看incarnation的資訊:
RMAN> list incarnation;
更多內容參考:
RMAN 系列(八)---- RMAN List和report命令
http://blog.csdn.net/tianlesoftware/article/details/5728116
Oracle Rman跨resetlogs版本恢複
http://blog.csdn.net/tianlesoftware/article/details/4682463
做不完全恢複必須使用resetlogs, resetlogs也可以做完全恢複。而noresetlogs則是必須做完全恢複時使用。resetlogs會重設記錄序號強制清空或重建REDO,而noresetlogs則不會這麼做。
2.2 MOS 上對這個RESETLOGS和NORESETLOGS的說明:
Physical Backup and Recovery: An Insider'sPerspective [ID 16530.1]:
After recoverdatabase operation, open the database with: ALTER DATABASE OPEN [NO]RESETLOGS
(1) NORESETLOGS
The NORESETLOGSoption does not clear the redo log files during startup and the online redologs to be used for recovery. Only used in scenario where MANUAL RECOVERY isstarted, CANCEL is used, and then RECOVER DATABASE is started.
(2)RESETLOGS
CAUTION: Never use RESETLOGS unlessnecessary.
Once RESETLOGS is used then the redo logfiles cannot be used and any completed transactions in those redo logs arelost!!
Before using the RESETLOGS option take anoffline backup of the database.
The RESETLOGSoption clears all the online redo logs and modifies all the online data filesto indicate no recovery is needed. After resetting the redo logs none of theexisting log files or data file backups can be used.
In the control file, the log sequence number is modified,which is very important for recovery purposes. Therecovery will be applied only to the log files whose sequence number is greaterthan log sequence number in the control file. One has to be very cautious whenusing RESETLOGS option. It is important to remember that all datafiles must beonline otherwise they will become useless once the database is up。
2.3 幾種情況的說明
(1) 第一種情況
假設僅僅控制檔案丟失,而其他檔案沒有丟失(主要是歸檔和REDO),那麼恢複的時候如果選擇從備份中恢複控制檔案。恢複後,控制檔案會去讀資料檔案頭中與CHECKPOINT SCN對應的RBA資訊來確定從那個序列的歸檔日誌開始恢複,一直推進恢複到NEXT SCN是無窮大的那個REDOLOG,此時恢複是完全恢複的,但開啟的時候還要以resetlogs方式開啟,這樣要重設歸檔日誌的sequence,也就是說,如果你恢複時使用了備份控制檔案,那麼開啟資料庫時必然是要resetlogs的。
不完全恢複時是必須RESETLOGS,但是完全恢複時如果使用備份控制檔案來恢複,那麼使用RESETLOGS一樣可以完全恢複。但是丟失控制檔案也可以不使用RESETLOGS方式開啟資料庫,這樣也就可以避免重設記錄序號帶來的不變,詳情請見第四種情況。
(2) 第二種情況
不完全恢複,不管是要什麼樣的不完全恢複,SCN,TIME,跨越REDO,都必須使用resetlogs。
(3) 第三種情況
丟失REDOLOG,這就更需要resetlogs了,因為resetlogs能夠重建REDOLOG。如果你的REDOLOG、控制檔案、資料檔案丟失的話,需要先恢複控制檔案,然後restore database;recover database;alter database open resetlogs;
注意,這時候做的是不完全恢複,因為REDO沒有了。在recover過程中可能會報錯然後自動結束RMAN,無視,alter database open resetlogs即可,
(4) 第四種情況
沒有丟失控制檔案及各種日誌,僅遺失資料檔案,這種問題比較常見,有可能磁碟損壞造成資料檔案丟失,等磁碟故障排除後,需要恢複,此時的恢複就很簡單了,restore database;recover database;alter database open;就一切OK,也就是說,在不使用備份控制檔案恢複的情況下,是可以使用noresetlog方式開啟資料庫的。
前提有一,不能丟失記錄檔。假若丟失了控制檔案和資料檔案但還是想以noresetlog開啟的話,就必須手動以noresetlogs方式重建控制檔案,而且REDOLOG的狀態都必須正常,否則是無法使用noresetlogs方式開啟。
幾種情況的分析轉自一下Blog:
http://space.itpub.net/16628454/viewspace-524593
-------------------------------------------------------------------------------------------------------
著作權,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!
Skype: tianlesoftware
QQ: tianlesoftware@gmail.com
Email: tianlesoftware@gmail.com
Blog: http://www.tianlesoftware.com
Weibo: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware
-------加群需要在備忘說明Oracle資料表空間和資料檔案的關係,否則拒絕申請----
DBA1 群:62697716(滿); DBA2 群:62697977(滿) DBA3 群:62697850(滿)
DBA 超級群:63306533(滿); DBA4 群:83829929 DBA5群: 142216823
DBA6 群:158654907 DBA7 群:172855474 DBA總群:104207940