您好,登錄后才能下訂單哦!
【BBED】BBED模擬并修復(fù)ORA-08102錯(cuò)誤
各位技術(shù)愛(ài)好者,看完本文后,你可以掌握如下的技能,也可以學(xué)到一些其它你所不知道的知識(shí),~O(∩_∩)O~:
① 使用BBED修復(fù)ORA-08102錯(cuò)誤(重點(diǎn))
② BBED的使用
③ 數(shù)據(jù)塊格式的dump文件解釋
④ ORA-08102錯(cuò)誤的trace文件解釋
⑤ 從rdba獲取ROWID信息
⑥ 其它實(shí)用技能
這幾天一個(gè)朋友問(wèn)我有關(guān)ORA-08102的錯(cuò)誤,而且是關(guān)于OBJ$表上的I_OBJ4索引。這些系統(tǒng)對(duì)象的索引,不能采用重建或設(shè)置事件的方式來(lái)修復(fù)該錯(cuò)誤。模模糊糊的記得很早以前看過(guò)使用BBED的方式來(lái)修復(fù)該錯(cuò)誤,只是已經(jīng)記不清了。正好,趁此機(jī)會(huì)把該錯(cuò)誤再模擬的復(fù)現(xiàn)一下,也把bbed再熟悉一下吧。
朋友發(fā)給我的參考文章也是大師惜分飛的博客地址,大致看了一下過(guò)程,主要是找到索引塊的相關(guān)地址,然后利用bbed把鍵值修改的和表中存儲(chǔ)的一致即可。還是那句話,“紙上得來(lái)終覺(jué)淺,絕知此事要躬行?!保?/span>自己模擬實(shí)驗(yàn),這個(gè)過(guò)程是必須的。
廢話不多說(shuō),開(kāi)始實(shí)驗(yàn)吧。
閱讀本篇文章,請(qǐng)先閱讀以下內(nèi)容:
1. Oracle 中 Object_iD 和 Data_Object_ID 的區(qū)別:http://blog.itpub.net/26736162/viewspace-2145230/
2. Oracle的dump函數(shù):http://blog.itpub.net/26736162/viewspace-2145228/
3. BBED的幾篇文章:
① 【BBED】編譯及基本命令(1):http://blog.itpub.net/26736162/viewspace-2075216/
② 【BBED】丟失歸檔文件情況下的恢復(fù):http://blog.itpub.net/26736162/viewspace-2079337/
③ 【BBED】 sys.bootstrap$ 對(duì)象的恢復(fù):http://blog.itpub.net/26736162/viewspace-2083621/
④ 【BBED】 SYSTEM文件頭損壞的恢復(fù)(4):http://blog.itpub.net/26736162/viewspace-2084329/
⑤ 【BBED】bbed常用命令:http://blog.itpub.net/26736162/viewspace-2123465/
1、bbed畢竟是未公開(kāi)的恢復(fù)方式,所以不熟悉的朋友要慎用。
2、startup force慎用
3、操作bbed之前最好先把數(shù)據(jù)庫(kù)關(guān)閉
An ORA-08102 indicates that there is a mismatch between the key(s) stored in the index and the values stored in the table.What typically happens in the index is built and at some future time,some type of corruption occurs,either in the table or index,to cause the mismatch.
ORA-08102常見(jiàn)于索引鍵值與表上存的值不一致。
[oracle@rhel6lhr ~]$ oerr ora 8102 08102, 00000, "index key not found, obj# %s, file %s, block %s (%s)" // *Cause: Internal error: possible inconsistency in index // *Action: Send trace file to your customer support representative, along // with information on reproducing the error |
ora-08102這種錯(cuò)誤說(shuō)明索引或表出現(xiàn)了數(shù)據(jù)不一致,索引上記錄的鍵值和表里的數(shù)據(jù)不一致,引起訪問(wèn)失敗,一般重建下索引就可以解決。兩邊不一致改表和索引都能達(dá)到目的,只要一致即可,但有一個(gè)原則就是索引鍵值始終要保證按順序遞增。通常有三種情況:
1.如果損壞為索引,則刪除索引并重建索引,但對(duì)于index的obj#小于56的情況,由于是核心的bootstrap$對(duì)象,index是在DB啟動(dòng)時(shí)由DB自動(dòng)創(chuàng)建,此種情況下通過(guò)設(shè)置event 38003或startup migrate模式都不能解決,但obj#>56的則可以。
2.如果損壞為塊級(jí)別,則采用壞塊的處理方法
3.如果損壞的為表的記錄級(jí)別的則采用bbed或其它工具
I_OBJ1、I_OBJ2、I_OBJ3、I_OBJ4、I_OBJ5這幾個(gè)都是OBJ$基表的索引,如果損壞會(huì)非常麻煩,因?yàn)?/span>ORACLE 對(duì)這些對(duì)象的DDL做了嚴(yán)格限制,沒(méi)有辦法簡(jiǎn)單修復(fù)它們。
SYS@ora11g > drop index i_obj4; drop index i_obj5 * ERROR at line 1: ORA-00701: object necessary for warmstarting database cannot be altered
|
項(xiàng)目 | source db |
db 類型 | 單機(jī) |
db version | 11.2.0.3.0 |
db 存儲(chǔ) | FS |
OS版本及kernel版本 | RHEL 6.5 |
實(shí)驗(yàn)?zāi)繕?biāo):使用BBED模擬并修復(fù)ORA-08102錯(cuò)誤。
模擬錯(cuò)誤過(guò)程:通過(guò)bbed修改OBJ$表中DATAOBJ#列最大的行所在的塊,讓DATAOBJ#的值增大,從而和索引中記錄的值不一致。重啟數(shù)據(jù)庫(kù)并創(chuàng)建表讓數(shù)據(jù)庫(kù)報(bào)出ORA-08102錯(cuò)誤。
修復(fù)錯(cuò)誤過(guò)程:通過(guò)bbed把表中或索引中的不一致的數(shù)據(jù)修改成一致的,從而修復(fù)ORA-08102錯(cuò)誤。
[oracle@rhel6lhr ~]$ more rman_full.sh rman target / nocatalog <<> run{ backup database format '/home/oracle/bak/%d_%U.full'; sql 'alter system archive log current'; backup archivelog all format '/home/oracle/bak/%d_%U.arc'; backup current controlfile format '/home/oracle/bak/%d_%U.ctl'; } EOF
|
通過(guò)BBED修改OBJ$中DATAOBJ$重現(xiàn)I_OBJ4索引報(bào)ORA-08102錯(cuò)誤。定位需要破壞的OBJ$上DATAOBJ$列最大的記錄,使之和索引I_OBJ4中記錄不一致,從而實(shí)現(xiàn)ORA-8102錯(cuò)誤。
[oracle@rhel6lhr ~]$ ORACLE_SID=ora11g [oracle@rhel6lhr ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Thu Sep 21 09:24:08 2017
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@ora11g > select object_id,object_type from dba_objects where object_name='I_OBJ4';
OBJECT_ID OBJECT_TYPE ---------- ------------------- 39 INDEX
SYS@ora11g > select max(DATAOBJ#) from obj$;
MAX(DATAOBJ#) ------------- 94098
SYS@ora11g > select dump(94098,16) from dual;
DUMP(94098,16) ----------------------- Typ=2 Len=4: c3,a,29,63 ===>>>>> Typ=2表示NUMBER,96表示CHAR。Len=4表示4位長(zhǎng)度,所以,94098在數(shù)據(jù)庫(kù)內(nèi)部的存儲(chǔ)格式為04c30a2963
SYS@ora11g > SELECT DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) FILE#, 2 DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) BLOCK#, 3 DBMS_ROWID.ROWID_ROW_NUMBER(ROWID) ROW# 4 FROM OBJ$ 5 WHERE DATAOBJ# = 94098;
FILE# BLOCK# ROW# ---------- ---------- ---------- 1 241 27
SYS@ora11g > SELECT COUNT(*) COUNTS, 2 MAX(DBMS_ROWID.ROWID_ROW_NUMBER(ROWID)) MAX_ROWNUM, 3 MIN(DBMS_ROWID.ROWID_ROW_NUMBER(ROWID)) MIN_ROWNUM 4 FROM SYS.OBJ$ D 5 WHERE DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) = 1 6 AND DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) = 241;
COUNTS MAX_ROWNUM MIN_ROWNUM ---------- ---------- ---------- 105 104 0
|
根據(jù)以上的SQL可以得到下表的內(nèi)容:
項(xiàng)目 | 值 |
OBJ$上DATAOBJ#列的最大值 | 94098 |
OBJ$上DATAOBJ#列的最大值dump值 | Typ=2 Len=4: c3,a,29,63 即:04c30a2963 |
該行所在數(shù)據(jù)塊的地址 | FILE# BLOCK# ROW# ---------- ---------- ---------- 1 241 27 |
該行的存儲(chǔ)情況 | COUNTS MAX_ROWNUM MIN_ROWNUM ---------- ---------- ---------- 105 104 0 |
即:OBJ$表上DATAOBJ#列的最大值為94098,該值在Oracle數(shù)據(jù)庫(kù)中的存儲(chǔ)格式為04c30a2963,該行數(shù)據(jù)所在的塊為1號(hào)文件,241號(hào)塊,第27行,該塊上共有105行數(shù)據(jù),最大值的行號(hào)為104,最小值的行號(hào)為0。
全文請(qǐng)參考:http://blog.itpub.net/26736162/viewspace-2145368/
SELECT COUNT(*) COUNTS, MAX(DBMS_ROWID.ROWID_ROW_NUMBER(ROWID)) MAX_ROWNUM, MIN(DBMS_ROWID.ROWID_ROW_NUMBER(ROWID)) MIN_ROWNUM FROM SYS.OBJ$ D WHERE DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) = 1 AND DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) = 241;
SELECT DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) FILE#, DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) BLOCK#, DBMS_ROWID.ROWID_ROW_NUMBER(ROWID) ROW# FROM SYS.OBJ$ WHERE DATAOBJ# = 94109;
SELECT DUMP(94098, 16) FROM DUAL;
SELECT DUMP(OBJ#, 16), DUMP(DATAOBJ#, 16), DUMP(OWNER#, 16), DUMP(NAME, 16), DUMP(NAMESPACE, 16), DUMP(SUBNAME, 16), DUMP(TYPE#, 16), DUMP(CTIME, 16), DUMP(MTIME, 16), DUMP(STIME, 16), DUMP(STATUS, 16), DUMP(REMOTEOWNER, 16), DUMP(LINKNAME, 16), DUMP(FLAGS, 16), DUMP(OID$, 16), DUMP(SPARE1, 16), DUMP(SPARE2, 16), DUMP(SPARE3, 16), DUMP(SPARE4, 16), DUMP(SPARE5, 16), DUMP(SPARE6, 16) FROM SYS.OBJ$ D WHERE DATAOBJ# = 94098;
SELECT OBJ#, DATAOBJ#, OWNER#, NAME, NAMESPACE, SUBNAME, TYPE#, CTIME, MTIME, STIME, STATUS, REMOTEOWNER, LINKNAME, FLAGS, OID$, SPARE1, SPARE2, SPARE3 FROM SYS.OBJ$ D WHERE DATAOBJ# = 94098;
SELECT * FROM SYS.OBJ$ D WHERE D.NAME = 'OBJ$';
SELECT 'DUMP(' || D.COLUMN_NAME || ',16),' FROM DBA_TAB_COLS D WHERE D.TABLE_NAME = 'OBJ$' ORDER BY D.COLUMN_ID; SELECT D.COLUMN_NAME || ',' FROM DBA_TAB_COLS D WHERE D.TABLE_NAME = 'OBJ$' ORDER BY D.COLUMN_ID;
SELECT * FROM sys.Bootstrap$ ;
ORA-08102: index key not found, obj# 39, file 1, block 94083 (2)
select /*+ index(t i_obj4) */ DATAOBJ# from sys.obj$ t minus select /*+ full(t1) */ DATAOBJ# from sys.obj$ t1;
select /*+ full(t1) */ DATAOBJ# from sys.obj$ t1 minus select /*+ index(t i_obj4) */ DATAOBJ# from sys.obj$ t ; select /*+ full(t) */ DATAOBJ#,type#,owner# from sys.obj$ t WHERE t.dataobj# IN (94098,94099); select /*+ full(t i_obj4) */ DATAOBJ#,type#,owner# from sys.obj$ t WHERE t.dataobj# IN (94098,94099);
--16進(jìn)制轉(zhuǎn)換為10進(jìn)制 select utl_raw.cast_to_number('c30a2964') from dual;
show all map p kdbr p *kdbr[27] x /rnnncncntttnccncnnn d /v count 32 f /x c30a29 sum sum apply v
|
About Me
.............................................................................................................................................
● 本文作者:小麥苗,只專注于數(shù)據(jù)庫(kù)的技術(shù),更注重技術(shù)的運(yùn)用
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)、博客園(http://www.cnblogs.com/lhrbest)和個(gè)人微信公眾號(hào)(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/viewspace-2145368/
● 本文博客園地址:http://www.cnblogs.com/lhrbest/p/7576416.html
● 本文pdf版、個(gè)人簡(jiǎn)介及小麥苗云盤(pán)地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 數(shù)據(jù)庫(kù)筆試面試題庫(kù)及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA寶典今日頭條號(hào)地址:http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群號(hào):230161599(滿)、618766405
● 微信群:可加我微信,我拉大家進(jìn)群,非誠(chéng)勿擾
● 聯(lián)系我請(qǐng)加QQ好友(646634621),注明添加緣由
● 于 2017-09-20 09:00 ~ 2017-09-23 22:00 在魔都完成
● 文章內(nèi)容來(lái)源于小麥苗的學(xué)習(xí)筆記,部分整理自網(wǎng)絡(luò),若有侵權(quán)或不當(dāng)之處還請(qǐng)諒解
● 版權(quán)所有,歡迎分享本文,轉(zhuǎn)載請(qǐng)保留出處
.............................................................................................................................................
● 小麥苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麥苗出版的數(shù)據(jù)庫(kù)類叢書(shū):http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客戶端掃描下面的二維碼來(lái)關(guān)注小麥苗的微信公眾號(hào)(xiaomaimiaolhr)及QQ群(DBA寶典),學(xué)習(xí)最實(shí)用的數(shù)據(jù)庫(kù)技術(shù)。
小麥苗的微信公眾號(hào) 小麥苗的DBA寶典QQ群1 小麥苗的DBA寶典QQ群2 小麥苗的微店
.............................................................................................................................................
cdn.qqmail.com/zh_CN/htmledition/p_w_picpaths/function/qm_open/ico_mailme_02.png">
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。