Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » 内部原理

如何使用BBED

BBED是Oracle提供的块编辑器,借助BBED我们可以更好的理解Oracle的Block的结构。也只有理解了块的结构,才能更好的利用BBED在某些特殊情况下修复数据库。

BBED使用原则
   A.确认大端、小端问题。这个确认后,更改数据后才不会出错。
   B.在正确的位置修改正确的值。确认需要修改的值的位置,确认你需要修改什么成什么值。
如何判断大端、小端?
   BBED> p kcvfhbfh
   struct kcvfhbfh, 20 bytes                   @0       
      ub1 type_kcbh                            @0        0x0b
      ub1 frmt_kcbh                            @1        0xa2
      ub1 spare1_kcbh                          @2        0x00
      ub1 spare2_kcbh                          @3        0x00
      ub4 rdba_kcbh                            @4        0x00400001
      ub4 bas_kcbh                             @8        0x00000000
      ub2 wrp_kcbh                             @12       0x0000
      ub1 seq_kcbh                             @14       0x01
      ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
      ub2 chkval_kcbh                          @16       0x7c2e
      ub2 spare3_kcbh                          @18       0x0000
   
   BBED> d/v count 20
    File: /oradata/ora10/system01.dbf (1)
    Block: 1       Offsets:    0 to   19  Dba:0x00400001
   -------------------------------------------------------
    0ba20000 01004000 00000000 00000104 l ....@.........
    2e7c0000                            l .|..
   
    <16 bytes per line>
   
   BBED>
如果红色部分显示的内容一样,则说明是大端,如果不一样,则是小端

如果是Little Endian,如果将0x00400001修改为0x00400002,应该用m/x 02004000 offset 4

如果是Big   Endian如果将0x00400001修改为0x00400002,应该用m/x 00400002 offset 4


10g块头结构

