暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

oracle 通过bbed 观察数据文件头

原创 四九年入国军 2025-04-23
139
BBED> map /v
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1                                     Dba:0x01c00001
------------------------------------------------------------
 Data File Header

 struct kcvfh, 1272 bytes                   @0       
    struct kcvfhbfh, 20 bytes               @0         --块头,主要包含blockrdba地址和block标志(是否坏块)
    struct kcvfhhdr, 76 bytes               @20        --头部结构,主要包括版本号,dbiddbname,文件大小,文件类型等
    ub4 kcvfhrdb                            @96      
    struct kcvfhcrs, 8 bytes                @100       --create 时候的scn ,重要
    ub4 kcvfhcrt                            @108       --create  scn 对应的时间戳
    ub4 kcvfhrlc                            @112       --resetlogs  scn 对应的时间戳  
    struct kcvfhrls, 8 bytes                @116       --包含有resetlogs scn,重要
    ub4 kcvfhbti                            @124     
    struct kcvfhbsc, 8 bytes                @128       --意义不大,跟备份有关  SCN allocated when last backup started  
    ub2 kcvfhbth                            @136     
    ub2 kcvfhsta                            @138     
    struct kcvfhckp, 36 bytes               @484       --checkpoint 信息:包含检查点信息,如检查点SCN和时间戳
    ub4 kcvfhcpc                            @140       --datafile checkpoint count
    ub4 kcvfhrts                            @144       
    ub4 kcvfhccc                            @148     
    struct kcvfhbcp, 36 bytes               @152      --和备份相关,没啥意义   
    ub4 kcvfhbhz                            @312     
    struct kcvfhxcd, 16 bytes               @316      --不需要关注,没啥意义
    sword kcvfhtsn                          @332      -- 表空间编号  v$tablespace.ts#
    ub2 kcvfhtln                            @336      --表空间长度
    text kcvfhtnm[30]                       @338      --表空间名字
    ub4 kcvfhrfn                            @368     
    struct kcvfhrfs, 8 bytes                @372      --fuzzy scn (追踪数据一致性的标志,模糊标记)  必须为0,如果!=0,oracle提示需要恢复
    ub4 kcvfhrft                            @380     
    struct kcvfhafs, 8 bytes                @384      --fuzzy scn,数据文件需不需要恢复取决于当前scn是否大于这个fuzzy scn
    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       --前一次resetlogs 的scn
    struct kcvfhprfs, 8 bytes               @428     
    ub4 kcvfhtrt                            @444     

 ub4 tailchk                                @8188      --校验块的完整性,由 kcvfhbfh 里面的type_kcbh 和seq_kcbh 组合的


BBED> 


 1>
--文件头
BBED> p kcvfhbfh
struct kcvfhbfh, 20 bytes                   @0       
   ub1 type_kcbh                            @0        0x0b                     --type类型
   ub1 frmt_kcbh                            @1        0xa2                     --块格式类型
   ub2 wrp2_kcbh                            @2        0x0000
   ub4 rdba_kcbh                            @4        0x00400001               --block   dba地址(复制的其他block记得修改这个值)
   ub4 bas_kcbh                             @8        0x00000000
   ub2 wrp_kcbh                             @12       0x0000
   ub1 seq_kcbh                             @14       0x01                     --sequence 编号,如果是坏块的话,会被标记为0xff
   ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)          --标记
   ub2 chkval_kcbh                          @16       0x97a2                   --校验值    
   ub2 spare3_kcbh                          @18       0x0000

BBED> 

