​[20231023]生成bbed的執行指令碼(bash shell).txt

lfree發表於2023-11-05

[20231023]生成bbed的執行指令碼(bash shell).txt

--//嘗試使用bbed 恢復rename IDL_UB1$的情況,前面的準備分析時間很長,恢復很容易。但是每次做修復資料塊的一致性時,我總是還要
--//查詢我以前寫的檔案,特別浪費時間記不住一些細節。實際上主要寫計算公式上,我想既然已經給出提示資訊。透過外部命令計算很
--//容易生成bbed的執行指令碼,自己嘗試看看。

--//bbed執行verify後出現6110,6111錯誤,簡單更正公式如下:
--//code 6110
--//avsp = dtl-used-fsc
--//code 6111
--//tosp = avsp+stb+fsc

--//code=6110的情況:
BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 243

Block Checking: DBA = 4194547, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: the amount of space used is not equal to block size
        used=7298 fsc=66 avsp=822 dtl=8120
Block 243 failed with check code 6110

--//avsp = dtl-used-fsc
--//avsp= 8120-7298-66 = 756
--//補充建議:我看有一些選擇設定fsc=0,方法就是要修改對應事務itl的fsc值,要看行記錄的lock,才知道那個事務的ITL。
--//這樣可能avsp不需要修改。比如修改成如下:
used=7298 fsc=0 avsp=822 dtl=8120
--//dtl-used-fsc 8120-7298-0 = 822.

BBED> assign kdbh.kdbhavsp=756
sb2 kdbhavsp                                @78       756

--//code=6111的情況:
BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/system01.dbf
BLOCK = 243

Block Checking: DBA = 4194547, Block Type = KTB-managed data block
data header at 0x8ec644
kdbchk: space available on commit is incorrect
        tosp=890 fsc=66 stb=0 avsp=756
Block 243 failed with check code 6111

--//tosp = avsp+stb+fsc
--//tosp= 756+0+66  = 822
BBED> assign kdbh.kdbhtosp=822
sb2 kdbhtosp                                @80       822

--//建立指令碼如下:
$ cat bbed1011.sh
#! /bin/bash
# create bbed script ,resolve code 6110 and 6111
# argument1=dba
a=$1
echo verify dba $a| rlbbed | grep "code 6110" > /dev/null
if [ $? -eq 0 ] ; then
#    echo verify dba $a | rlbbed | tr -d '\r' | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/;dtl-used-fsc/"| bc -q | sed "s/^/ assign dba $a kdbh.kdbhavsp = /"
echo verify dba $a | rlbbed | tr -d '\r' | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/;dtl-used-fsc/" | bc -q | sed "s/^/ assign dba $a kdbh.kdbhavsp = /"
fi
echo verify dba $a| rlbbed | grep "code 6111" > /dev/null
if [ $? -eq 0 ] ; then
    echo verify dba $a | rlbbed | tr -d '\r' | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/;avsp+stb+fsc/"| bc -q | sed "s/^/assign dba $a kdbh.kdbhtosp = /"
fi

--//感覺不需要呼叫這麼多次bbed,再引入1個引數輸出code程式碼,修改如下:
$ cat bbed1011x.sh
#! /bin/bash
# create bbed script ,resolve code 6110 and 6111
# argument1=dba argument2=bbed code
# if [$2 -eq 6110  ] ; then
#     str1=";dtl-used-fsc"
#     str2="kdbh.kdbhavsp"
# fi
# if [$2 -eq 6110  ] ; then
#     str1=";avsp+stb+fsc"
#     str2="kdbh.kdbhtosp"
# fi

a=$1
case $2 in
    6110|10)
        str1=";dtl-used-fsc"
        str2="kdbh.kdbhavsp"
        str3=6110
        ;;
    6111|11)
        str1=";avsp+stb+fsc"
        str2="kdbh.kdbhtosp"
        str3=6111
        ;;
esac

echo verify dba $a| rlbbed | tr -d '\r' | grep -B1 "code ${str3}$" | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/${str1}/"| bc -q | sed "s/^/assign dba $a $str2 = /"
#echo verify dba $a | rlbbed | grep -B1 "code ${str3}$" | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/${str1}/"| bc -q | sed "s/^/ assign dba $a $str2 = /"
#echo verify dba $a| rlbbed | grep -B1 "code 6110$" | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/;dtl-used-fsc/"| bc -q | sed "s/^/ assign dba $a kdbh.kdbhavsp = /"
#echo verify dba $a| rlbbed | grep -B1 "code 6111$" | grep "avsp" | sed -e "s/^\s*//;s/ /;/g;s/$/;avsp+stb+fsc/"| bc -q | sed "s/^/ assign dba $a kdbh.kdbhtosp = /"