BBED> p kcvfh
struct kcvfh, 676 bytes                     @0       
   struct kcvfhbfh, 20 bytes                @0       
      ub1 type_kcbh                         @0        0x0b
      ub1 frmt_kcbh                         @1        0xa2
      ub1 spare1_kcbh                       @2        0x00
      ub1 spare2_kcbh                       @3        0x00
      ub4 rdba_kcbh                         @4        0x00400001
      ub4 bas_kcbh                          @8        0x00000000
      ub2 wrp_kcbh                          @12       0x0000
      ub1 seq_kcbh                          @14       0x01
      ub1 flg_kcbh                          @15       0x04 (KCBHFCKV)
      ub2 chkval_kcbh                       @16       0x73a8
      ub2 spare3_kcbh                       @18       0x0000
   struct kcvfhhdr, 76 bytes                @20      
      ub4 kccfhswv                          @20       0x00000000
      ub4 kccfhcvn                          @24       0x0a200100
      ub4 kccfhdbi                          @28       0x3526cf91
      text kccfhdbn[0]                      @32      O
      text kccfhdbn[1]                      @33      R
      text kccfhdbn[2]                      @34      A
      text kccfhdbn[3]                      @35      1
      text kccfhdbn[4]                      @36      0
      text kccfhdbn[5]                      @37       
      text kccfhdbn[6]                      @38       
      text kccfhdbn[7]                      @39       
      ub4 kccfhcsq                          @40       0x0000018e
      ub4 kccfhfsz                          @44       0x0000f000
      s_blkz kccfhbsz                       @48       0x00
      ub2 kccfhfno                          @52       0x0001
      ub2 kccfhtyp                          @54       0x0003
      ub4 kccfhacid                         @56       0x00000000
      ub4 kccfhcks                          @60       0x00000000
      text kccfhtag[0]                      @64       
      text kccfhtag[1]                      @65       
      text kccfhtag[2]                      @66       
      text kccfhtag[3]                      @67       
      text kccfhtag[4]                      @68       
      text kccfhtag[5]                      @69       
      text kccfhtag[6]                      @70       
      text kccfhtag[7]                      @71       
      text kccfhtag[8]                      @72       
      text kccfhtag[9]                      @73       
      text kccfhtag[10]                     @74       
      text kccfhtag[11]                     @75       
      text kccfhtag[12]                     @76       
      text kccfhtag[13]                     @77       
      text kccfhtag[14]                     @78       
      text kccfhtag[15]                     @79       
      text kccfhtag[16]                     @80       
      text kccfhtag[17]                     @81       
      text kccfhtag[18]                     @82       
      text kccfhtag[19]                     @83       
      text kccfhtag[20]                     @84       
      text kccfhtag[21]                     @85       
      text kccfhtag[22]                     @86       
      text kccfhtag[23]                     @87       
      text kccfhtag[24]                     @88       
      text kccfhtag[25]                     @89       
      text kccfhtag[26]                     @90       
      text kccfhtag[27]                     @91       
      text kccfhtag[28]                     @92       
      text kccfhtag[29]                     @93       
      text kccfhtag[30]                     @94       
      text kccfhtag[31]                     @95       
   ub4 kcvfhrdb                             @96       0x00400179
   struct kcvfhcrs, 8 bytes                 @100     
      ub4 kscnbas                           @100      0x00000008
      ub2 kscnwrp                           @104      0x0000
   ub4 kcvfhcrt                             @108      0x221e01bf
   ub4 kcvfhrlc                             @112      0x36303713
   struct kcvfhrls, 8 bytes                 @116     
      ub4 kscnbas                           @116      0x00080634
      ub2 kscnwrp                           @120      0x0000
   ub4 kcvfhbti                             @124      0x00000000
   struct kcvfhbsc, 8 bytes                 @128     
      ub4 kscnbas                           @128      0x00000000
      ub2 kscnwrp                           @132      0x0000
   ub2 kcvfhbth                             @136      0x0000
   ub2 kcvfhsta                             @138      0x2000 (NONE)
   struct kcvfhckp, 36 bytes                @484     
      struct kcvcpscn, 8 bytes              @484     
         ub4 kscnbas                        @484      0x00088742
         ub2 kscnwrp                        @488      0x0000
      ub4 kcvcptim                          @492      0x36304031
      ub2 kcvcpthr                          @496      0x0001
      union u, 12 bytes                     @500     
         struct kcvcprba, 12 bytes          @500     
            ub4 kcrbaseq                    @500      0x00000002
            ub4 kcrbabno                    @504      0x00015b11
            ub2 kcrbabof                    @508      0x0010
      ub1 kcvcpetb[0]                       @512      0x02
      ub1 kcvcpetb[1]                       @513      0x00
      ub1 kcvcpetb[2]                       @514      0x00
      ub1 kcvcpetb[3]                       @515      0x00
      ub1 kcvcpetb[4]                       @516      0x00
      ub1 kcvcpetb[5]                       @517      0x00
      ub1 kcvcpetb[6]                       @518      0x00
      ub1 kcvcpetb[7]                       @519      0x00
   ub4 kcvfhcpc                             @140      0x00000033
   ub4 kcvfhrts                             @144      0x3630370c
   ub4 kcvfhccc                             @148      0x00000032
   struct kcvfhbcp, 36 bytes                @152     
      struct kcvcpscn, 8 bytes              @152     
         ub4 kscnbas                        @152      0x00000000
         ub2 kscnwrp                        @156      0x0000
      ub4 kcvcptim                          @160      0x00000000
      ub2 kcvcpthr                          @164      0x0000
      union u, 12 bytes                     @168     
         struct kcvcprba, 12 bytes          @168     
            ub4 kcrbaseq                    @168      0x00000000
            ub4 kcrbabno                    @172      0x00000000
            ub2 kcrbabof                    @176      0x0000
      ub1 kcvcpetb[0]                       @180      0x00
      ub1 kcvcpetb[1]                       @181      0x00
      ub1 kcvcpetb[2]                       @182      0x00
      ub1 kcvcpetb[3]                       @183      0x00
      ub1 kcvcpetb[4]                       @184      0x00
      ub1 kcvcpetb[5]                       @185      0x00
      ub1 kcvcpetb[6]                       @186      0x00
      ub1 kcvcpetb[7]                       @187      0x00
   ub4 kcvfhbhz                             @312      0x00000000
   struct kcvfhxcd, 16 bytes                @316     
      ub4 space_kcvmxcd[0]                  @316      0x00000000
      ub4 space_kcvmxcd[1]                  @320      0x00000000
      ub4 space_kcvmxcd[2]                  @324      0x00000000
      ub4 space_kcvmxcd[3]                  @328      0x00000000
   word kcvfhtsn                            @332      0
   ub2 kcvfhtln                             @336      0x0006
   text kcvfhtnm[0]                         @338     S
   text kcvfhtnm[1]                         @339     Y
   text kcvfhtnm[2]                         @340     S
   text kcvfhtnm[3]                         @341     T
   text kcvfhtnm[4]                         @342     E
   text kcvfhtnm[5]                         @343     M
   text kcvfhtnm[6]                         @344      
   text kcvfhtnm[7]                         @345      
   text kcvfhtnm[8]                         @346      
   text kcvfhtnm[9]                         @347      
   text kcvfhtnm[10]                        @348      
   text kcvfhtnm[11]                        @349      
   text kcvfhtnm[12]                        @350      
   text kcvfhtnm[13]                        @351      
   text kcvfhtnm[14]                        @352      
   text kcvfhtnm[15]                        @353      
   text kcvfhtnm[16]                        @354      
   text kcvfhtnm[17]                        @355      
   text kcvfhtnm[18]                        @356      
   text kcvfhtnm[19]                        @357      
   text kcvfhtnm[20]                        @358      
   text kcvfhtnm[21]                        @359      
   text kcvfhtnm[22]                        @360      
   text kcvfhtnm[23]                        @361      
   text kcvfhtnm[24]                        @362      
   text kcvfhtnm[25]                        @363      
   text kcvfhtnm[26]                        @364      
   text kcvfhtnm[27]                        @365      
   text kcvfhtnm[28]                        @366      
   text kcvfhtnm[29]                        @367      
   ub4 kcvfhrfn                             @368      0x00000001
   struct kcvfhrfs, 8 bytes                 @372     
      ub4 kscnbas                           @372      0x00000000
      ub2 kscnwrp                           @376      0x0000
   ub4 kcvfhrft                             @380      0x00000000
   struct kcvfhafs, 8 bytes                 @384     
      ub4 kscnbas                           @384      0x00000000
      ub2 kscnwrp                           @388      0x0000
   ub4 kcvfhbbc                             @392      0x00000000
   ub4 kcvfhncb                             @396      0x00000000
   ub4 kcvfhmcb                             @400      0x00000000
   ub4 kcvfhlcb                             @404      0x00000000
   ub4 kcvfhbcs                             @408      0x00000000
   ub2 kcvfhofb                             @412      0x000a
   ub2 kcvfhnfb                             @414      0x000a
   ub4 kcvfhprc                             @416      0x221e01a8
   struct kcvfhprs, 8 bytes                 @420     
      ub4 kscnbas                           @420      0x00000001
      ub2 kscnwrp                           @424      0x0000
   struct kcvfhprfs, 8 bytes                @428     
      ub4 kscnbas                           @428      0x00000000
      ub2 kscnwrp                           @432      0x0000
   ub4 kcvfhtrt                             @444      0x00000000

