Professional Documents
Culture Documents
Ora BBED 2
Ora BBED 2
txt
blocksize=8192
listfile=filelist.txt
mode=edit
FILE#||CHR(9)||NAME||CHR(9)||BYTES
--------------------------------------------------------------------------------
1 /home/oracle/app/oradata/newtest/system01.dbf 786432000
2 /home/oracle/app/oradata/newtest/sysaux01.dbf 1006632960
3 /home/oracle/app/oradata/newtest/undotbs01.dbf 78643200
4 /home/oracle/app/oradata/newtest/users01.dbf 355205120
5 /home/oracle/app/oradata/newtest/users02.dbf 524288000
#修改 bash_profile,添加参数等
[oracle@localhost ~]$ vi .bash_profile
#进入 bbed
[oracle@localhost ~]$ bbed
BBED: Release 2.0.0.0.0 - Limited Production on Thu Mar 15 22:17:40 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED>
3.常用命令
set file 4 block 32
set dba 0x01000020
set offset 0 -- 0 表示第一个字节开始
set block 1 -- 1 表示第一个块开始
set count 8192 -- 默认是显示 512 字节
find /x 05d67g
#查指定的字符串在指定数据块中的具体位置
f --find 的简写,表示继续从当前位置开始往下查询字符串 05d67g
dump
#十六进制查看 block
dump /v --查看十六进制内容的同时以文本方式“翻译”十六进制显示的内容,相当于对当
block 执行 strings 命令
modify /x d43 #修改指定 block,指定 offset 的数据块块内记录的内容
sum apply #计算修改后的数据块的 checksum 值,然后写入数据块的 offset 为 16-17 的位置
首先我们有一个表为
SQL> select * from t2;
ID NAME
---------- ----------------------------------------------------------------------------------------------------
1 AAAAA
1 BBBBB
1 CCCCC
1 DDDDD
1 EEEEE
查询出每行的所在的 dba
SQL> select id,name,dbms_rowid.ROWID_RELATIVE_FNO(rowid) file#,dbms_rowid.ROWID
_BLOCK_NUMBER(rowid) block# from t2;
ID NAME FILE# BLOCK#
---------- ----------------------------------------------------------------------------------------------------
1 AAAAA 4 189
1 BBBBB 4 189
1 CCCCC 4 189
1 DDDDD 4 189
1 EEEEE 4 189
map /v 可以看到数据块的结构
BBED> map /v
File: /app/oracle/oradata/orcl/users01.dbf (4)
Block: 189 Dba:0x010000bd
------------------------------------------------------------
KTB Data Block (Table/Cluster)
3.用户数据头
data_block_dump,data header at 0x2b2fb2e3aa64
===============
tsiz: 0x1f98 0x1f98 块的 total 总可用空间
hsiz: 0x1c 数据头部占的字节数-不固定
pbl: 0x2b2fb2e3aa64
76543210
flag=--------
ntab=1 ntab=1 --数据块属于一个表, cluster 表时不是 1
nrow=5 nrow=2 --行数
frre=-1 first free row index entry;-1=you have to add one
fsbo=0x1c free space begin offset 起始空间:可以存放数据空间的起始位置(即
定义了数据层中空闲空间的起始 offset)
fseo=0x1f5c free space end offset 结束空间:可以存放数据空间的结束位置(即定
义了数据层中空闲空间的结束 offset)
avsp=0x1f40 available space in the block 可用空间
tosp=0x1f40 total available space when all txs commit
0xe:pti[0] nrow=5 offs=0 整个表的开始,共 2 行数据 ,定义了该表在行索引中使用的插
槽数
0x12:pri[0] offs=0x1f8c 行索引,定义了该块中包含的所有行数据的位置
0x14:pri[1] offs=0x1f80
0x16:pri[2] offs=0x1f74
0x18:pri[3] offs=0x1f68
0x1a:pri[4] offs=0x1f5c
BBED 中
BBED> p kdbh
struct kdbh, 14 bytes @100
ub1 kdbhflag @100 0x00 (NONE)
sb1 kdbhntab @101 1
sb2 kdbhnrow @102 5
sb2 kdbhfrre @104 -1
sb2 kdbhfsbo @106 28
sb2 kdbhfseo @108 8028
sb2 kdbhavsp @110 8000
sb2 kdbhtosp @112 8000
4.接下来就是用户数据
block_row_dump:
tab 0, row 0, @0x1f8c
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2 FL 开始结束, lb(lock byte), 第一个事务发生在第一个
事务槽上面 cc 有两列
col 0: [ 2] c1 02 c1 02 是 1 ,oracle 内部的算法。
col 1: [ 5] 41 41 41 41 41 41=A,所以是 AAAAA
tab 0, row 1, @0x1f80
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 42 42 42 42 42
tab 0, row 2, @0x1f74
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 43 43 43 43 43
tab 0, row 3, @0x1f68
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 44 44 44 44 44
tab 0, row 4, @0x1f5c
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 45 45 45 45 45
end_of_block_dump<em id="__mceDel" style="background-color: #ffffff; font-family: verdana,
Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.5;"> </em>
BBED> p kdbr
sb2 kdbr[0] @118 8076
sb2 kdbr[1] @120 8064
sb2 kdbr[2] @122 8052
sb2 kdbr[3] @124 8040
sb2 kdbr[4] @126 8028
BBED> x /rnc
rowdata[48] @8176
-----------
flag@8176: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8177: 0x01
cols@8178: 2
Use the verify command in bbed, along with several other outside-of-bbed utilities (analyze,
DBMS_REPAIR, etc.) to validate the block structure. Is the restored structure valid?
In this example, the data was restored, but the block failed to validate. Once the data is restored,
take steps to check and ensure its validity. A simple way to collect the data is to perform a CTAS
(Create Table As Select) using the original table as the source. The following shows there is not a
difference, followed by evidence of one, and that the count is off by one.
SQL> select empno from emp minus select empno from emp2;
no rows selected
SQL> select empno from emp2 minus select empno from emp;
EMPNO
----------
7788
What can one do to remove this discrepancy? The best way - before anyone else starts trying other
options - is to do what was just mentioned: make a copy of the data and put it elsewhere. Then, if
one wants to start trying DBMS_REPAIR and other options, when one sees the following, there
will not be such a desperate feeling.
Tailcheck - consists of three elements: the lower ordered two bytes of the SCN base, the block
type (typically 06 for data blocks), and the SCN sequence number.
BBED> p tailchk
ub4 tailchk @8188 0x75850602
The hex value 0x75850602 above reflects 7585 from the base, 06 for a data block, and 02 for the
sequence number.
Block header structure, found in several public sources, consists of the type, format, spare, data
block address, SCN base, SCN wrap, SCN sequence, and a flag (new, delayed logging, check
value saved and temporary, using values of 01, 02, 04 and 08). Dump the beginning of a block (at
offset 0) and this is the first line.