2>
--头部结构
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes                   @20      
   ub4 kccfhswv                             @20       0x00000000  
   ub4 kccfhcvn                             @24       0x13000000        --版本信息,16进制的13=19
   ub4 kccfhdbi                             @28       0x66b562f3        --dbid
   text kccfhdbn[0]                         @32      O                  --从这里可以看到数据文件的名字最长不能超过8
   text kccfhdbn[1]                         @33      R
   text kccfhdbn[2]                         @34      C
   text kccfhdbn[3]                         @35      L
   text kccfhdbn[4]                         @36       
   text kccfhdbn[5]                         @37       
   text kccfhdbn[6]                         @38       
   text kccfhdbn[7]                         @39       
   ub4 kccfhcsq                             @40       0x00000797       --controlfile sequence  number ,不重要
   ub4 kccfhfsz                             @44       0x0001bd00       --文件大小
   s_blkz kccfhbsz                          @48       0x00
   ub2 kccfhfno                             @52       0x0001           --文件编号
   ub2 kccfhtyp                             @54       0x0003           --block 类型,3=数据文件(1是控制文件,2是redo文件)
   ub4 kccfhacid                            @56       0x00000000
   ub4 kccfhcks                             @60       0x00000000
   text kccfhtag[0]                         @64       

--和前面 dump 的文件头信息一致
	Compatibility Vsn = 318767104=0x13000000
	Db ID=1723163379=0x66b562f3, Db Name='ORCL'
	Activation ID=0=0x0
	Control Seq=1943=0x797, File size=113920=0x1bd00
	File Number=1, Blksiz=8192, File Type=3 DATA
3>
	
BBED> p kcvfhcrs
struct kcvfhcrs, 8 bytes                    @100     
   ub4 kscnbas                              @100      0x00000009     --create 时候的scn ,重要
   ub2 kscnwrp                              @104      0x8000
   ub2 kscnwrp2                             @106      0x0000
   
4>
BBED> p kcvfhrls
struct kcvfhrls, 8 bytes                    @116     
   ub4 kscnbas                              @116      0x001d4fd1       --resetlogs  scn
   ub2 kscnwrp                              @120      0x8000
   ub2 kscnwrp2                             @122      0x0000


5>
BBED> p kcvfhbsc
struct kcvfhbsc, 8 bytes                    @128     
   ub4 kscnbas                              @128      0x00000000    --意义不大,跟备份有关  SCN allocated when last backup started
   ub2 kscnwrp                              @132      0x0000
   ub2 kscnwrp2                             @134      0x0000

6>
BBED> 
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes                   @484     
   struct kcvcpscn, 8 bytes                 @484     
      ub4 kscnbas                           @484      0x0021ccb6     --checkpoint scn  ,重要
      ub2 kscnwrp                           @488      0x8000
      ub2 kscnwrp2                          @490      0x0000
   ub4 kcvcptim                             @492      0x477a3884     --checkpoint time
   ub2 kcvcpthr                             @496      0x0001         --checkpoint thread
   union u, 12 bytes                        @500     
      struct kcvcprba, 12 bytes             @500     
         ub4 kcrbaseq                       @500      0x00000007     --checkpoint  rba  sequence
         ub4 kcrbabno                       @504      0x00000002     --checkpoint   rba number
         ub2 kcrbabof                       @508      0x0010         --offset,固定值
   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
   
   
7>   和备份相关,没啥意义
BBED> p kcvfhbcp
struct kcvfhbcp, 36 bytes                   @152     
   struct kcvcpscn, 8 bytes                 @152     
      ub4 kscnbas                           @152      0x00000000
      ub2 kscnwrp                           @156      0x0000
      ub2 kscnwrp2                          @158      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   
   
   
8>
BBED> p kcvfhrfs
struct kcvfhrfs, 8 bytes                    @372     
   ub4 kscnbas                              @372      0x00000000   --fuzzy scn(追踪数据一致性的标志,模糊标记)  必须为0,如果!=0,oracle提示需要恢复
   ub2 kscnwrp                              @376      0x0000
   ub2 kscnwrp2                             @378      0x0000


9>    对应 x$kcvfh.fhafs
BBED> p kcvfhafs
struct kcvfhafs, 8 bytes                    @384     
   ub4 kscnbas                              @384      0x00000000   --绝对fuzzy scn ,数据库必须要恢复到这个scn的点,数据库才能open
   ub2 kscnwrp                              @388      0x0000
   ub2 kscnwrp2                             @390      0x0000
   
   
   
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论