BBED> 

SET帮助信息
BBED> help set
SET DBA [ dba | file#, block# ]                    --设置块的地址
SET FILENAME 'filename'                            --设置要查看的数据文件名字
SET FILE file#                                     --设置要查看的文件编号
SET BLOCK [+/-]block#                              --设置块的编号
   BBED> set block +4
           BLOCK#          5
   
   BBED> set block -1
           BLOCK#          4
   
   BBED> 

SET OFFSET [ [+/-]byte offset | symbol | *symbol ] --设置在当前块中偏移量
   BBED> set offset -10
           OFFSET          10
   
   BBED> set offset +40
           OFFSET          50
   
   BBED> 

SET BLOCKSIZE bytes                             --设置块大小
SET LIST[FILE] 'filename'                       --设置包含数据文件的文件列表
SET WIDTH character_count                       --设置每行显示的字符宽度
SET COUNT bytes_to_display                      --设置显示字符的个数
SET IBASE [ HEX | OCT | DEC ]                   --设置输入的模式,16/8/10进制
SET OBASE [ HEX | OCT | DEC ]                   --设置输出的模式,16/8/10进制
SET MODE  [ BROWSE | EDIT ]                     --设置模式,只读或编辑
SET SPOOL [ Y | N ]                             --设置为Y,会把输入写入bbed.log

SHOW [ <SET parameter> | ALL ]

显示当前BBED相关配置信息

BBED> show
        FILE#           1
        BLOCK#          1
        OFFSET          0
        DBA             0x00400001 (4194305 1,1)
        FILENAME        /oradata/ora10/system01.dbf
        BIFILE          bifile.bbd
        LISTFILE        files.txt
        BLOCKSIZE       8192
        MODE            Browse
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           10
        LOGFILE         log.bbd
        SPOOL           No

BBED> 

INFO

显示当前的listfile内容,列出要查看或编辑的文件列表

BBED> info
 File#  Name                                                        Size(blks)
 -----  ----                                                        ----------
     1  /oradata/ora10/system01.dbf                                          0
     2  /oradata/ora10/undotbs01.dbf                                         0
     3  /oradata/ora10/sysaux01.dbf                                          0
     4  /oradata/ora10/users01.dbf                                           0
     5  /oradata/ora10/example01.dbf                                         0

BBED> 

MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]         

