[20180205]使用bbed相关问题.txt
--//上个星期5使用bbed修改块遇到一些问题,做一个记录:
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
create table t (id number, update_scn number, commit_scn number,pad varchar2(20));
insert into t values (1,dbms_flashback.get_system_change_number,userenv('commitscn'),lpad('x',10,'x'));
commit;
SCOTT@book> select ora_rowscn,rowid,t.* from scott.t;
ORA_ROWSCN ROWID ID UPDATE_SCN COMMIT_SCN PAD
------------ ------------------ ------------ ------------ ------------ --------------------
13278403922 AAAWUOAAEAAAAI0AAA 1 13278403918 13278403921 xxxxxxxxxx
SCOTT@book> @ &r/rowid AAAWUOAAEAAAAI0AAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
------------ ------------ ------------ ------------ -------------------- -------------------- ----------------------------------------
91406 4 564 0 0x1000234 4,564 alter system dump datafile 4 block 564 ;
select 13278403922,trunc(13278403922/power(2,32)) scn_wrap,mod(13278403922,power(2,32)) scn_base from dual
13278403922 SCN_WRAP SCN_BASE SCN_WRAP16 SCN_BASE16
------------ ------------ ------------ ---------- ----------
13278403922 3 393502034 3 17745d52
SCOTT@book> alter system checkpoint ;
System altered.
2.以dba=4,564为例子说明问题一:
$ cat scn.cmd
set count 8192
set width 210
p dba 4,564 kcbh.bas_kcbh
p dba 4,564 ktbbh.ktbbhcsc.kscnbas
p dba 4,564 ktbbh.ktbbhitl[0].ktbitflg
p dba 4,564 ktbbh.ktbbhitl[0].ktbitbas
p dba 4,564 ktbbh.ktbbhitl[1].ktbitflg
p dba 4,564 ktbbh.ktbbhitl[1].ktbitbas
p dba 4,564 ktbbh.ktbbhitl[2].ktbitflg
p dba 4,564 ktbbh.ktbbhitl[2].ktbitbas
p dba 4,564 tailchk
quit
$ $ORACLE_HOME/bin/bbed parfile=bbed.par cmdfile=scn.cmd
..
BBED> p dba 4,564 kcbh.bas_kcbh
ub4 bas_kcbh @8 0x17745d52
BBED> p dba 4,564 ktbbh.ktbbhcsc.kscnbas
ub4 kscnbas @28 0x17745d50
BBED> p dba 4,564 ktbbh.ktbbhitl[0].ktbitflg
ub2 ktbitflg @60 0x2001 (KTBFUPB)
BBED> p dba 4,564 ktbbh.ktbbhitl[0].ktbitbas
ub4 ktbitbas @64 0x17745d52
BBED> p dba 4,564 ktbbh.ktbbhitl[1].ktbitflg
ub2 ktbitflg @84 0x0000 (NONE)
BBED> p dba 4,564 ktbbh.ktbbhitl[1].ktbitbas
ub4 ktbitbas @88 0x00000000
BBED> p dba 4,564 ktbbh.ktbbhitl[2].ktbitflg
ub2 ktbitflg @60 0x2001 (KTBFUPB)
BBED> p dba 4,564 ktbbh.ktbbhitl[2].ktbitbas
ub4 ktbitbas @64 0x17745d52
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BBED> p dba 4,564 tailchk
ub4 tailchk @8188 0x5d520601
BBED> quit
--//注意看下划线实际上仅仅2个itl槽.ktbbh.ktbbhitl[2].ktbitbas根本不存在.
BBED> p dba 4,564 ktbbh.ktbbhitl
struct ktbbhitl[0], 24 bytes @44
struct ktbitxid, 8 bytes @44
ub2 kxidusn @44 0x0008
ub2 kxidslt @46 0x000d
ub4 kxidsqn @48 0x0000076d
struct ktbituba, 8 bytes @52
ub4 kubadba @52 0x00c008cc
ub2 kubaseq @56 0x03ca
ub1 kubarec @58 0x2e
ub2 ktbitflg @60 0x2001 (KTBFUPB)
union _ktbitun, 2 bytes @62
sb2 _ktbitfsc @62 0
ub2 _ktbitwrp @62 0x0000
ub4 ktbitbas @64 0x17745d52
struct ktbbhitl[1], 24 bytes @68
struct ktbitxid, 8 bytes @68
ub2 kxidusn @68 0x0000
ub2 kxidslt @70 0x0000
ub4 kxidsqn @72 0x00000000
struct ktbituba, 8 bytes @76
ub4 kubadba @76 0x00000000
ub2 kubaseq @80 0x0000
ub1 kubarec @82 0x00
ub2 ktbitflg @84 0x0000 (NONE)
union _ktbitun, 2 bytes @86
sb2 _ktbitfsc @86 0
ub2 _ktbitwrp @86 0x0000
ub4 ktbitbas @88 0x00000000
--//显示第7槽,实际上都是槽1的信息.感觉这个是bbed的bug.
BBED> p dba 4,564 ktbbh.ktbbhitl[7]
struct ktbbhitl[7], 24 bytes @44
struct ktbitxid, 8 bytes @44
ub2 kxidusn @44 0x0008
ub2 kxidslt @46 0x000d
ub4 kxidsqn @48 0x0000076d
struct ktbituba, 8 bytes @52
ub4 kubadba @52 0x00c008cc
ub2 kubaseq @56 0x03ca
ub1 kubarec @58 0x2e
ub2 ktbitflg @60 0x2001 (KTBFUPB)
union _ktbitun, 2 bytes @62
sb2 _ktbitfsc @62 0
ub2 _ktbitwrp @62 0x0000
ub4 ktbitbas @64 0x17745d52
3.问题2:
BBED> p dba 4,564 tailchk
ub4 tailchk @8188 0x5d520601
--//tailchk的组成包括kcbh.bas_kcbh的低4个位.
BBED> p dba 4,564 kcbh.bas_kcbh
ub4 bas_kcbh @8 0x17745d52
--//我一直以为assign命令不能修改tailchk,实际上是可以的.
BBED> assign dba 4,564 tailchk=0x6d520601
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub4 tailchk @8188 0x6d520601
--//仅仅第一位大于0x8才存在问题:
BBED> assign dba 4,564 tailchk=0x9d520601
BBED-00207: invalid offset specifier (9d520601)
BBED> assign dba 4,564 tailchk=0x8d520601
BBED-00207: invalid offset specifier (8d520601)
BBED> assign dba 4,564 tailchk=0x5d520601
ub4 tailchk @8188 0x5d520601
--//感觉这个也是bug.要使用modify修改要注意大小头问题,intel系列.
BBED> modify /x 529d offset 8190
File: /mnt/ramdisk/book/users01.dbf (4)
Block: 564 Offsets: 8190 to 8191 Dba:0x01000234
------------------------------------------------------------------------------------------------------------------------------------------------
529d
<64 bytes per line>
BBED> p dba 4,564 tailchk
ub4 tailchk @8188 0x9d520601
--//还原:
BBED> modify /x 525d offset 8190
File: /mnt/ramdisk/book/users01.dbf (4)
Block: 564 Offsets: 8190 to 8191 Dba:0x01000234
------------------------------------------------------------------------------------------------------------------------------------------------
525d
<64 bytes per line>
BBED> p dba 4,564 tailchk
ub4 tailchk @8188 0x5d520601
3.问题3:
--//在上个星期的测试中我自己还犯了一个小错误在执行modify前忘记指定dba地址,导致修改数据文件1的文件头tailchk.
--//导致测试库无法启动.
$ cat filelist.txt
4 /mnt/ramdisk/book/users01.dbf
1 /mnt/ramdisk/book/system01.dbf
2 /mnt/ramdisk/book/sysaux01.dbf
3 /mnt/ramdisk/book/undotbs01.dbf
5 /mnt/ramdisk/book/example01.dbf
6 /mnt/ramdisk/book/tea01.dbf
7 /mnt/ramdisk/book/sugar01.dbf
BBED> show all
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /mnt/ramdisk/book/system01.dbf
BIFILE bifile.bbd
LISTFILE /home/oracle/bbed/filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 160
COUNT 64
LOGFILE log.bbd
SPOOL Yes
--//无论system文件放在什么位置,bbed启动自动定位dba=1,1的位置.
4.这些细节要在以后工作中注意,避免犯一些低级错误.
感觉好久不用bbed,有点生疏了.所谓的用进废退吧.