[20190212]刪除tab$記錄的恢復3.txt
[20190212]刪除tab$記錄的恢復3.txt
--//春節前幾天做了刪除tan$記錄的測試,連結:
http://blog.itpub.net/267265/viewspace-2565245/=> [20190130]刪除tab$記錄的恢復.txt
http://blog.itpub.net/267265/viewspace-2565250/=> [20190130]刪除tab$記錄的恢復2.txt
--//實際上我一直認為能複製出來資料就ok了.這樣恢復的資料庫不能在使用,問題多多.
--//我繼續測試實際上建表等操作都會報類似的:
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [94232], [6110], [], [], [], [], [], [], [], []
--//這樣的錯誤.主要問題在於system塊的檢查更加嚴格.
--//今天嘗試恢復6110,6111,6112之類的錯誤.
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
--//前面已經恢復只讀狀態exp操作是正常的.具體看前面的文章.
--//首先更正前面指令碼的幾個錯誤:http://blog.itpub.net/267265/viewspace-2565250/=> [20190130]刪除tab$記錄的恢復2.txt
57 echo "x /rx dba $dba *kdbr[$begin]" | rlbbed | egrep "^^flag@.*: *0x7c" > /dev/null
--//原來寫成echo "x /rx dba $dba *kdbr[$begin]" | rlbbed | egrep "^^flag@.*: 0x7c" > /dev/null ,可能出現多個空格的情況.
58 if [ $? -eq 0 ]
59 then
60 echo "dba=$dba;ckix_value=0" >> scan4a.txt
61 fi
$ cat scana.sh
#! /bin/bash
cat clearout.txt | while read dba
do
echo set dba $dba
echo -n "assign "
echo -e "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$"| egrep "ktbbhitl|ktbitflg" | cut -c11-21,55-60 | paste -d. - - | sed -e 's/ /=/'
--//這裡寫錯,原來寫成4204236,實際上應該是$dba,
echo sum apply dba $dba
done
--//注:http://blog.itpub.net/267265/viewspace-2565250/=> [20190130]刪除tab$記錄的恢復2.txt 裡面的指令碼已經更正.
2.我前面做了冷備份.首先恢復冷備份:
$ /bin/cp -r /home/oracle/backup/book_20190122_bad/* /mnt/ramdisk/book/
*/
$ . scan.sh
process 1 start : 2019/02/12 08:45:44 scan dba 1,144 , create scan1.txt about ktetbdba,ktetbnbk
process 1 finish: 2019/02/12 08:45:44,enter continue...
process 2 start : 2019/02/12 08:45:45 scan block , get kdbtnrow,kdbtoffs ang grep kdbtnrow=0
process 2 finish: 2019/02/12 08:46:16,enter continue...
process 3 start : 2019/02/12 08:46:50 scan block , create bbed'script scan3_bbed.txt for modify delete of flag and create scan4a.txt about block of ckix
process 3 finish: 2019/02/12 08:52:01,enter continue...
process 4 start : 2019/02/12 08:52:06 create bbed's scan4_bbed.txt for modify cluster of mref of value
process 4 finish: 2019/02/12 08:53:12,enter continue...
process 5 start : create bbed's scan5_bbed.txt for sum apply
process 5 finish: 2019/02/12 08:54:11,enter continue...
--//檢視生成的bbed指令碼:
$ cat scan4m_bbed.txt
assign dba 4288539 offset 8169 = 1
assign dba 4288546 offset 8145 = 1
--//前面我提到過這2塊dba的不需要恢復(裡面記錄的scn不是這個事務產生的),或者講scan4m_bbed.txt指令碼記錄的dba可能存在多恢復記錄的情況.最好仔細檢查.
$ grep -v 0x6c scan3_bbed.txt
assign /x dba 4194451 offset 7349 = 0x20
assign /x dba 4197642 offset 7888 = 0x20
assign /x dba 4207636 offset 7087 = 0x20
assign /x dba 4225801 offset 3621 = 0x4c
assign /x dba 4225801 offset 4436 = 0x4c
assign /x dba 4288537 offset 7717 = 0x4c
--//這3條記錄存在行連結或者遷移的情況,前面已經解析不再說明.
--//修改scan3_bbed.txt檔案,註解如下2行不需要恢復.
$ grep ^# scan3_bbed.txt
#assign /x dba 4288539 offset 7920 = 0x6c
#assign /x dba 4288546 offset 7851 = 0x6c
$ grep 0x6c scan3_bbed.txt | grep -v "^#" |wc
2963 23704 124395
--//2963+3=2966,這樣恢復的記錄數量與實際情況相符.
3.執行生成的bbed指令碼並修復塊 6110,6111,6112錯誤.
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/scan3_bbed.txt
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/scan4k_bbed.txt
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/scan5_bbed.txt
--//前面提到啟動遇到如下錯誤,主要是因為延遲塊提交的問題:
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [94232], [6110], [], [], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [9951], [6110], [], [], [], [], [], [], [], []
ORA-00600: internal error code, arguments: [kdBlkCheckError], [1], [31548], [6110], [], [], [], [], [], [], [], []
--//編寫指令碼如下,主要獲得延遲塊提交的資料塊,設定提交標識.並且將對應的ktbbhitl[N]._ktbitun._ktbitfsc=0.
--//這樣會導致verify時出現如下錯誤,例子:
BBED> set dba 4204236
DBA 0x004026cc (4204236 1,9932)
BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 9932
Block Checking: DBA = 4204236, Block Type = KTB-managed data block
data header at 0x7fb110a7b25c
kdbchk: space available on commit is incorrect
tosp=5052 fsc=0 stb=0 avsp=4937
Block 9932 failed with check code 6111
--//解決方法就是assign kdbhtosp=kdbhavsp;sum apply就ok了.
--//我以前處理這個錯誤有點繁瑣.實際上設定fsc=0,設定提交標識為快速提交標識0x2,在執行assign kdbhtosp=kdbhavsp,
--//這樣記錄裡面lock標識不需要設定為0x0,這樣簡單許多.
$ cat scanb.sh
#! /bin/bash
# get dba of tailchk ,grep begin # line, save scan6.txt
# and then grep -v 0x5f5f06,save clearout.txt,other save notclearout.txt
grep dba scan3_bbed.txt | grep -v "^#" | cut -d" " -f4 | uniq | while read dba
do
echo -n $dba :
echo "p dba $dba offset 0 tailchk 8188"| rlbbed | grep "ub4 tailchk"
done >| scan6.txt
grep -v 0x5f5f06 scan6.txt >| clearout.txt
grep 0x5f5f06 scan6.txt >| notclearout.txt
# create modify ktbbhitl[N].ktbitflg , ktbbhitl[N]._ktbitun._ktbitfsc=0 and kdbhtosp=kdbhavsp of script.
cat clearout.txt | cut -d" " -f1 |while read dba
do
echo set dba $dba
echo -n "assign "
echo -e "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$"| egrep "ktbbhitl|ktbitflg" | cut -c11-21,55-60 | paste -d. - - | sed -e 's/ /=/'
echo -n "assign "
echo -e "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$" | egrep "ktbbhitl"| cut -c11-21 | sed -e 's/$/._ktbitun._ktbitfsc=0/'
echo "assign kdbhtosp=kdbhavsp"
echo sum apply dba $dba
done >| clearout_bbed.txt
# create modify ktbbhitl[N]._ktbitun._ktbitfsc=0 and kdbhtosp=kdbhavsp of script.
cat notclearout.txt | cut -d" " -f1 |while read dba
do
echo set dba $dba
# echo -n "assign "
# echo -e "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$"| egrep "ktbbhitl|ktbitflg" | cut -c11-21,55-60 | paste -d. - - | sed -e 's/ /=/'
echo -n "assign "
echo -e "set dba $dba \np ktbbh" |rlbbed | /bin/grep -B 4 -A 9 "ub4 kxidsqn \+@.*0x00000751$" | egrep "ktbbhitl"| cut -c11-21 | sed -e 's/$/._ktbitun._ktbitfsc=0/'
echo "assign kdbhtosp=kdbhavsp"
echo sum apply dba $dba
done >| notclearout_bbed.txt
--//執行以上指令碼:
$ . scanb.sh
$ grep "ktbbhitl[1].ktbitflg=" clearout_bbed.txt | grep -v 0x0
$ echo $?
1
--//說明這些塊都沒有打上提交標識.
$ head -5 clearout_bbed.txt
set dba 4204236
assign ktbbhitl[1].ktbitflg=0x0002
assign ktbbhitl[1]._ktbitun._ktbitfsc=0
assign kdbhtosp=kdbhavsp
sum apply dba 4204236
--//使用vim執行:%s/ktbitflg=0x0/ktbitflg=0x2/.也就是設定提交標識.注意檢查替換是否74行.
--//補充說明一下,我前面測試執行的是%s/=0x00/=0x20/,實際上提交標識僅僅佔半個位元組(4位),這樣寫有點問題,不過一般不會出現問題.
--//1塊修改255條以上的情況在這裡不會出現(至少對於這個表是如此).
$ head -5 clearout_bbed.txt
set dba 4204236
assign ktbbhitl[1].ktbitflg=0x2002
assign ktbbhitl[1]._ktbitun._ktbitfsc=0
assign kdbhtosp=kdbhavsp
sum apply dba 4204236
--//執行如下:
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/clearout_bbed.txt
bbed parfile=/home/oracle/bbed/bbed.par cmdfile=/home/oracle/hrp430/bbed/notclearout_bbed.txt
$ dbv file=/mnt/ramdisk/book/system01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Tue Feb 12 10:37:09 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
DBVERIFY - Verification starting : FILE = /mnt/ramdisk/book/system01.dbf
DBVERIFY - Verification complete
Total Pages Examined : 97280
Total Pages Processed (Data) : 64316
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 13442
Total Pages Failing (Index): 0
Total Pages Processed (Other): 4185
Total Pages Processed (Seg) : 1
Total Pages Failing (Seg) : 0
Total Pages Empty : 15337
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 393502590 (3.393502590)
--//現在OK了.
4.禁用sys.tab$的索引I_TAB1.
--//這樣恢復,索引與表存在不一致情況,要禁用sys.tab$的索引I_TAB1.
BBED> x /rnnc dba 1,523 *kdbr[9]
rowdata[1269] @4910
-------------
flag@4910: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@4911: 0x01
cols@4912: 3
col 0[2] @4913: 33
col 1[2] @4916: 33
col 2[189] @4919: CREATE INDEX I_TAB1 ON TAB$(BOBJ#) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 64K NEXT 1024K MINEXTENTS 1 MAXEXTENTS 2147483
645 PCTINCREASE 0 OBJNO 33 EXTENTS (FILE 1 BLOCK 312))
--//設定flag=3c,表示刪除.
BBED> assign /x dba 1,523 offset 4910= 0x3c
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 rowdata[0] @4910 0x3c
BBED> sum apply dba 1,523
Check value for File 1, Block 523:
current = 0x7e6b, required = 0x7e6b
BBED> verify dba 1,523
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 523
Block Checking: DBA = 4194827, Block Type = KTB-managed data block
data header at 0x6eee44
kdbchk: the amount of space used is not equal to block size
used=4398 fsc=0 avsp=3525 dtl=8120
Block 523 failed with check code 6110
--//先不理會這個錯誤.
5.啟動資料庫看看:
SYS@book> startup pfile='/tmp/@.ora';
ORACLE instance started.
Total System Global Area 643084288 bytes
Fixed Size 2255872 bytes
Variable Size 205521920 bytes
Database Buffers 427819008 bytes
Redo Buffers 7487488 bytes
Database mounted.
Database opened.
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@book> startup open read only pfile='/tmp/book.ora'
ORACLE instance started.
Total System Global Area 643084288 bytes
Fixed Size 2255872 bytes
Variable Size 205521920 bytes
Database Buffers 427819008 bytes
Redo Buffers 7487488 bytes
Database mounted.
Database opened.
--//注/tmp/book.ora最好加入修改如下:
*._system_trig_enabled=false
*.job_queue_processes=0
SYS@book> select * from sys.tab$ minus select * from orachk001;
no rows selected
SYS@book> select * from orachk001 minus select * from sys.tab$;
no rows selected
--//OK,幾乎完美恢復.我執行如下select * from sh.sales;,順利讀出,沒有任何問題.
--//現在建立刪除表沒有任何問題.
SCOTT@book> create table t as select * from all_objects;
Table created.
SCOTT@book> drop table t purge ;
Table dropped.
6.剩下恢復tab$.索引I_TAB1,寫得有點長.另寫一篇修復索引的帖子,感覺這步很難,也許要先放一放.
--//最後說明一點,我的是測試環境,也許真實的環境更加複雜.我可能還遺漏一些細節...^_^.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2629866/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20190130]刪除tab$記錄的恢復.txt
- [20190225]刪除tab$記錄的恢復5.txt
- [20190130]刪除tab$記錄的恢復2.txt
- [20220909]bbed關於刪除記錄恢復的問題.txt
- oracle使用小記、刪除恢復Oracle
- 刪除的微信聊天記錄怎麼恢復?(已解決)
- hbase 恢復 誤刪除
- NTFS刪除及恢復
- Git恢復被刪除的分支Git
- Git恢復刪除的檔案Git
- 華為、榮耀手機微信聊天記錄刪除怎麼恢復
- 行動硬碟刪除的檔案能恢復嗎,怎麼恢復硬碟刪除的檔案硬碟
- docker筆記40-ceph osd誤刪除恢復Docker筆記
- 如何恢復被刪除的 GitLab 專案?Gitlab
- MySQL 如何重建/恢復刪除的 sys SchemaMySql
- Shift + Delete刪除的檔案如何恢復?delete
- [20210803]刪除user$的恢復準備.txt
- [20210930]bbed恢復刪除的資料.txt
- sd卡刪除的檔案如何恢復SD卡
- extundelete工具恢復rm -rf 刪除的目錄(ext4、ext3)delete
- Oracle 檔案意外刪除恢復(Linux)OracleLinux
- 【北亞資料恢復】誤刪除oracle表和誤刪除oracle表資料的資料恢復方法資料恢復Oracle
- 微信互刪好友聊天記錄還能恢復嗎
- 如何使用 testdisk 恢復已刪除的檔案
- 在LVM中恢復已刪除的物理卷LVM
- 相機sd卡刪除的照片如何恢復SD卡
- U盤的東西刪除了怎麼恢復,怎麼恢復U盤刪除的檔案
- 【NetApp資料恢復案例】針對NetApp誤刪除資料的恢復APP資料恢復
- 刪除重複id的記錄
- 電話號碼刪除了怎麼恢復?通訊錄刪除的號碼怎麼找回
- sd卡中的資料夾刪除了怎麼恢復,SD卡刪除的檔案如何恢復SD卡
- 微信聊天記錄的恢復
- google書籤刪除了怎麼恢復?谷歌瀏覽器刪除的書籤怎麼恢復?Go谷歌瀏覽器
- 【儲存資料恢復】NetApp儲存誤刪除的資料恢復案例資料恢復APP
- iPhone刪除的照片能恢復嗎?蘋果手機照片怎麼恢復iPhone蘋果
- 電腦裡刪除的檔案怎麼恢復,資料恢復方法大全資料恢復
- 【儲存資料恢復案例】Netapp誤操作刪除lun的資料恢復資料恢復APP
- 回收站刪除的檔案怎麼恢復?