显示当前块结构并显示结构体的每个字段,用/v会显示更详细。会显示部分块类型的结构,比如数据文件头部,table/index/undo块等信息  

BBED> map /v
 File: /oradata/ora10/system01.dbf (1)
 Block: 1                                     Dba:0x00400001
------------------------------------------------------------
 Data File Header

 struct kcvfh, 676 bytes                    @0       
    struct kcvfhbfh, 20 bytes               @0       
    struct kcvfhhdr, 76 bytes               @20      
    ub4 kcvfhrdb                            @96      
    struct kcvfhcrs, 8 bytes                @100     
    ub4 kcvfhcrt                            @108     
    ub4 kcvfhrlc                            @112     
    struct kcvfhrls, 8 bytes                @116     
    ub4 kcvfhbti                            @124     
    struct kcvfhbsc, 8 bytes                @128     
    ub2 kcvfhbth                            @136     
    ub2 kcvfhsta                            @138     
    struct kcvfhckp, 36 bytes               @484     
    ub4 kcvfhcpc                            @140     
    ub4 kcvfhrts                            @144     
    ub4 kcvfhccc                            @148     
    struct kcvfhbcp, 36 bytes               @152     
    ub4 kcvfhbhz                            @312     
    struct kcvfhxcd, 16 bytes               @316     
    word kcvfhtsn                           @332     
    ub2 kcvfhtln                            @336     
    text kcvfhtnm[30]                       @338     
    ub4 kcvfhrfn                            @368     
    struct kcvfhrfs, 8 bytes                @372     
    ub4 kcvfhrft                            @380     
    struct kcvfhafs, 8 bytes                @384     
    ub4 kcvfhbbc                            @392     
    ub4 kcvfhncb                            @396     
    ub4 kcvfhmcb                            @400     
    ub4 kcvfhlcb                            @404     
    ub4 kcvfhbcs                            @408     
    ub2 kcvfhofb                            @412     
    ub2 kcvfhnfb                            @414     
    ub4 kcvfhprc                            @416     
    struct kcvfhprs, 8 bytes                @420     
    struct kcvfhprfs, 8 bytes               @428     
    ub4 kcvfhtrt                            @444     
 ub4 tailchk                                @8188    

BBED>      
                                                                                                  

DUMP[/v] [ DBA | FILENAME | FILE | BLOCK | OFFSET | COUNT ]

显示数据库的内容,/v显示更易读

    BBED> d/v dba 1,1 count 16
     File: /oradata/ora10/system01.dbf (1)
     Block: 1       Offsets:    0 to   15  Dba:0x00400001
    -------------------------------------------------------
     0ba20000 01004000 00000000 00000104 l ....@.........
    
     <16 bytes per line>
    
    BBED> d/v filename '/oradata/ora10/system01.dbf' count 16
     File: /oradata/ora10/system01.dbf (1)
     Block: 1       Offsets:    0 to   15  Dba:0x00400001
    -------------------------------------------------------
     0ba20000 01004000 00000000 00000104 l ....@.........
    
     <16 bytes per line>
    
    BBED> dump /v file 1 count 16
     File: /oradata/ora10/system01.dbf (1)
     Block: 1       Offsets:    0 to   15  Dba:0x00400001
    -------------------------------------------------------
     0ba20000 01004000 00000000 00000104 l ....@.........
    
     <16 bytes per line>
    
    BBED> dump/v block 1 count 16
     File: /oradata/ora10/system01.dbf (1)
     Block: 1       Offsets:    0 to   15  Dba:0x00400001
    -------------------------------------------------------
     0ba20000 01004000 00000000 00000104 l ....@.........
    
     <16 bytes per line>
    
    BBED> d/v offset 0 count 16
     File: /oradata/ora10/system01.dbf (1)
     Block: 1       Offsets:    0 to   15  Dba:0x00400001
    -------------------------------------------------------
     0ba20000 01004000 00000000 00000104 l ....@.........
    
     <16 bytes per line>
    
    BBED>

PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]

显示数据块中offset位置/指定位置的信息

  x - hexadecimal
  d - decimal
  u - unsigned decimal
  o - octal
  c - character (native)
  以16进制,10进制,8进制,字符显示
  DBA | FILE | FILENAME | BLOCK | OFFSET可参照以上dump用法
  BBED> p kcvfhbfh.rdba_kcbh
  ub4 rdba_kcbh                               @4        0x00400001
 
  BBED> p *kcvfhbfh.rdba_kcbh
  BBED-00206: out of range offset (4194305)
 
 
  BBED> p *kcvfhtnm
  kcvfh.kcvfhhdr.kccfhtag[0].kccfhtag[19]
  ---------------------------------------
  text kccfhtag[19]                           @83       
 
  BBED> p *kcvfhtnm[1]
  kcvfh.kcvfhhdr.kccfhtag[0].kccfhtag[25]
  ---------------------------------------
  text kccfhtag[25]                           @89       
 
  BBED>   

EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]

用不同进制显示不同单位的数据

</Nuf>:
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
 
  BBED> x/4bc offset 338 --显示在偏移量为338处的4个字符
  pad                                         @338     
  ---
  SYST
 
  BBED> x/6bc offset 338 --显示在偏移量为338处的6个字符
  pad                                         @338     
  ---
  SYSTEM
 
  BBED> 


FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]

以指定的格式查找信息

   BBED> f/c SYSTEM
    File: /oradata/ora10/system01.dbf (1)
    Block: 1                Offsets:  338 to  347           Dba:0x00400001
   ------------------------------------------------------------------------
    53595354 454d0000 0000
   
    <32 bytes per line>
   
   BBED>
   BBED> f/c S
    File: /oradata/ora10/system01.dbf (1)
    Block: 1                Offsets:  338 to  347           Dba:0x00400001
   ------------------------------------------------------------------------
    53595354 454d0000 0000
   
    <32 bytes per line>
   
   BBED> f --重复执行上次执行的查找命令
    File: /oradata/ora10/system01.dbf (1)
    Block: 1                Offsets:  340 to  349           Dba:0x00400001
   ------------------------------------------------------------------------
    5354454d 00000000 0000
   
    <32 bytes per line>
   
   BBED>

COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]

复制数据块至另一个数据块。这个命令很管用,如果某个块坏掉,可以从备份的文件中复制一个块

   BBED> copy dba 4,1 to dba 1,1
    File: /oradata/ora10/system01.dbf (1)
    Block: 1                Offsets:   15 to   24           Dba:0x00400001
   ------------------------------------------------------------------------
    0435c700 00000000 0000
   
    <32 bytes per line>
   
   BBED>

 
MODIFY[/x|d|u|o|c] numeric/character string

      [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]

以指定的格式修改数据块内容

  BBED> p kcvfhbfh
    struct kcvfhbfh, 20 bytes                   @0       
     ub1 type_kcbh                            @0        0x0b
     ub1 frmt_kcbh                            @1        0xa2
     ub1 spare1_kcbh                          @2        0x00
     ub1 spare2_kcbh                          @3        0x00
     ub4 rdba_kcbh                            @4        0x00400001
     ub4 bas_kcbh                             @8        0x00000000
     ub2 wrp_kcbh                             @12       0x0000
     ub1 seq_kcbh                             @14       0x01
     ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
     ub2 chkval_kcbh                          @16       0x73a8
     ub2 spare3_kcbh                          @18       0x0000
    
  BBED> d/v offset 0 count 20
   File: /oradata/ora10/system01.dbf (1)
   Block: 1       Offsets:    0 to   19  Dba:0x00400001
  -------------------------------------------------------
   0ba20000 01004000 00000000 00000104 l ....@.........
   a8730000                            l ╯..
 
   <16 bytes per line>
 
  BBED> m/x 02004000 offset 4
   File: /oradata/ora10/system01.dbf (1)
   Block: 1                Offsets:    4 to   23           Dba:0x00400001
  ------------------------------------------------------------------------
   02004000 00000000 00000104 a8730000 00000000
 
   <32 bytes per line>
  BBED> d/v count 10
   File: /oradata/ora10/system01.dbf (1)
   Block: 1       Offsets:    4 to   13  Dba:0x00400001
  -------------------------------------------------------
   02004000 00000000 0000              l ..@.......
 
   <16 bytes per line>
 
  BBED>   
  BBED> p/w
  kcvfh.kcvfhbfh.rdba_kcbh
  ------------------------
  ub4 rdba_kcbh                               @4        0x00400002
 
  BBED>

