Oracle中修復(fù)數(shù)據(jù)塊的損壞
1、先創(chuàng)建一個(gè)用于實(shí)驗(yàn)的表空間
create tablespace block datafile size 1M extent management local–因?yàn)槭?1g所以使用了AMS
alter user ff default tablespace block;
alter user ff quota unlimited on block;
2、損壞數(shù)據(jù)文件
關(guān)閉database后用編輯器隨便修改幾個(gè)字符,然后啟動(dòng)database
當(dāng)訪問相關(guān)被損壞的block時(shí),將會(huì)遇到錯(cuò)誤
3、對(duì)此使用dbv檢查數(shù)據(jù)文件
dbv file=block.dbf blocksize=8192
假設(shè)獲得第35塊被損壞了
4、恢復(fù)步驟
①select tablespace_name, segment_type, owner, segment_name from dba_extents where file_id=4 and 35 between block_id and block_id+blocks-1;
如果確定損失的是數(shù)據(jù),就ok
設(shè)置內(nèi)部事件,設(shè)置在全表掃描時(shí)跳過損壞的數(shù)據(jù)塊
alter system set events=’10231 trace name context forever,level 10′;
隨后,可以用exp和imp進(jìn)行導(dǎo)入導(dǎo)出,進(jìn)行恢復(fù)。但這畢竟導(dǎo)致相依blocks中數(shù)據(jù)的丟失。
②rman的塊媒體恢復(fù)(BMR)
使用BMR恢復(fù)可以大量降低恢復(fù)的時(shí)間,可以使datafile仍然處于在線的狀態(tài)。RMAN在BMR恢復(fù)時(shí),先在full或level 0的備份集中查詢相應(yīng)的塊的內(nèi)容,并恢復(fù),隨后使用 redo log進(jìn)行恢復(fù),而不使用level 1備份集。
在恢復(fù)之前,首先要查找到corrupt blocks:在db中,v$database_block_corruption 視圖顯示了rman、analyze、dbv和sql查詢等操作中獲悉的corrupt block信息。此視圖記錄的記錄數(shù)據(jù)有兩類:
*物理的corruption:無法辨識(shí)該數(shù)據(jù)塊,checksum、header、footer校驗(yàn)錯(cuò)誤
*邏輯corruption:chechsum、header、footer校驗(yàn)是正確的,但是該數(shù)據(jù)塊的內(nèi)容時(shí)不一致的。
注意:BMR是不能用于恢復(fù)邏輯上的corruption的。在backup命令中checksum的校驗(yàn)是
默認(rèn)開啟的,可以通過NOCHECKSUM選項(xiàng)屬性關(guān)閉。邏輯的校驗(yàn)?zāi)J(rèn)是關(guān)閉的,可以
在backup、restore、recover、validate命令中添加CHECK LOGICAL開啟。
@@進(jìn)行BMR的條件
1)target db必須運(yùn)行在歸檔模式下,并以當(dāng)前的控制文件open或mounted
2)If the target database is a standby database, then it must be in a consistent state, recovery cannot be in session, and the backup must be older than the corrupted file.
3)數(shù)據(jù)文件的備份集必須是full或level 0
4)對(duì)于BMR,rman只使用已經(jīng)歸檔的redo logs
5)flashback db開啟時(shí),rman可以用flashback logs查找corrupt block在corrupt之前的鏡像,用于恢復(fù),加快恢復(fù)速度。
使用恢復(fù)命令恢復(fù)指定的數(shù)據(jù)塊
相關(guān)文章:
1. Oracle數(shù)據(jù)庫中fast刷新會(huì)受到哪些限制2. 全面解析Oracle developer的異常處理機(jī)制3. Oracle進(jìn)程導(dǎo)致CPU 100%具體解決步驟4. Oracle中PL/SQL單行函數(shù)和組函數(shù)詳解5. 在ORACLE里用存儲(chǔ)過程定期分割表7. oracle中all、any函數(shù)用法與區(qū)別說明8. [Oracle] Ora2html--收集Oracle數(shù)據(jù)庫信息9. Oracle以網(wǎng)格技術(shù)解決成本難題10. Windows10系統(tǒng)中Oracle完全卸載正確步驟
