oracle備份恢複之recover database的四條語句區別

來源:互聯網
上載者:User
oracle備份恢複之recover database的四條語句區別  

2011-09-20 11:27:48|  分類:

Oracle備份恢複 |  標籤:
|字型大小大中小 訂閱

1  recover database using backup controlfile
2  recover database until cancel
3  recover database using backup controlfile until cancel;
4  recover database until cancel using backup controlfile;

本文主要介紹以下四種恢複方式的含義與區別: 1. recover database using backup controlfileITPUB個人空間 \6C+L-K3}+m
 如果丟失當前控制檔案,用冷備份的控制檔案恢複的時候,用來告訴oracle,不要以controlfile中的scn作為恢複的終點; 2. recover database until cancel 如果丟失current/active redo的時候,手動指定終點。 3. recover database using backup controlfile until cancel;  如果丟失當前controlfile並且current/active redo都丟失,會先去自動應用歸檔日誌,可以實現最大的恢複; 4. recover database until cancel using backup controlfile;  如果丟失當前controlfile並且current/active redo都丟失,以舊的redo中的scn為恢複終點。因為沒有應用歸檔日誌,所有會遺失資料。 要理解recover database using backup controlfile,先理解 recover database,也就是說,不加using backup controlfile的情況。在普通的recover database 或者 recover tablespace, recover datafile時, Oracle會以當前controlfile所紀錄的SCN為準,利用archive log和 redo log的redo entry, 把相關的datafile 的 block恢複到“當前controlfile所紀錄的SCN”I而某些情況下,Oracle需要把資料恢複到比當前controlfile所紀錄的SCN還要靠後的位置(比如說,control file是backup controlfile , 或者 controlfile是根據trace create的。),這時候,就需要用using backup controlfile.   恢複就不會受“當前controlfile所記錄的SCN”的限制。這時候的限制就來自於你的語句(until time , until scn),或者可用的archive
log(until cancel) ...

結果如下:
如果控制檔案丟失,restore備份的控制檔案後,則必須使用using backup controlfile選項。而until cancel則是不完全恢複,即current/active redo丟失,或者從restore資料庫後某個歸檔檔案缺失,則終止。

結論:
1、適用於restore舊的控制檔案,且歸檔日誌和cuurrent/active redo都沒有丟失情況。如果一切歸檔日誌和線上日誌完好,可以不遺失資料。類似於recover database
2、當前控制檔案未丟失(不需要restore舊的控制檔案),此時有歸檔日誌或者current/active log有丟失情況下,則終止。最大可能恢複資料
3、4:我在oracle 10.2.0.4環境下測試效果是相同的,即適用於restore舊的控制檔案,在恢複到控制檔案備份那刻後,系統會提示應用控制檔案備份後的歸檔日誌,如果沒有則停止。也是最大可能的恢複資料。

可以得出結果,如果有舊的Database Backup,在歸檔日誌和線上日誌全部儲存完好的情況下,使用recover database或recover database using backup controlfile。則不遺失資料
如果存在備份資料檔案restore後,歸檔日誌或者線上日誌(active、current)丟失情況下,則可以恢複到丟失的前一個歸檔日誌

 

until cancel就是不完全恢複
需要alter database open resetlogs
資料庫開啟後需要理解做一個全庫備份

 

線上記錄檔丟失:

如果正常關閉資料庫,然後啟動時報錯:

SQL> alter database open;
alter database open
*
第 1 行出現錯誤:
ORA-00313: 無法開啟日誌組 1 (用於線程 1) 的成員
ORA-00312: 聯機日誌 1 線程 1:
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG'

SQL> alter database open resetlogs;
alter database open resetlogs
*
第 1 行出現錯誤:
ORA-01139: RESETLOGS 選項僅在不完全資料庫恢複後有效

SQL> recover database until cancel;
完成介質恢複。
SQL> alter database open resetlogs;

資料庫已更改。
from:http://blog.163.com/scott_guo/blog/static/1810260832011820112748756/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.