ASSIGN[/x|d|u|o] <target spec>=<source spec>
<target spec> : [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
<source spec> : [ value | <target spec options> ]

SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]     

计算块的checksum值,请参考How to calculate checksum(chkval_kcbh)?

  BBED> sum
  Check value for File 1, Block 1:
  current = 0x73a8, required = 0x73ab
 
  BBED> 

PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]

POP [ALL]

Push/Pop用于记录数据块地址,允许当前块暂时被保存,其它块可以被查看或修改。用堆栈保存dba,起到标签的作用

   BBED> set dba 1,4
           DBA             0x00400004 (4194308 1,4)
   
   BBED> m/x 3
    File: /oradata/ora10/system01.dbf (1)
    Block: 4                Offsets:    0 to    9           Dba:0x00400004
   ------------------------------------------------------------------------
    03a20000 04004000 0c00
   
    <32 bytes per line>
   
   BBED> push dba 1,4
           DBA             0x00400004 (4194308 1,4)
           OFFSET          0
   
   BBED> set dba 1,6
           DBA             0x00400006 (4194310 1,6)
   
   BBED> d/v
    File: /oradata/ora10/system01.dbf (1)
    Block: 6       Offsets:    0 to    9  Dba:0x00400006
   -------------------------------------------------------
    1ea20000 06004000 1000              l ....@...
   
    <16 bytes per line>
   
   BBED> pop
           DBA             0x00400004 (4194308 1,4)
           OFFSET          0
   
   BBED> d/v
    File: /oradata/ora10/system01.dbf (1)
    Block: 4       Offsets:    0 to    9  Dba:0x00400004
   -------------------------------------------------------
    03a20000 04004000 0c00              l ....@...
   
    <16 bytes per line>
   
   BBED>
   BBED> pop
           DBA             0x00400004 (4194308 1,4)
           OFFSET          0
   
   BBED> pop
           DBA             0x00400002 (4194306 1,2)
           OFFSET          0
   
   BBED> pop
           DBA             0x00400001 (4194305 1,1)
           OFFSET          0
   
   BBED> pop
   BBED-00211: location stack is empty
   BBED>
 
REVERT [ DBA | FILE | FILENAME | BLOCK ]  

还原dba,file,filename,block到原始状态

   BBED> m /x 3 dba 1,3
    File: /oradata/ora10/system01.dbf (1)
    Block: 3                Offsets:    0 to    9           Dba:0x00400003
   ------------------------------------------------------------------------
    03a20000 03004000 8483
   
    <32 bytes per line>
   
   BBED> m /x 3 dba 1,4
    File: /oradata/ora10/system01.dbf (1)
    Block: 4                Offsets:    0 to    9           Dba:0x00400004
   ------------------------------------------------------------------------
    03a20000 04004000 0c00
   
    <32 bytes per line>
   
   
   BBED> revert
   All changes made in this session will be rolled back. Proceed? (Y/N) y
   Reverted file '/oradata/ora10/system01.dbf', block 3
   Reverted file '/oradata/ora10/system01.dbf', block 4
   Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
   
   BBED>
 

UNDO 

