[20161124]bbed使用问题.txt
--最近一致在使用bbed探究oracle数据库,遇到一些问题做一些记录。
1.环境:
SCOTT@book> @ &r/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 TABLESPACE SUGAR DATAFILE
'/mnt/ramdisk/book/sugar01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
SCOTT@book> create table t4 tablespace sugar select rownum id ,lpad('A',32,'A') name from dual connect by level<=1e5;
Table created.
SCOTT@book> column PARTITION_NAME noprint
SCOTT@book> select * from dba_extents where owner=user and segment_name='T4';
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------ ------------ ------------ --------------- ---------- ---------- ---------- ---------- ---------- ------------
SCOTT T4 TABLE SUGAR 0 6 128 65536 8 6
SCOTT T4 TABLE SUGAR 1 6 136 65536 8 6
SCOTT T4 TABLE SUGAR 2 6 144 65536 8 6
SCOTT T4 TABLE SUGAR 3 6 152 65536 8 6
SCOTT T4 TABLE SUGAR 4 6 160 65536 8 6
SCOTT T4 TABLE SUGAR 5 6 168 65536 8 6
SCOTT T4 TABLE SUGAR 6 6 176 65536 8 6
SCOTT T4 TABLE SUGAR 7 6 184 65536 8 6
SCOTT T4 TABLE SUGAR 8 6 192 65536 8 6
SCOTT T4 TABLE SUGAR 9 6 200 65536 8 6
SCOTT T4 TABLE SUGAR 10 6 208 65536 8 6
SCOTT T4 TABLE SUGAR 11 6 216 65536 8 6
SCOTT T4 TABLE SUGAR 12 6 224 65536 8 6
SCOTT T4 TABLE SUGAR 13 6 232 65536 8 6
SCOTT T4 TABLE SUGAR 14 6 240 65536 8 6
SCOTT T4 TABLE SUGAR 15 6 248 65536 8 6
SCOTT T4 TABLE SUGAR 16 6 256 1048576 128 6
SCOTT T4 TABLE SUGAR 17 6 384 1048576 128 6
SCOTT T4 TABLE SUGAR 18 6 512 1048576 128 6
SCOTT T4 TABLE SUGAR 19 6 640 1048576 128 6
20 rows selected.
SCOTT@book> select SEGMENT_NAME,HEADER_FILE,HEADER_BLOCK,BYTES,BLOCKS,EXTENTS from dba_segments where owner=user and segment_name='T4';
SEGMENT_NAME HEADER_FILE HEADER_BLOCK BYTES BLOCKS EXTENTS
-------------------- ----------- ------------ ---------- ---------- ----------
T4 6 130 5242880 640 20
--从这里看出段头位于130块是PAGETABLE SEGMENT HEADER,而前面的128,129块是1级,2级是FIRST LEVEL BITMAP BLOCK,SECOND LEVEL BITMAP BLOCK。
2.而bbed是无法识别这些块的,当访问这些块时出现如下提示。
BBED> set dba 6,128
DBA 0x01800080 (25165952 6,128)
BBED> map /v
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 128 Dba:0x01800080
------------------------------------------------------------
BBED-00400: invalid blocktype (32)
SCOTT@book> select rowid,t4.id from t4 where id=1;
ROWID ID
------------------ ----------
AAAVwFAAGAAAACDAAA 1
SCOTT@book> @ &r/rowid AAAVwFAAGAAAACDAAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
89093 6 131 0 0x1800083 6,131 alter system dump datafile 6 block 131 ;
SCOTT@book> update t4 set name=upper(name) where id=1;
1 row updated.
SCOTT@book> commit ;
Commit complete.
--//这样块131,132的scn号不一样。
3.我遇到的问题。我的设置已经建立了listfile文件。如果你执行bbed,马上输入show all,结果如下:
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
--实际上我的测试无论/home/oracle/bbed/filelist.txt中/mnt/ramdisk/book/system01.dbf在哪一行,执行都是像上面那样。
--显示P命令的执行方式:
BBED> help p
PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
--如果我执行如下:
BBED> p tailchk dba 6,131
ub4 tailchk @8188 0x70200602
BBED> p tailchk dba 6,128
BBED-00400: invalid blocktype (32)
BBED> p tailchk dba 6,131
BBED-00400: invalid blocktype (32)
--很明显第2次我再执行p tailchk dba 6,131,出现错误,从invalid blocktype (32)提示看访问的是dba=6,128.
--而这样执行就没有问题了。
BBED> p dba 6,131 tailchk
ub4 tailchk @8188 0x70200602
BBED> p tailchk dba 6,132
ub4 tailchk @8188 0x6d8e0602
--从显示结果看,这2种执行方式是等价的,但是当先访问了bbed无法识别的块。再执行p tailchk dba 6,132这种方式就报错。
BBED> p dba 6,128 tailchk
BBED-00400: invalid blocktype (32)
BBED> show
FILE# 6
BLOCK# 128
OFFSET 8188
DBA 0x01800080 (25165952 6,128)
FILENAME /mnt/ramdisk/book/sugar01.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
BBED> p dba 6,131 tailchk
ub4 tailchk @8188 0x70200602
--看来在bbed执行时dba 之类的要写在前面,避免这种错误。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2128975/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/267265/viewspace-2128975/