--//測試在cygwin ,過濾出來的內容有1個\r字元,要刪除掉.
--//測試看看:

1.環境:
SCOTT@test01p> @ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

SCOTT@test01p> create table deptx as select * from dept;
Table created.

SCOTT@test01p> select rowid,deptx.* from deptx where rownum=1;
ROWID                  DEPTNO DNAME                LOC
------------------ ---------- -------------------- -------------
AAAHZ8AALAAABLTAAA         10 ACCOUNTING           NEW YORK

SCOTT@test01p> @ rowid AAAHZ8AALAAABLTAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     30332         11       4819          0  0x2C012D3           11,4819              alter system dump datafile 11 block 4819

SCOTT@test01p> delete from deptx where deptno = 10;
1 row deleted.

SCOTT@test01p> commit ;
Commit complete.

SCOTT@test01p> alter system checkpoint;
System altered.

2.嘗試恢復看看:

BBED> x /rncc dba 11,4820 *kdbr[0]
rowdata[66]                                 @8162
-----------
flag@8162: 0x3c (KDRHFL, KDRHFF, KDRHFD, KDRHFH)
lock@8163: 0x02
cols@8164:    0

BBED> assign dba 11,4820 offset 8162=0x2c;
ub1 rowdata[0]                              @8162     0x2c

BBED> x /rncc dba 11,4820 *kdbr[0]
rowdata[66]                                 @8162
-----------
flag@8162: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8163: 0x02
cols@8164:    3

col    0[2] @8165: 10
col   1[10] @8168: ACCOUNTING
col    2[8] @8179: NEW YORK

BBED> sum apply dba 11,4820
Check value for File 11, Block 4820:
current = 0x1c09, required = 0x1c09

BBED> verify dba 11,4820
DBVERIFY - Verification starting
FILE = D:\APP\ORACLE\ORADATA\TEST\TEST01P\USERS01.DBF
BLOCK = 4819

Block Checking: DBA = 46142163, Block Type = KTB-managed data block
data header at 0x2b7027c
kdbchk: the amount of space used is not equal to block size
        used=118 fsc=24 avsp=7946 dtl=8064
--// assign kdbh.kdbhavsp = 7922
Block 4819 failed with check code 6110

DBVERIFY - Verification complete


$ ./bbed1011.sh 11,4820 6110 ; ./bbed1011x.sh 11,4820 6110
assign dba 11,4820 kdbh.kdbhavsp = 7922
assign dba 11,4820 kdbh.kdbhavsp = 7922
--//ok!!

BBED> assign dba 11,4820 kdbh.kdbhavsp = 7922
b2 kdbhavsp                                 @134      7922

BBED> sum apply dba 11,4820
Check value for File 11, Block 4820:
current = 0x1df1, required = 0x1df1

BBED> verify dba 11,4820
DBVERIFY - Verification starting
FILE = D:\APP\ORACLE\ORADATA\TEST\TEST01P\USERS01.DBF
BLOCK = 4819

Block Checking: DBA = 46142163, Block Type = KTB-managed data block
data header at 0x2b7027c
kdbchk: space available on commit is incorrect
        tosp=7972 fsc=24 stb=0 avsp=7922
--// assign kdbh.kdbhtosp = 7946
Block 4819 failed with check code 6111
DBVERIFY - Verification complete

$ ./bbed1011.sh 11,4820 6110 ; ./bbed1011x.sh 11,4820 6111
assign dba 11,4820 kdbh.kdbhtosp = 7946
assign dba 11,4820 kdbh.kdbhtosp = 7946

BBED> assign dba 11,4820 kdbh.kdbhtosp = 7946
b2 kdbhtosp                                 @136      7946

BBED> sum apply dba 11,4820
Check value for File 11, Block 4820:
current = 0x1ddf, required = 0x1ddf

BBED> verify dba 11,4820
DBVERIFY - Verification starting
FILE = D:\APP\ORACLE\ORADATA\TEST\TEST01P\USERS01.DBF
BLOCK = 4819
DBVERIFY - Verification complete

--//OK!修復完成.

SCOTT@test01p> alter system flush BUFFER_CACHE;
System altered.

SCOTT@test01p> select rowid,deptx.* from deptx ;
ROWID                  DEPTNO DNAME                LOC
------------------ ---------- -------------------- -------------
AAAHZ8AALAAABLTAAA         10 ACCOUNTING           NEW YORK
AAAHZ8AALAAABLTAAB         20 RESEARCH             DALLAS
AAAHZ8AALAAABLTAAC         30 SALES                CHICAGO
AAAHZ8AALAAABLTAAD         40 OPERATIONS           BOSTON

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2992943/,如需轉載,請註明出處,否則將追究法律責任。

相關文章