最近bbed的讨论相对比较多,可能因为是底层的东西,使很多想深入的oracler对它越来越感兴趣。在此我也分享下我的心得。此后会经常发些实验与大家共享。
BBED -oracle数据坏块修复工具
在9i/10g中连接生成bbed:
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
以上生成的bbed可执行文件在$ORACLE_HOME/rdbms/lib目录,可以复制到其他位置或者其他同Oracle版本的机器上运行。也可通过以下命令将bbed生成到$ORACLE_HOME/bin目录
make -f ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbed
在11g中生成bbed,需要先从10g中复制如下文件到相应目录,然后再执行上述连接命令:
$ORACLE_HOME/rdbms/lib/ssbbded.o
$ORACLE_HOME/rdbms/lib/sbbdpt.o
$ORACLE_HOME/rdbms/mesg/bbedus.msb
BBED设置了口令保护,密码为blockedit。
BBED设置了口令保护,密码为blockedit。
BBED的命令行参数:
$bbed help=yes
PASSWORD – Required parameter
FILENAME – Database file name
BLOCKSIZE – Database block size
LISTFILE – List file name
MODE – [browse/edit]
SPOOL – Spool to logfile [no/yes]
CMDFILE – BBED command file name
LOGFILE – BBED log file name
PARFILE – Parameter file name
BIFILE – BBED before-image file name
REVERT – Rollback changes from BIFILE [no/yes]
SILENT – Hide banner [no/yes]
HELP – Show all valid parameters [no/yes]一般将一些常用选项写入到一个parfile中:
blocksize=8192
listfile=filelist.txt
mode=edit其中filelist.txt列出了需要使用BBED编辑的数据文件列表,格式为
文件编号 文件名字 文件大小
1 /u01/oracle/oradata/NinGoo/system.dbf 2097160192
2 /u01/oracle/oradata/NinGoo/test.dbf 2097160192这里的文件编号不一定要和数据库里的file_id相同,当然最好能设置相同,以免在处理过程中搞混淆了。
$bbed parfile=bbed.par
Password:
BBED: Release 2.0.0.0.0 – Limited Production on Sun Nov 15 00:26:14 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> help
HELP [| ALL ]
[oracle@lyn bbed]$ ls
filelist.txt log.bbd par.bbd
[oracle@lyn bbed]$ cat par.bbd
blocksize=8192
listfile=filelist.txt
logfile=log.bbd
mode=edit
[oracle@lyn bbed]$ cat filelist.txt
7 /u01/test/testxh.dbf
passwd:blockedit
######################
bbed 使用介绍
BBED> help
HELP [ | ALL ]
BBED> help all
SET DBA [ dba | file#, block# ]
SET FILENAME ‘filename’
SET FILE file#
SET BLOCK [+/-]block#
SET OFFSET [ [+/-]byte offset | symbol | *symbol ]
SET BLOCKSIZE bytes
SET LIST[FILE] ‘filename’
SET WIDTH character_count
SET COUNT bytes_to_display
SET IBASE [ HEX | OCT | DEC ]
SET OBASE [ HEX | OCT | DEC ]
SET MODE [ BROWSE | EDIT ]
SET SPOOL [ Y | N ]
SHOW [ | ALL ]
INFO
MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]
DUMP[/v] [ DBA | FILENAME | FILE | BLOCK | OFFSET | COUNT ]
PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
:
N – a number which specifies a repeat count.
u – a letter which specifies a unit size:
b – b1, ub1 (byte)
h – b2, ub2 (half-word)
w – b4, ub4(word)
r – Oracle table/index row
f – a letter which specifies a display format:
x – hexadecimal
d – decimal
u – unsigned decimal
o – octal
c – character (native)
n – Oracle number
t – Oracle date
i – Oracle rowid
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
MODIFY[/x|d|u|o|c] numeric/character string
[ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
ASSIGN[/x|d|u|o] =
: [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
: [ value | ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]
POP [ALL]
REVERT [ DBA | FILE | FILENAME | BLOCK ]
UNDO
HELP [ | ALL ]
VERIFY [ DBA | FILE | FILENAME | BLOCK ]
CORRUPT [ DBA | FILE | FILENAME | BLOCK ]
常用set选项
blocksize: standard blocksize in bytes of datafiles to edit,块大小
mode:mode to run bbed in (browse or edit) 是否可以修改,默认是不行的
listfile:bbed中文件列表
logfile:日志文件,默认是log.bbd
parfile: parameter file with above options listed
set dba
set data block address
set filename
set file (file#)
set offset 块中位置偏移量
set count
sets the number of bytes the data block to display from the dump command
default is 512
info 列出当前文件信息
map(显示当前块信息,/v显示的更多点)
: the map command shows a map of the current block,it can be combined with the /v optinon to produce a more verbose output
dump:
dump参数 dump /v看的多些
BBED> dump /v dba 10, 32 offset 8187 count 64
File: /u01/test/block_test.dbf (10)
Block: 32 Offsets: 8187 to 8191 Dba:0×02800020
——————————————————-
630406be 52 l c..綬
BBED> p 8187
rowdata[15]
———–
ub1 rowdata[15] @8187 0×63
BBED> dump /v
File: /u01/test/block_test.dbf (10)
Block: 32 Offsets: 8187 to 8191 Dba:0×02800020
——————————————————-
630406be 52 l c..綬
dump /v dba 10,32 offset 0 count 128
print:
the pring command allows data structures to be printed in raw or formatted output
BBED> p kdbh
struct kdbh, 14 bytes @100
ub1 kdbhflag @100 0×00 (NONE)
b1 kdbhntab @101 1
b2 kdbhnrow @102 2
sb2 kdbhfrre @104 -1
sb2 kdbhfsbo @106 22
sb2 kdbhfseo @108 8076
b2 kdbhavsp @110 8048
b2 kdbhtosp @112 8048
BBED> p kdbhntab
b1 kdbhntab @101 1
BBED> p kdbh.kdbhntab
b1 kdbhntab @101 1
in addition to printing information about
the specified data structure,the print command can also
be used to print information about the location the data
structure points to by using the pointer(*) prefix
######################可以看到有2行数据
BBED> p kdbr
sb2 kdbr[0] @118 8082 *********第1行数据
sb2 kdbr[1] @120 8076
BBED> p kdbr[0]
sb2 kdbr[0] @118 8082 ***********这是一个相对位置
我们例子中要20(cache layer)+24(事务层固定部分)+24*2(itl部分 N*24)+8=100,这行的绝对位置在8082+100=8182中
########################用处比较大,直接找到行数据的位置
BBED> p rowdata
ub1 rowdata[0] @8176 0x2c
ub1 rowdata[1] @8177 0×02
ub1 rowdata[2] @8178 0×01
ub1 rowdata[3] @8179 0×02
ub1 rowdata[4] @8180 0xc1
ub1 rowdata[5] @8181 0×03
ub1 rowdata[6] @8182 0x2c
ub1 rowdata[7] @8183 0×00
ub1 rowdata[8] @8184 0×01
ub1 rowdata[9] @8185 0×02
ub1 rowdata[10] @8186 0xc1
ub1 rowdata[11] @8187 0×02
BBED> p *kdbr[0]
rowdata[6]
———-
ub1 rowdata[6] @8182 0x2c
BBED>
BBED> d /v offset 8182
File: /u01/test/block_test.dbf (10)
Block: 44 Offsets: 8182 to 8191 Dba:0x0280002c
——————————————————-
2c000102 c1020106 80cc l ,…?…?
BBED> p offset 8182
rowdata[6]
———-
ub1 rowdata[6] @8182 0x2c
print默认显示 16 进制
/x 16 进制
/d signed decimal 10进制
/u unsigned decimal 10进制
/o octal 8进制
/c character 字符类
/n oracle number oracle数值
/t oracle date oracle时间
/i oracle rowid oracle rowid
我们测试表 值为数字
SQL> select file#,block#,name from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,name from tr2);
FILE# BLOCK# NAME
———- ———- ——————–
10 52 xh
10 52 hr
BBED> set block 52
BLOCK# 52
BBED> p kdbr
sb2 kdbr[0] @118 8082
sb2 kdbr[1] @120 8076
BBED> p rowdata
ub1 rowdata[0] @8176 0x2c
ub1 rowdata[1] @8177 0×01
ub1 rowdata[2] @8178 0×01
ub1 rowdata[3] @8179 0×02
ub1 rowdata[4] @8180 0×68
ub1 rowdata[5] @8181 0×72
ub1 rowdata[6] @8182 0x2c
ub1 rowdata[7] @8183 0×01
ub1 rowdata[8] @8184 0×01
ub1 rowdata[9] @8185 0×02
ub1 rowdata[10] @8186 0×78
ub1 rowdata[11] @8187 0×68
BBED> p kdbr[0]
sb2 kdbr[0] @118 8082
BBED> p *kdbr[0]
rowdata[6]
———-
ub1 rowdata[6] @8182 0x2c
BBED>
BBED>
BBED>
BBED> dump /v
File: /u01/test/block_test.dbf (10)
Block: 52 Offsets: 8182 to 8191 Dba:0×02800034
——————————————————-
2c010102 78680406 4cd3 l ,…xh..L?
8182 开始 8182=2c(记录头标志), 8183=itl index=01(itl slot号) ,8184=01(字段数量,1列),8185=02字段长度(这里表示字段有2个字节,即8186,8187)
BBED> p /c offset 8187
rowdata[11]
———–
ub1 rowdata[11] @8187 h
BBED> p /c offset 8186
rowdata[10]
———–
ub1 rowdata[10] @8186 x
BBED> find /c xh
File: /u01/test/block_test.dbf (10)
Block: 52 Offsets: 8186 to 8191 Dba:0×02800034
————————————————————————
78680406 4cd3
e(x)amine
the examine command is used to display data from the block in raw or formatted output
unlike the print command it cannot interpret data structures
but it can be used to display row information combined with know ledge of data type of the row,it can be used to retrieve complete rows from the block
/b b1,ub1(type)
/h b2,ub2(half-word)
/w b4,ub4(word)
/l b8,ub8(long)(was b4/ub4 in oracle 7)
/r oracle table /index row
BBED> p *kdbr[0]
rowdata[6]
———-
ub1 rowdata[6] @8182 0x2c
############### /r就是oracle table index, c就是char
BBED> x /rcnn
rowdata[6] @8182
———-
flag@8182: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8183: 0×01
cols@8184: 1
col 0[2] @8185: xh
从上面可以看出各个结构非常清晰,flag 2c=8182,lock 01=8183,clos 1=8184,col [2]=8185(记录是2字节),后面8186,8187位置就是值
这里面lock 就是使用哪个itl solt
#######################按16进制列出来
BBED> x /rxnn
rowdata[6] @8182
———-
flag@8182: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8183: 0×01
cols@8184: 1
col 0[2] @8185: 0×78 0×68
BBED> x /bxnn
rowdata[6] @8182
———-
0x2c
BBED> x /hxnn
rowdata[6] @8182
———-
0x012c
BBED> x /wxnn
rowdata[6] @8182
———-
0x0201012c
上面这个在数据文件里写就是2c010102
BBED> x /lxnn
rowdata[6] @8182
———-
0x0201012c
SQL> select file#,block#,name from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,name from tr2);
FILE# BLOCK# NAME
———- ———- ——————–
10 52 xh
10 52 hr
10 52 dd
BBED> p kdbr
sb2 kdbr[0] @118 8082
sb2 kdbr[1] @120 8076
sb2 kdbr[2] @122 8070
BBED> p *kdbr[0]
rowdata[12]
———–
ub1 rowdata[12] @8182 0x2c
BBED> x /rcnn
rowdata[12] @8182
———–
flag@8182: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8183: 0×01
cols@8184: 1
col 0[2] @8185: xh
BBED> x /2rcnn
rowdata[12] @8182
———–
flag@8182: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8183: 0×01
cols@8184: 1
col 0[2] @8185: xh
tailchk @8188
——-
BBED-00210: no row at this offset
#########上面问题错误很好理解,
数据块中的数据是从底向上增长的(这就表示,第一行就是尾部分) ,所以 3x 这样的显示n行 是代表,显示该行 之上的 3 行(包含该行),第1行,上面没有行了所以报告错了
BBED> p *kdbr[2] *************第3行
rowdata[0]
———-
ub1 rowdata[0] @8170 0x2c
BBED> x /3rcnn
rowdata[0] @8170
———-
flag@8170: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8171: 0×02
cols@8172: 1
col 0[2] @8173: dd *************************************第3行值
rowdata[6] @8176
———-
flag@8176: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8177: 0×01
cols@8178: 1
col 0[2] @8179: hr *********************************第2行值
rowdata[12] @8182
———–
flag@8182: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8183: 0×01
cols@8184: 1
col 0[2] @8185: xh **************************第1行值
SQL> select file#,block#,a,b from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a,b from t3);
FILE# BLOCK# A B
———- ———- ——— ———-
10 60 05-AUG-11 xh
BBED> p kdbr
sb2 kdbr[0] @118 8074
BBED> p *kdbr[0]
rowdata[0]
———-
ub1 rowdata[0] @8174 0x2c
#######################################################可以混合使用tc,但顺序要对
BBED> x /rtcnnn
rowdata[0] @8174
———-
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0×01
cols@8176: 2
col 0[7] @8177: 05-AUG-11
col 1[2] @8185: xh
BBED> x /rctnnn
rowdata[0] @8174
———-
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0×01
cols@8176: 2
col 0[7] @8177: xo…:0
col 1[2] @8185: 0×78 0×68 *******************************回到16进制(如果完全无法转换将转为16进制)
########只有1列的类型,就会有下面的问题
BBED> x /rcnnn
rowdata[0] @8174
———-
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0×01
cols@8176: 2
col 0[7] @8177: xo…:0
col 1[2] @8185: -0
BBED> x /rtnnn
rowdata[0] @8174
———-
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0×01
cols@8176: 2
col 0[7] @8177: 05-AUG-11
col 1[2] @8185: -0
***********************************************每列需要对应一个类型,否则都为-0
BBED> x /rxnnn
rowdata[0] @8174
———-
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0×01
cols@8176: 2
col 0[7] @8177: 0×78 0x6f 0×08 0×05 0x0f 0x3a 0×30
col 1[2] @8185: -0
#2列都给输出类型
BBED> x /rccnnn
rowdata[0] @8174
———-
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0×01
cols@8176: 2
col 0[7] @8177: xo…:0 ***********
col 1[2] @8185: xh ***********
find :
the find command is used to locate data within a block,
the command allows hex,string or numeric data
to be searched for.
the pattern can be searched for from the top of the block (offset 0)
using the top directive ,or from the current position using the curr directive
/x hex
/d decimal 10
/u unsigned decimal
/o Octal
/c character(native) 字符
这里要注意number and date不支持find命令
BBED> find /c xh
File: /u01/test/block_test.dbf (10)
Block: 60 Offsets: 8186 to 8191 Dba:0x0280003c
————————————————————————
78680306 2ed8
File: /u01/test/block_test.dbf (10)
Block: 60 Offsets: 8186 to 8191 Dba:0x0280003c
————————————————————————
78680306 2ed8
78=x 68=h
SQL> select chr(to_number(68,’xx’)) from dual;
CH
–
h
SQL> select chr(to_number(78,’xx’)) from dual;
CH
–
x
BBED> find /x 68 curr
File: /u01/test/block_test.dbf (10)
Block: 60 Offsets: 8187 to 8191 Dba:0x0280003c
————————————————————————
6803062e d8
BBED>
copy:
the copy command is used to copy blocks from one location to another ,
as with other commands ,the file or filename and offset can be specified,or the dba can be specified instead
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr);
FILE# BLOCK# A
———- ———- ———-
10 44 1
10 44 2
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3);
FILE# BLOCK# A
———- ———- ———-
10 68 3
BBED> copy dba 10,44 to dba 10,68
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 0 to 511 Dba:0×02800044
————————————————————————
06a20000 2c008002 80cc3500 00000104 11ef0000 01000000 b0dc0000 80cc3500
00000000 02003200 29008002 06001d00 e7050000 a6578000 1b041600 00800000
33cc3500 09002d00 16060000 ee008000 13031000 00800000 00000000 00000000
00000000 00010200 ffff1600 8c1f701f 701f0000 0200921f 8c1f6f0c ae07ffff
ffff0000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 6c000800 06c5083b 191f1407 786f0803 18042801 8005c404
331f1b02 c164fea4 04cede31 2db37335 0000005c 2fd1de31 2db47335 00000000
00d4de31 2db57335 00000000 00d7de31 2db67335 000000de bfdade31 2db77335
000000e7 0cddde31 2db87335 00000007 00f9de31 2db97335 00000000 00fcde31
2dba7335 00000000 00ffde31 2dbb7335 000000de bf02df31 2dbc7335 00000000
0005df31 2dbd7335 000000d4 0808df31 2dbe7335 000000de bf0bdf31 2dbf7335
00000000 000edf31 2dc07335 00000000 0011df31 2dc17335 000000e7 0c14df31
2dc27335 000000e7 0c17df31 2dc37335 00000041 081adf31 2dc47335 00000000
003edf31 2dc57335 000000e7 0c41df31 2dc67335 000000f1 3044df31 2dc77335
00000000 0047df31 2dc87335 0000004d 664adf31 2dc97335 000000de bf4ddf31
BBED> verify
DBVERIFY – Verification starting
FILE = /u01/test/block_test.dbf
BLOCK = 68
Block 68 is corrupt
Corrupt block relative dba: 0×02800044 (file 0, block 68)
Bad header found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x0280002c
last change scn: 0×0000.0035cc80 seq: 0×1 flg: 0×04
spare1: 0×0 spare2: 0×0 spare3: 0×0
consistency value in tail: 0xcc800601
check value in block header: 0xef11
computed block checksum: 0×0
DBVERIFY – Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
BBED> sum apply
Check value for File 10, Block 68:
current = 0xef11, required = 0xef11
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3);
select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3)
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 10, block # 68)
ORA-01110: data file 10: ‘/u01/test/block_test.dbf’
BBED> set block 68
BLOCK# 68
BBED> p kdbr
sb2 kdbr[0] @118 8082
sb2 kdbr[1] @120 8076
BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0×06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0×00
ub1 spare2_kcbh @3 0×00
ub4 rdba_kcbh @4 0x0280002c
ub4 bas_kcbh @8 0x0035cc80
ub2 wrp_kcbh @12 0×0000
ub1 seq_kcbh @14 0×01
ub1 flg_kcbh @15 0×04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xef11
ub2 spare3_kcbh @18 0×0000
Block 68 is corrupt
Corrupt block relative dba: 0×02800044 (file 0, block 68)
Bad header found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x0280002c
last change scn: 0×0000.0035cc80 seq: 0×1 flg: 0×04
spare1: 0×0 spare2: 0×0 spare3: 0×0
consistency value in tail: 0xcc800601
check value in block header: 0xef11
computed block checksum: 0×0
BBED> p kcbh.rdba_kcbh
ub4 rdba_kcbh @4 0x0280002c
相对offset 4,那么rdba是从5开始的4个字节
BBED> dump /v offset 4 count 16
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 4 to 19 Dba:0×02800044
——————————————————-
2c008002 80cc3500 00000104 11ef0000 l ,….?……?..
0x0280002c
0×02800044 那么写到disk里就是 44008002
BBED> modify /x 44008002 offset 4
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 4 to 19 Dba:0×02800044
————————————————————————
44008002 80cc3500 00000104 11ef0000
BBED> p kcbh.rdba_kcbh
ub4 rdba_kcbh @4 0×02800044
BBED> verify
DBVERIFY – Verification starting
FILE = /u01/test/block_test.dbf
BLOCK = 68
Block 68 is corrupt
Corrupt block relative dba: 0×02800044 (file 0, block 68)
Bad check value found during verification
Data in bad block:
type: 6 format: 2 rdba: 0×02800044
last change scn: 0×0000.0035cc80 seq: 0×1 flg: 0×04
spare1: 0×0 spare2: 0×0 spare3: 0×0
consistency value in tail: 0xcc800601
check value in block header: 0xef11
computed block checksum: 0×68
DBVERIFY – Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
BBED> sum apply
Check value for File 10, Block 68:
current = 0xef79, required = 0xef79
BBED> verify
DBVERIFY – Verification starting
FILE = /u01/test/block_test.dbf
BLOCK = 68
Block Checking: DBA = 41943108, Block Type = KTB-managed data block
data header at 0×254264
kdbchk: row locked by non-existent transaction
table=0 slot=1
lockid=2 ktbbhitc=2
Block 68 failed with check code 6101
DBVERIFY – Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing (Data) : 1
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 0
Total Blocks Influx : 0
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3);
select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3)
*
ERROR at line 1:
ORA-01410: invalid ROWID
BBED> set block 44
BLOCK# 44
BBED> p ktbbh.ktbbhsid
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000dcb0
ub4 ktbbhod1 @24 0x0000dcb0
BBED> set block 68
BLOCK# 68
BBED> p ktbbh.ktbbhsid
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000dcb0
ub4 ktbbhod1 @24 0x0000dcb0
BBED> dump /v offset 24 count 16
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
——————————————————-
b0dc0000 80cc3500 00000000 02003200 l 败…?…….2.
SQL> select obj# from obj$ where name=’TR’;
OBJ#
———-
56496
SQL> select obj# from obj$ where name=’TR3′;
OBJ#
———-
56499
SQL> select to_number(‘dcb0′,’xxxxxxxx’) from dual;
TO_NUMBER(‘DCB0′,’XXXXXXXX’)
—————————-
56496
BBED> modify /u 56499 offset 24
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
dcb30000 80cc3500 00000000 02003200
BBED> p ktbbh.ktbbhsid
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000b3dc
ub4 ktbbhod1 @24 0x0000b3dc
SQL> select to_number(‘dcb3′,’xxxxxxxx’) from dual;
TO_NUMBER(‘DCB3′,’XXXXXXXX’)
—————————-
56499
SQL> select to_number(‘b3dc’,'xxxxxxxx’) from dual;
TO_NUMBER(‘B3DC’,'XXXXXXXX’)
—————————-
46044
BBED> modify /x b3dc offset 24
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 33 Dba:0×02800044
————————————————————————
b3dc0000 80cc3500 0000
BBED> sum apply
Check value for File 10, Block 68:
current = 0xef7a, required = 0xef7a
BBED> p ktbbh.ktbbhsid
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000dcb3
ub4 ktbbhod1 @24 0x0000dcb3
System altered.
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from xh.tr3);
FILE# BLOCK# A
———- ———- ———-
10 68 1
10 68 2
assign:
the assign command does symbolic assignment,with type and
range checking,either target or source can be omitted for the current offset
assign dba 10,68 ktbbhitl[0]
sum
the sum command is used to check and set block checksum ,the dba filename ,file,block and or
offset to check can be specified with the command,if these are not specified the current file,block and offset
as established with the set command will be checked
BBED> sum dba 10,68
Check value for File 10, Block 68:
current = 0xef7a, required = 0xef7a
##修改过块后要重新计算,否则报错,与参数db_block_checksum 有关
BBED> sum dba 10,68 apply
Check value for File 10, Block 68:
current = 0xef7a, required = 0xef7a
push/pop
the push and pop commands are uesd to push a file,block and offset location onto a memory backed stack and
then pop them back ,this allows a current location begin edited to be temporarily saved while another location
is examined or modified
BBED> push dba 10,68
DBA 0×02800044 (41943108 10,68)
OFFSET 20
BBED> set dba 10,40
DBA 0×02800028 (41943080 10,40)
BBED> pop
DBA 0×02800044 (41943108 10,68)
OFFSET 20
BBED> map /v (开所有结构)
File: /u01/test/block_test.dbf (10)
Block: 68 Dba:0×02800044
————————————————————
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
ub1 type_kcbh @0
ub1 frmt_kcbh @1
ub1 spare1_kcbh @2
ub1 spare2_kcbh @3
ub4 rdba_kcbh @4
ub4 bas_kcbh @8
ub2 wrp_kcbh @12
ub1 seq_kcbh @14
ub1 flg_kcbh @15
ub2 chkval_kcbh @16
ub2 spare3_kcbh @18
struct ktbbh, 72 bytes @20
ub1 ktbbhtyp @20
union ktbbhsid, 4 bytes @24
struct ktbbhcsc, 8 bytes @28
b2 ktbbhict @36
ub1 ktbbhflg @38
ub1 ktbbhfsl @39
ub4 ktbbhfnx @40
struct ktbbhitl[2], 48 bytes @44
struct kdbh, 14 bytes @100
ub1 kdbhflag @100
b1 kdbhntab @101
b2 kdbhnrow @102
sb2 kdbhfrre @104
sb2 kdbhfsbo @106
sb2 kdbhfseo @108
b2 kdbhavsp @110
b2 kdbhtosp @112
struct kdbt[1], 4 bytes @114
b2 kdbtoffs @114
b2 kdbtnrow @116
sb2 kdbr[2] @118
ub1 freespace[8054] @122
ub1 rowdata[12] @8176
ub4 tailchk @8188
revert
the revert command is used to restore a file,filename,block or dba to it’s original state when bbed was started
这个就是 恢复到bbed刚开始启动的时候,但是关了后重新来就不行了
revert dba 10,68
undo
the undo command rolls back the last modify or assign command,if the undo command is issued again
the modification is re-done
eg : revert & undo
BBED> p ktbbh.ktbbhsid
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000dcb3
ub4 ktbbhod1 @24 0x0000dcb3
BBED> dump /v count 16
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
——————————————————-
b3dc0000 80cc3500 00000000 02003200 l 耻…?…….2.
BBED>
BBED>
BBED> modify /x dddd offset 24
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
dddd0000 80cc3500 00000000 02003200
BBED> undo
BBED> modify /x B3DC filename ‘/u01/test/block_test.dbf’ block 68. offset 24.
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
b3dc0000 80cc3500 00000000 02003200
BBED> modify /x aaaa offset 24
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
aaaa0000 80cc3500 00000000 02003200
BBED> undo
BBED> modify /x B3DC filename ‘/u01/test/block_test.dbf’ block 68. offset 24.
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
b3dc0000 80cc3500 00000000 02003200
BBED> modify /x cccc offset 24
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
cccc0000 80cc3500 00000000 02003200
BBED> modify /x dddd offset 24
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
dddd0000 80cc3500 00000000 02003200
BBED> undo
BBED> modify /x CCCC filename ‘/u01/test/block_test.dbf’ block 68. offset 24.
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
————————————————————————
cccc0000 80cc3500 00000000 02003200
##############上面可以看到只能回退最近的一次修改,而下面的revert可以自bbed启动来的全回退
BBED> revert
All changes made in this session will be rolled back. Proceed? (Y/N) y
Reverted file ‘/u01/test/block_test.dbf’, block 68
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
BBED> p ktbbh.ktbbhsid
union ktbbhsid, 4 bytes @24
ub4 ktbbhsg1 @24 0x0000dcb3
ub4 ktbbhod1 @24 0x0000dcb3
BBED> dump /v count 16
File: /u01/test/block_test.dbf (10)
Block: 68 Offsets: 24 to 39 Dba:0×02800044
——————————————————-
b3dc0000 80cc3500 00000000 02003200 l 耻…?…….2.
##########################检查有木有坏块
verify
BBED> verify
DBVERIFY – Verification starting
FILE = /u01/test/block_test.dbf
BLOCK = 68
Block Checking: DBA = 41943108, Block Type = KTB-managed data block
data header at 0x62c0264
kdbchk: row locked by non-existent transaction
table=0 slot=1
lockid=2 ktbbhitc=2
Block 68 failed with check code 6101
DBVERIFY – Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing (Data) : 1
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 0
Total Blocks Influx : 0
corrput 标记块损坏,
corrupt dba 10,58
BBED> set block 68
BLOCK# 68
BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0×06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0×00
ub1 spare2_kcbh @3 0×00
ub4 rdba_kcbh @4 0×02800044
ub4 bas_kcbh @8 0x0035cc80
ub2 wrp_kcbh @12 0×0000
ub1 seq_kcbh @14 0×01
ub1 flg_kcbh @15 0×04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xef7a
ub2 spare3_kcbh @18 0×0000
BBED> corrupt dba 10,68
Block marked media corrupt.
BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0×06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0×00
ub1 spare2_kcbh @3 0×00
ub4 rdba_kcbh @4 0×02800044
ub4 bas_kcbh @8 0×00000000
ub2 wrp_kcbh @12 0×0000
ub1 seq_kcbh @14 0xff*******************
ub1 flg_kcbh @15 0×04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xef4f
ub2 spare3_kcbh @18 0×0000
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3);
select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3)
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 10, block # 68)
ORA-01110: data file 10: ‘/u01/test/block_test.dbf’
undo是修复不回来的,revert 可以
BBED> revert
All changes made in this session will be rolled back. Proceed? (Y/N) y
Reverted file ‘/u01/test/block_test.dbf’, block 68
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
BBED> sum apply
Check value for File 10, Block 68:
current = 0xef7a, required = 0xef7a
BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0×06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0×00
ub1 spare2_kcbh @3 0×00
ub4 rdba_kcbh @4 0×02800044
ub4 bas_kcbh @8 0x0035cc80
ub2 wrp_kcbh @12 0×0000
ub1 seq_kcbh @14 0×01
ub1 flg_kcbh @15 0×04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xef7a
ub2 spare3_kcbh @18 0×0000
SQL> select file#,block#,a from (select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,a from tr3);
FILE# BLOCK# A
———- ———- ———-
10 68 1
10 68 2