撤销更改,再次执行会重做

   BBED> d/v
    File: /oradata/ora10/system01.dbf (1)
    Block: 4       Offsets:    0 to    9  Dba:0x00400004
   -------------------------------------------------------
    03a20000 04004000 0c00              l ....@...
   
    <16 bytes per line>
   
   BBED> undo
   BBED> modify /x 1E filename '/oradata/ora10/system01.dbf' block 4. offset 0.
    File: /oradata/ora10/system01.dbf (1)
    Block: 4                Offsets:    0 to    9           Dba:0x00400004
   ------------------------------------------------------------------------
    1ea20000 04004000 0c00
   
    <32 bytes per line>
   
   
   BBED> undo
   BBED> modify /x 03 filename '/oradata/ora10/system01.dbf' block 4. offset 0.
    File: /oradata/ora10/system01.dbf (1)
    Block: 4                Offsets:    0 to    9           Dba:0x00400004
   ------------------------------------------------------------------------
    03a20000 04004000 0c00
   
    <32 bytes per line>

HELP [ <bbed command> | ALL ]

显示帮助信息

   BBED> help f
   FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
   
   BBED> help m
   MODIFY[/x|d|u|o|c] numeric/character string
         [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
   
   BBED> help p
   PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
   
   BBED> help x
   EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
   </Nuf>:
   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
   
   BBED> 


VERIFY [ DBA | FILE | FILENAME | BLOCK ]   

校验块的完整性

修改块后要重新计算chksum值。为了做测试,不应用新的chksum值,这时做校验,就会出现坏块

  BBED> sum 
  Check value for File 1, Block 1:
   current = 0x73a8, required = 0x73ab
   
   BBED> verify
   DBVERIFY - Verification starting
   FILE = /oradata/ora10/system01.dbf
   BLOCK = 1
   
   Block 1 is corrupt
   Corrupt block relative dba: 0x00400001 (file 0, block 1)
   Bad header found during verification
   Data in bad block:
    type: 11 format: 2 rdba: 0x00400002
    last change scn: 0x0000.00000000 seq: 0x1 flg: 0x04
    spare1: 0x0 spare2: 0x0 spare3: 0x0
    consistency value in tail: 0x00000b01
    check value in block header: 0x73a8
    computed block checksum: 0x3
   
   
   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> 

CORRUPT [ DBA | FILE | FILENAME | BLOCK ]           

设置块为坏块,更改seq_kcbh(offset 14)为0xff

   BBED> p kcvfhbfh
   struct kcvfhbfh, 20 bytes                   @0       
      ub1 type_kcbh                            @0        0x0b
      ub1 frmt_kcbh                            @1        0xa2
      ub1 spare1_kcbh                          @2        0x00
      ub1 spare2_kcbh                          @3        0x00
      ub4 rdba_kcbh                            @4        0x00400002
      ub4 bas_kcbh                             @8        0x00000000
      ub2 wrp_kcbh                             @12       0x0000
      ub1 seq_kcbh                             @14       0x01
      ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
      ub2 chkval_kcbh                          @16       0x73a8
      ub2 spare3_kcbh                          @18       0x0000
   
   BBED> corrupt
   Block marked media corrupt.
   
   BBED> p kcvfhbfh
   struct kcvfhbfh, 20 bytes                   @0       
      ub1 type_kcbh                            @0        0x0b
      ub1 frmt_kcbh                            @1        0xa2
      ub1 spare1_kcbh                          @2        0x00
      ub1 spare2_kcbh                          @3        0x00

      ub4 rdba_kcbh                            @4        0x00400001     

      ub4 bas_kcbh                             @8        0x00000000
      ub2 wrp_kcbh                             @12       0x0000
      ub1 seq_kcbh                             @14       0xff
      ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
      ub2 chkval_kcbh                          @16       0x73a8
      ub2 spare3_kcbh                          @18       0x0000
   
   BBED> 


Reference

http://orafaq.com/papers/dissassembling_the_data_block.pdf

Understanding Datafile Header kcvfh structure


关键词:bbed 

相关文章

如何用BBED使Offline的数据文件Online
如何使用BBED
如何安装BBED

联系我们

韩朝阳



    Phone:186-9589-1286

    E-mail:ohsdba@qq.com

    微  信: ohsdba


电话(186-9589-1286)

QQ(375349564)

微信(ohsdba)


常用链接

Oracle
eDelivery
My Oracle Support

Exadata 12.1 Document

Exadata 12.2 Document

Oracle 11gR2 Document

Oracle 12cR1 Document

Oracle 12cR2 Document

GoldenGate 12c

Oracle Fusion Middleware

Mysql Document

PostgreSQL

Python

github

sourceforge



Top
Cell186-9589-1286
QQ 375349564
E-mail ohsdba@qq.com