ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle 使用BBED 查看 ASM Disk Header 内容

Oracle 使用BBED 查看 ASM Disk Header 内容

原创 Linux操作系统 作者:roominess 时间:2012-03-31 11:13:11 0 删除 编辑

RAC ASM由于其高度的封装性,使得我们很难知道窥探其内部的原理。ASM如果一旦出现问题,通常都很难处理。即便在有很完备的RMAN备份的情况下,恢复起来都可能需要很长的时间。

       而ASM 中最为脆弱的又是ASM disk header。如果disk header逻辑损坏了,即corrupt了,整个disk group将不能够mount,依赖于ASM实例的database也将不能够startup。

       那么asm disk header里到底保存了什么信息? 这个可以使用KFED 命令或者BBED 命令来查看。

 

       Roger同学整理过使用BBED 查看disk header 的文章,所以这个测试就按照Roger 的实验步骤来操作。

       原文链接如下:

              http://ms.itpub.net/viewthread.php?tid=1370753

      

 

一.  KFOD查看disk header 的内容

使用KFED 查看,之前整理了一篇blog,具体参考:

              Oracle KFED 和 KFOD 工具说明

              OracleASM是个封装的磁盘管理工具,所以我们需要对ASM 有充分的认识,否则ASM 出现问题就会非常棘手,KFED 和KFOD 两个命令可以帮助我们了解ASM。

 

一. KFED(Kernel Files Editor) 说明

       KFED是ORACLE 10gR2 自带的一个工具,但是和BBED 命令一样,需要编译过以后才能使用。

 

1.1 编译KFED

[oracle@rac2 lib]$cd $ORACLE_HOME/rdbms/lib

[oracle@rac2 lib]$ pwd

/u01/app/oracle/product/10.2.0/db_1/rdbms/lib

[oracle@rac2 lib]$ make -f ins_rdbms.mk ikfed

 

Linking KFED utility (kfed)

rm -f/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/kfed

gcc -o/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/kfed-L/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/-L/u01/app/oracle/product/10.2.0/db_1/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/stubs/-L/usr/lib -lirc /u01/app/oracle/product/10.2.0/db_1/lib/s0main.o/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/sskfeded.o/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/skfedpt.o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/defopt.o -ldbtools10-lclntsh  `cat/u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10-ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10-ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lmm -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10-lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat/u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10-ln10 -lnnz10 -lnl10 -lnro10 `cat/u01/app/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10-ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10  -lsnls10 -lnls10  -lcore10-lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10-lnls10 -lcore10 -lnls10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10  -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10-lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10   `cat/u01/app/oracle/product/10.2.0/db_1/lib/sysliblist`-Wl,-rpath,/u01/app/oracle/product/10.2.0/db_1/lib -lm    `cat /u01/app/oracle/product/10.2.0/db_1/lib/sysliblist`-ldl -lm   -L/u01/app/oracle/product/10.2.0/db_1/lib

mv -f/u01/app/oracle/product/10.2.0/db_1/bin/kfed/u01/app/oracle/product/10.2.0/db_1/bin/kfedO

mv: cannot stat`/u01/app/oracle/product/10.2.0/db_1/bin/kfed': No such file or directory

make: [ikfed] Error 1 (ignored)

mv /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/kfed/u01/app/oracle/product/10.2.0/db_1/bin/kfed

chmod 751/u01/app/oracle/product/10.2.0/db_1/bin/kfed

[oracle@rac2 lib]$

 

--查看KFED 位置

[oracle@rac2 lib]$ which kfed

/u01/app/oracle/product/10.2.0/db_1/bin/kfed

 

1.2 KFED 命令使用

--查看KFED 帮助

[oracle@rac2 lib]$ kfed -h

as/mlib         ASM Library [asmlib='lib']

aun/um          AU number to examine or update[AUNUM=number]

aus/z           Allocation Unit size in bytes[AUSZ=number]

blkn/um         Block number to examine or update[BLKNUM=number]

blks/z          Metadata block size in bytes[BLKSZ=number]

ch/ksum         Update checksum before each write[CHKSUM=YES/NO]

cn/t            Count of AUs to process[CNT=number]

d/ev            ASM device to examine or update[DEV=string]

o/p             KFED operation type [OP=READ/WRITE/MERGE/NEW/FORM/FIND/STRUCT]

p/rovnm         Name for provisioning purposes[PROVNM=string]

s/eek           AU number to seek to [SEEK=number]

te/xt           File name for translated block text[TEXT=string]

ty/pe           ASM metadata block type number[TYPE=number]

 

--查看ASM磁盘组的情况

SYS@anqing2(rac2)> select group_number,disk_number,mount_status,header_status,state,name,path fromv$asm_disk;

 

group_number disk_number mount_sheader_statu state    name       path

------------ ----------- ------------------- -------- ---------- --------------------

1   0OPENED  UNKNOWN   NORMAL  DATA       /dev/mapper/datap1

2   0OPENED  UNKNOWN   NORMAL   FRA_0000  /dev/mapper/frap1

 

SYS@anqing2(rac2)> selectdg.group_number "g.no",dg.name,d.disk_number,d.mount_status,

  2 d.header_status,dg.type,d.name,d.path from v$asm_disk d,v$asm_diskgroupdg

  3 where dg.group_number=d.group_number;

 

g.no NAME       DISK_NUMBER MOUNT_S HEADER_STATUTYPE   NAME       PATH

---------- --------------------- ------- ------------ ------ ---------- ---------------------------

1 DATA                 0 OPENED  UNKNOWN     EXTERN DATA      /dev/mapper/datap1

2 FRA                  0 OPENED  UNKNOWN     EXTERN FRA_0000  /dev/mapper/frap1

 

 

--从系统层面上查看

[oracle@rac2 ~]$ /etc/init.d/oracleasm listdisks

DATA

FRA

[oracle@rac2 ~]$ ls -lrt /dev/oracleasm/disks/*

brw-rw---- 1 oracle dba 8, 49 Aug  7 07:32 /dev/oracleasm/disks/FRA

brw-rw---- 1 oracle dba 8, 65 Aug  7 07:32 /dev/oracleasm/disks/DATA

 

 

--使用KFED查看ASM磁盘组

[oracle@rac2 ~]$ kfed read /dev/mapper/datap1 text=datap1.txt

[oracle@rac2 ~]$ ls

datap1.txt Desktop  oradiag_oracle

[oracle@rac2 ~]$ cat datap1.txt

...

kfed 命令可以加text或者不加,如果使用text 参数,那么kfed 读取的内容会保存到text 指定的文档,如果不使用就直接输入到屏幕。

 

[oracle@rac2 ~]$ kfed read /dev/mapper/datap1

kfbh.endian:                          1 ; 0x000: 0x01

kfbh.hard:                          130 ; 0x001: 0x82

kfbh.type:                            1 ; 0x002:KFBTYP_DISKHEAD

kfbh.datfmt:                          1 ; 0x003: 0x01

kfbh.block.blk:                       0 ; 0x004: T=0 NUMB=0x0

kfbh.block.obj:              2147483648 ; 0x008: TYPE=0x8NUMB=0x0

kfbh.check:                  1508168608 ; 0x00c:0x59e4d3a0

kfbh.fcn.base:                        0 ; 0x010: 0x00000000

kfbh.fcn.wrap:                        0 ; 0x014: 0x00000000

kfbh.spare1:                          0 ; 0x018: 0x00000000

kfbh.spare2:                          0 ; 0x01c: 0x00000000

kfdhdb.driver.provstr:     ORCLDISKDATA ; 0x000: length=12

-->磁盘卷名

kfdhdb.driver.reserved[0]:   1096040772 ; 0x008: 0x41544144

kfdhdb.driver.reserved[1]:            0 ; 0x00c: 0x00000000

kfdhdb.driver.reserved[2]:            0 ; 0x010: 0x00000000

kfdhdb.driver.reserved[3]:            0 ; 0x014: 0x00000000

kfdhdb.driver.reserved[4]:            0 ; 0x018: 0x00000000

kfdhdb.driver.reserved[5]:            0 ; 0x01c: 0x00000000

kfdhdb.compat:                168820736 ; 0x020: 0x0a100000

kfdhdb.dsknum:                        0 ; 0x024: 0x0000

kfdhdb.grptyp:                        1 ; 0x026:KFDGTP_EXTERNAL

--> This indicatesRedundancy for Group.Check TYPE in query output.

kfdhdb.hdrsts:                        3 ; 0x027:KFDHDR_MEMBER

--> This indicatesDisk Header status. Here it indicates it is member of Group.

kfdhdb.dskname:                    DATA ; 0x028: length=4

--> This indicatesDisk Name

kfdhdb.grpname:                    DATA ; 0x048: length=4

--> This indicates theGroup Name for the disk.

kfdhdb.fgname:                     DATA ; 0x068: length=4

--> This indicates theFailure Group Name.

kfdhdb.capname:                         ; 0x088: length=0

kfdhdb.crestmp.hi:             32952076 ; 0x0a8: HOUR=0xcDAYS=0x18 MNTH=0x3 YEAR=0x7db

kfdhdb.crestmp.lo:           3374491648 ; 0x0ac: USEC=0x0MSEC=0xaa SECS=0x12 MINS=0x32

kfdhdb.mntstmp.hi:             32955120 ; 0x0b0: HOUR=0x10DAYS=0x17 MNTH=0x6 YEAR=0x7db

kfdhdb.mntstmp.lo:           3440417792 ; 0x0b4: USEC=0x0MSEC=0x27 SECS=0x11 MINS=0x33

kfdhdb.secsize:                     512 ; 0x0b8: 0x0200

kfdhdb.blksize:                    4096 ; 0x0ba: 0x1000

kfdhdb.ausize:                  1048576 ; 0x0bc: 0x00100000

kfdhdb.mfact:                    113792 ; 0x0c0: 0x0001bc80

kfdhdb.dsksize:                   11993 ; 0x0c4: 0x00002ed9

kfdhdb.pmcnt:                         2 ; 0x0c8: 0x00000002

kfdhdb.fstlocn:                       1 ; 0x0cc: 0x00000001

kfdhdb.altlocn:                       2 ; 0x0d0: 0x00000002

kfdhdb.f1b1locn:                      2 ; 0x0d4: 0x00000002

kfdhdb.redomirrors[0]:                0 ; 0x0d8: 0x0000

kfdhdb.redomirrors[1]:                0 ; 0x0da: 0x0000

kfdhdb.redomirrors[2]:                0 ; 0x0dc: 0x0000

kfdhdb.redomirrors[3]:                0 ; 0x0de: 0x0000

kfdhdb.dbcompat:              168820736 ; 0x0e0: 0x0a100000

kfdhdb.grpstmp.hi:             32952076 ; 0x0e4: HOUR=0xcDAYS=0x18 MNTH=0x3 YEAR=0x7db

kfdhdb.grpstmp.lo:           3374396416 ; 0x0e8: USEC=0x0MSEC=0x4d SECS=0x12 MINS=0x32

kfdhdb.ub4spare[0]:                   0 ; 0x0ec: 0x00000000

kfdhdb.ub4spare[1]:                   0 ; 0x0f0: 0x00000000

kfdhdb.ub4spare[2]:                   0 ; 0x0f4: 0x00000000

kfdhdb.ub4spare[3]:                   0 ; 0x0f8: 0x00000000

kfdhdb.ub4spare[4]:                   0 ; 0x0fc: 0x00000000

kfdhdb.ub4spare[5]:                   0 ; 0x100: 0x00000000

kfdhdb.ub4spare[6]:                   0 ; 0x104: 0x00000000

kfdhdb.ub4spare[7]:                   0 ; 0x108: 0x00000000

kfdhdb.ub4spare[8]:                   0 ; 0x10c: 0x00000000

kfdhdb.ub4spare[9]:                   0 ; 0x110: 0x00000000

kfdhdb.ub4spare[10]:                  0 ; 0x114: 0x00000000

kfdhdb.ub4spare[11]:                  0 ; 0x118: 0x00000000

kfdhdb.ub4spare[12]:                  0 ; 0x11c: 0x00000000

kfdhdb.ub4spare[13]:                  0 ; 0x120: 0x00000000

kfdhdb.ub4spare[14]:                  0 ; 0x124: 0x00000000

kfdhdb.ub4spare[15]:                  0 ; 0x128: 0x00000000

kfdhdb.ub4spare[16]:                  0 ; 0x12c: 0x00000000

kfdhdb.ub4spare[17]:                  0 ; 0x130: 0x00000000

kfdhdb.ub4spare[18]:                  0 ; 0x134: 0x00000000

kfdhdb.ub4spare[19]:                  0 ; 0x138: 0x00000000

kfdhdb.ub4spare[20]:                  0 ; 0x13c: 0x00000000

kfdhdb.ub4spare[21]:                  0 ; 0x140: 0x00000000

kfdhdb.ub4spare[22]:                  0 ; 0x144: 0x00000000

kfdhdb.ub4spare[23]:                  0 ; 0x148: 0x00000000

kfdhdb.ub4spare[24]:                  0 ; 0x14c: 0x00000000

kfdhdb.ub4spare[25]:                  0 ; 0x150: 0x00000000

kfdhdb.ub4spare[26]:                  0 ; 0x154: 0x00000000

kfdhdb.ub4spare[27]:                  0 ; 0x158: 0x00000000

kfdhdb.ub4spare[28]:                  0 ; 0x15c: 0x00000000

kfdhdb.ub4spare[29]:                  0 ; 0x160: 0x00000000

kfdhdb.ub4spare[30]:                  0 ; 0x164: 0x00000000

kfdhdb.ub4spare[31]:                  0 ; 0x168: 0x00000000

kfdhdb.ub4spare[32]:                  0 ; 0x16c: 0x00000000

kfdhdb.ub4spare[33]:                  0 ; 0x170: 0x00000000

kfdhdb.ub4spare[34]:                  0 ; 0x174: 0x00000000

kfdhdb.ub4spare[35]:                  0 ; 0x178: 0x00000000

kfdhdb.ub4spare[36]:                  0 ; 0x17c: 0x00000000

kfdhdb.ub4spare[37]:                  0 ; 0x180: 0x00000000

kfdhdb.ub4spare[38]:                  0 ; 0x184: 0x00000000

kfdhdb.ub4spare[39]:                  0 ; 0x188: 0x00000000

kfdhdb.ub4spare[40]:                  0 ; 0x18c: 0x00000000

kfdhdb.ub4spare[41]:                  0 ; 0x190: 0x00000000

kfdhdb.ub4spare[42]:                  0 ; 0x194: 0x00000000

kfdhdb.ub4spare[43]:                  0 ; 0x198: 0x00000000

kfdhdb.ub4spare[44]:                  0 ; 0x19c: 0x00000000

kfdhdb.ub4spare[45]:                  0 ; 0x1a0: 0x00000000

kfdhdb.ub4spare[46]:                  0 ; 0x1a4: 0x00000000

kfdhdb.ub4spare[47]:                  0 ; 0x1a8: 0x00000000

kfdhdb.ub4spare[48]:                  0 ; 0x1ac: 0x00000000

kfdhdb.ub4spare[49]:                  0 ; 0x1b0: 0x00000000

kfdhdb.ub4spare[50]:                  0 ; 0x1b4: 0x00000000

kfdhdb.ub4spare[51]:                  0 ; 0x1b8: 0x00000000

kfdhdb.ub4spare[52]:                  0 ; 0x1bc: 0x00000000

kfdhdb.ub4spare[53]:                  0 ; 0x1c0: 0x00000000

kfdhdb.ub4spare[54]:                  0 ; 0x1c4: 0x00000000

kfdhdb.ub4spare[55]:                  0 ; 0x1c8: 0x00000000

kfdhdb.ub4spare[56]:                  0 ; 0x1cc: 0x00000000

kfdhdb.ub4spare[57]:                  0 ; 0x1d0: 0x00000000

kfdhdb.acdb.aba.seq:                  0 ; 0x1d4: 0x00000000

kfdhdb.acdb.aba.blk:                  0 ; 0x1d8: 0x00000000

kfdhdb.acdb.ents:                     0 ; 0x1dc: 0x0000

kfdhdb.acdb.ub2spare:                 0 ; 0x1de: 0x0000

 

 

1.3 ASM 磁盘里的一些名词解释

(1)kfbh.endian

    kf3.h  /*endianness of writer */

      Littleendian = 1

      Bigendian = 0

 

(2) kfbh.hard  

    kf3.h  /*H.A.R.D. magic # and block size */

 

(3) kfbh.type

   kf3.h   /*metadata blocktype              */

 

(4) kfbh.datfmt

   kf3.h  /*metadata block data format       */

 

(5) kfbh.block

   kf3.h  /* blocklocation of thisblock     */               

     blk -- Diskheader should have T=0 and NUMB=0x0

     obj -- Diskheader should have TYPE=0x8 NUMB=

   blk and obj values arederived from a series of macros in kf3.h. See

 

   "KFBL Macros"in kf3.h for more information.

 

(6) kfbh.check

   kf3.h  /* checkvalue to verify consistency */

 

(7) kfbh.fcn

   kf3.h  /*change number of last change     */-

 

(8) kfdhdb.driver

   kf3.h  /*OSMLIB driver reserved block */

      If nodriver is defined "ORCLDISK" is used.

 

(9) kfdhdb.compat

   kf3.h  /*Comaptible software version  */

     example:0x0a100000

     Youget:    

         a=101=1 so 10.1.0.0.0

 

(10) kfdhdb.dsknum

   kf3.h  /* OSMdisknumber              *

     This is thedisk number. The first disk being "0". There can be up to

     ub2 disks ina diskgroup. This allows for 65336 disks 0 through 65335.

 

(11) kfdhdb.grptyp

   kf3.h  /* Diskgrouptype              */

 

(12) kfdhdb.hdrsts

   kf3.h  /* Diskheaderstatus           */

     This is whatis used to determine if a disk is available or not to

     thediskgroup. 0x03 is the correct value for a valid status.

 

 (13)kfdhdb.dskname  /*OSMdisk name      */

 (14)kfdhdb.grpname  /*OSM disk group name */

 (15)kfdhdb.fgname   /*Failure group name */

 (16)kfdhdb.capname  /*Capacity grp, unused*/   

 (17)kfdhdb.crestmp  /*Creationtimestamp           */

 (18)kfdhdb.mntstmp  /*Mounttimestamp              */

       kf3.hTo derive the hi and low time`from an unformated dump use the

   "KFTS Macros" inkf3.h.

 

(19) kfdhdb.secsize

   kf3.h  /* Disksector size (bytes)     */

     This is thephysical sector size of the disk in bytes. All I/O's to the

     disk aredescribed in physical sectors. This must be a power of 2. An

     ideal valuewould be 4096, but most disks are formatted with 512 byte

     sectors.(from asmlib.h)

 

(20) kfdhdb.blksize

   kf3.h  /*Metadata block (bytes)       */

 

(21) kfdhdb.ausize

   kf3.h  /*Allocation Unit (bytes)      */

   

(22) kfdhdb.mfact

   kf3.h  /*Stride between phys addr AUs */

   

(23) kfdhdb.dsksize

   kf3.h  /* Disksize inAUs             */

     Mulitply byAUs to get actual size of disk when added.

     

(24) kfdhdb.pmcnt

   kf3.h  /*Permanent phys addressed AUs */

     Number ofphysically addressed allocation units.

     

(25) kfdhdb.fstlocn

   kf3.h  /* FirstFreeSpace table blk num */

     Used to findfreespace.

     

(26) kfdhdb.altlocn

   kf3.h  /* FirstAlocation table blk num */

     Used to findalocated space.

     

(27) kfdhdb.f1b1locn

   kf3.h  /* FileDirectory blk 1 AU num  */

     Beginging forfile directory.

 

1.4 一个损坏了的disk的KFED 结果

kfbh.endian: 83 ; 0×000: 0×53
kfbh.hard: 0 ; 0×001: 0×00
kfbh.type: 0 ; 0×002: KFBTYP_INVALID
kfbh.datfmt: 0 ; 0×003: 0×00
kfbh.block.blk: 4294967293 ; 0×004: T=1 NUMB=0x7ffffffd
kfbh.block.obj: 65286 ; 0×008: TYPE=0×0 NUMB=0xff06
kfbh.check: 144 ; 0x00c: 0×00000090
kfbh.fcn.base: 136903976 ; 0×010: 0x0828fd28
kfbh.fcn.wrap: 4294953840 ; 0×014: 0xffffcb70
kfbh.spare1: 136905029 ; 0×018: 0×08290145
kfbh.spare2: 30000 ; 0x01c: 0×00007530

 

二.KFOD ( OSM Discovery utility )说明

       这里的OSM是:Order and Service Management,KFOD 命令可以在系统级别对来查找ASM。也可以用来监控ASM.

 

2.1 KFOD的帮助

[oracle@rac2 ~]$ kfod -h

_asm_a/llow_only_raw_disks              KFOD allow only raw devices[_asm_allow_only_raw_disks=TRUE/(FALSE)]

_asm_l/ibraries         ASMLibraries[_asm_libraries='lib1','lib2',...]

_asms/id                ASM Instance[_asmsid=sid]

a/sm_diskstring         ASM Diskstring[asm_diskstring='discoverystring', 'discoverystring' ...]

d/isks          Disks to discover [disks=raw,asm,all]

g/roup          Group discover [group=controlfile]

n/ohdr          KFOD header suppression[nohdr=TRUE/(FALSE)]

o/p             KFOD options type[OP=DISKS/GROUPS/ALL]

p/file          ASM parameter file[pfile='parameterfile']

s/tatus         Include disk header status[status=TRUE/(FALSE)]

v/erbose                KFOD verbose errors[verbose=TRUE/(FALSE)]

 

 

2.2 KFOD 示例

[oracle@rac2 ~]$kfod 

--------------------------------------------------------------------------------

ORACLE_SID ORACLE_HOME                                                         

================================================================================

    +ASM2 /u01/app/oracle/product/10.2.0/db_1                                 

    +ASM1 /u01/app/oracle/product/10.2.0/db_1    

 

[oracle@rac2 ~]$ kfod disk=all

--------------------------------------------------------------------------------

 Disk         Size Path     

================================================================================

  1:        101 Mb /dev/raw/raw1

  2:        101 Mb /dev/raw/raw2

  3:        101 Mb /dev/raw/raw3

  4:        101 Mb /dev/raw/raw4

  5:        101 Mb /dev/raw/raw5

  6:        101 Mb /dev/raw/raw6

  7:        101 Mb /dev/raw/raw7

  8:        101 Mb /dev/raw/raw8

--------------------------------------------------------------------------------

ORACLE_SID ORACLE_HOME                                                         

================================================================================

    +ASM2 /u01/app/oracle/product/10.2.0/db_1                                 

    +ASM1 /u01/app/oracle/product/10.2.0/db_1   

 

 

[oracle@rac2 ~]$ kfod p=disks

--------------------------------------------------------------------------------

 Disk         Size Path     

================================================================================

  1:        101 Mb /dev/raw/raw3

  2:        101 Mb /dev/raw/raw4

  3:        101 Mb /dev/raw/raw8

 

 

       这篇就简单的介绍一下这2个命令, 在下篇ASM disk header 的备份与恢复中在详细的看一下这2个命令的使用。

 

这里直接截取disk header的内容:

[oracle@rac2 ~]$ kfed read/dev/mapper/datap1

kfbh.endian:                         1 ; 0x000: 0x01

kfbh.hard:                         130 ; 0x001: 0x82

kfbh.type:                           1 ; 0x002:KFBTYP_DISKHEAD

kfbh.datfmt:                         1 ; 0x003: 0x01

kfbh.block.blk:                      0 ; 0x004: T=0 NUMB=0x0

kfbh.block.obj:             2147483648 ; 0x008: TYPE=0x8NUMB=0x0

kfbh.check:                 1508168608 ; 0x00c:0x59e4d3a0

kfbh.fcn.base:                       0 ; 0x010: 0x00000000

kfbh.fcn.wrap:                       0 ; 0x014: 0x00000000

kfbh.spare1:                         0 ; 0x018: 0x00000000

kfbh.spare2:                         0; 0x01c: 0x00000000

kfdhdb.driver.provstr:    ORCLDISKDATA ; 0x000: length=12

-->磁盘卷名

kfdhdb.driver.reserved[0]:  1096040772 ; 0x008: 0x41544144

kfdhdb.driver.reserved[1]:           0 ; 0x00c: 0x00000000

kfdhdb.driver.reserved[2]:           0 ; 0x010: 0x00000000

kfdhdb.driver.reserved[3]:           0 ; 0x014: 0x00000000

kfdhdb.driver.reserved[4]:           0 ; 0x018: 0x00000000

kfdhdb.driver.reserved[5]:           0 ; 0x01c: 0x00000000

kfdhdb.compat:               168820736 ; 0x020: 0x0a100000

kfdhdb.dsknum:                       0 ; 0x024: 0x0000

kfdhdb.grptyp:                       1 ; 0x026:KFDGTP_EXTERNAL

--> ThisindicatesRedundancy for Group.Check TYPE in query output.

kfdhdb.hdrsts:                       3 ; 0x027:KFDHDR_MEMBER

--> This indicatesDiskHeader status. Here it indicates it is member of Group.

kfdhdb.dskname:                   DATA ; 0x028: length=4

--> This indicatesDiskName

kfdhdb.grpname:                   DATA ; 0x048: length=4

--> This indicatestheGroup Name for the disk.

kfdhdb.fgname:                    DATA ; 0x068: length=4

--> This indicatestheFailure Group Name.

kfdhdb.capname:                        ; 0x088: length=0

kfdhdb.crestmp.hi:            32952076 ; 0x0a8: HOUR=0xcDAYS=0x18 MNTH=0x3 YEAR=0x7db

kfdhdb.crestmp.lo:          3374491648 ; 0x0ac: USEC=0x0MSEC=0xaa SECS=0x12 MINS=0x32

kfdhdb.mntstmp.hi:            32955120 ; 0x0b0: HOUR=0x10DAYS=0x17 MNTH=0x6 YEAR=0x7db

kfdhdb.mntstmp.lo:          3440417792 ; 0x0b4: USEC=0x0MSEC=0x27 SECS=0x11 MINS=0x33

kfdhdb.secsize:                    512 ; 0x0b8: 0x0200

kfdhdb.blksize:                   4096 ; 0x0ba: 0x1000

kfdhdb.ausize:                 1048576 ; 0x0bc: 0x00100000

kfdhdb.mfact:                   113792 ; 0x0c0: 0x0001bc80

kfdhdb.dsksize:                  11993 ; 0x0c4: 0x00002ed9

kfdhdb.pmcnt:                        2 ; 0x0c8: 0x00000002

kfdhdb.fstlocn:                      1 ; 0x0cc: 0x00000001

kfdhdb.altlocn:                      2 ; 0x0d0: 0x00000002

kfdhdb.f1b1locn:                     2 ; 0x0d4: 0x00000002

kfdhdb.redomirrors[0]:               0 ; 0x0d8: 0x0000

kfdhdb.redomirrors[1]:               0 ; 0x0da: 0x0000

kfdhdb.redomirrors[2]:               0 ; 0x0dc: 0x0000

kfdhdb.redomirrors[3]:               0 ; 0x0de: 0x0000

kfdhdb.dbcompat:             168820736 ; 0x0e0: 0x0a100000

kfdhdb.grpstmp.hi:            32952076 ; 0x0e4: HOUR=0xcDAYS=0x18 MNTH=0x3 YEAR=0x7db

kfdhdb.grpstmp.lo:          3374396416 ; 0x0e8: USEC=0x0MSEC=0x4d SECS=0x12 MINS=0x32

kfdhdb.ub4spare[0]:                  0 ; 0x0ec: 0x00000000

kfdhdb.ub4spare[1]:                  0 ; 0x0f0: 0x00000000

......

kfdhdb.ub4spare[55]:                 0 ; 0x1c8: 0x00000000

kfdhdb.ub4spare[56]:                 0 ; 0x1cc: 0x00000000

kfdhdb.ub4spare[57]:                 0 ; 0x1d0: 0x00000000

kfdhdb.acdb.aba.seq:                 0 ; 0x1d4: 0x00000000

kfdhdb.acdb.aba.blk:                 0 ; 0x1d8: 0x00000000

kfdhdb.acdb.ents:                    0 ; 0x1dc: 0x0000

kfdhdb.acdb.ub2spare:                0 ; 0x1de: 0x0000

 

 

二. 使用BBED 查看diskheader

BBED 的使用需要先编译,这个参考:

              Oracle BBED 工具 说明

              http://blog.csdn.net/tianlesoftware/article/details/5006580

 

              Oracle bbed 五个 实用示例

              http://blog.csdn.net/tianlesoftware/article/details/6684505

 

2.1 配置bbed

[oracle@rac2 u01]$ cat bbed.par

blocksize=8192

listfile=/u01/filelist.txt

mode=edit

[oracle@rac2 u01]$

 

2.2 用DD 命令将diskheader 导出

SYS@anqing2(rac2)> select path fromv$asm_disk;

PATH

--------------------------------------------------------------------------------

/dev/mapper/datap1

/dev/mapper/frap1

 

[oracle@rac2 u01]$  ddif=/dev/mapper/datap1 f=/u01/asm_disk_header bs=4096 count=1

1+0 records in

1+0 records out

4096 bytes (4.1 kB) copied, 0.000297071seconds, 13.8 MB/s

[oracle@rac2 u01]$ pwd

/u01

[oracle@rac2 u01]$ ll asm_disk_header

-rw-r--r-- 1 oracle oinstall 4096 Sep  1 10:48 asm_disk_header

[oracle@rac2 u01]$

 

2.3  将导出的disk header 添加到bbed 的filelist里

[oracle@rac2 u01]$ cat filelist.txt

1 /u01/asm_disk_header

 

2.4 开始进行bbed

 [oracle@rac2 lib]$ bbedparfile=/u01/bbed.par

Password:

 

BBED: Release 2.0.0.0.0 - LimitedProduction on Thu Sep 1 10:53:50 2011

 

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

 

************* !!! For Oracle Internal Useonly !!! ***************

 

BBED> show all

        FILE#           1

        BLOCK#          1

              --这里显示的是file:1,block 1

       OFFSET          0

       DBA             0x00400001(4194305 1,1)

       FILENAME       /u01/asm_disk_header

       BIFILE          bifile.bbd

       LISTFILE        /u01/filelist.txt

       BLOCKSIZE       512

       MODE            Edit

       EDIT            Unrecoverable

       IBASE           Dec

       OBASE           Dec

       WIDTH           80

       COUNT           512

       LOGFILE         log.bbd

       SPOOL           No

 

BBED> map /v dba 1,1

--查看block1里的详细信息

 File: /u01/asm_disk_header (1)

 Block: 1                                    Dba:0x00400001

------------------------------------------------------------

 UndoSegment Header

 

 struct kcbh, 20 bytes                      @0      

--kcbh 的结构占用了20个bytes,@表示该信息在block里的偏移量,即offset值

   ub1 type_kcbh                          @0      

   ub1 frmt_kcbh                          @1      

   ub1 spare1_kcbh                        @2      

   ub1 spare2_kcbh                        @3      

   ub4 rdba_kcbh                          @4      

   ub4 bas_kcbh                           @8      

   ub2 wrp_kcbh                           @12     

   ub1 seq_kcbh                           @14     

   ub1 flg_kcbh                            @15     

   ub2 chkval_kcbh                        @16     

   ub2 spare3_kcbh                        @18     

 

 struct ktect, 44 bytes                     @20     

   ub4 ktectspare                         @20     

   word ktecttsn                          @24     

   ub4 ktectobj                           @28     

   ub4 ktectnex                           @32     

   ub2 ktecttbe                           @36     

   ub4 ktectcex                           @40     

   ub4 ktectces                           @44     

   ub4 ktectcbk                           @48     

   struct ktectxid, 8 bytes               @52     

   ub1 ktectlck                           @60     

 

 struct ktetb[1], 8 bytes                   @64     

   ub4 ktetbdba                           @64     

   ub4 ktetbnbk                           @68     

 

 struct ktuxc, 104 bytes                    @18776  

   struct ktuxcscn, 8 bytes               @18776  

   struct ktuxcuba, 8 bytes               @18784  

   sb2 ktuxcflg                           @18792  

   ub2 ktuxcseq                           @18794  

   sb2 ktuxcnfb                           @18796  

   ub4 ktuxcinc                           @18800  

   sb2 ktuxcchd                           @18804  

   sb2 ktuxcctl                           @18806  

   ub2 ktuxcmgc                           @18808  

   ub4 ktuxcopt                           @18816  

   struct ktuxcfbp[5], 60 bytes           @18820  

 

 struct ktuxe[255], 10200 bytes             @18880  

   ub4 ktuxexid                           @18880  

   ub4 ktuxebrb                           @18884  

   struct ktuxescn, 8 bytes               @18888  

   sb4 ktuxesta                            @18896  

   ub1 ktuxecfl                           @18897  

   sb2 ktuxeuel                           @18898  

 

 ub4tailchk                               @508  

 

 

查看kcbh 结构里的具体值

BBED> print kcbh

struct kcbh, 20 bytes                       @0      

  ub1 type_kcbh                           @0        0x01

  ub1 frmt_kcbh                           @1        0x82

  ub1 spare1_kcbh                         @2        0x01

  ub1 spare2_kcbh                         @3        0x01

  ub4 rdba_kcbh                            @4        0x00000000

  ub4 bas_kcbh                            @8        0x80000000

  ub2 wrp_kcbh                            @12       0xd3a0

  ub1 seq_kcbh                            @14       0xe4

  ub1 flg_kcbh                           @15      0x59 (KCBHFNEW)

  ub2 chkval_kcbh                         @16       0x0000

  ub2 spare3_kcbh                         @18       0x0000

 

@同样表示偏移量,最后一列就是具体的值.

 

dump 这个block,查看具体内容:

BBED> dump /v dba 1,1 offset 0 count4096

 File: /u01/asm_disk_header (1)

 Block: 1      Offsets:    0 to  511 Dba:0x00400001

-------------------------------------------------------

 01820101 00000000 00000080 a0d3e459 l............ 夀

 00000000 00000000 00000000 00000000 l................

 4f52434c4449534b 44415441 00000000 l ORCLDISKDATA....

 00000000 00000000 00000000 00000000 l................

 0000100a 00000103 44415441 00000000 l........DATA....

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 44415441 00000000 l........DATA....

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 44415441 00000000 l........DATA....

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 0ccff601 00a822c9 l...........¨"

 f0daf601 009c10cd 00020010 00001000 l............

 80bc0100 d92e0000 02000000 01000000 l..............

 02000000 02000000 00000000 00000000 l................

 0000100a 0ccff601 003421c9 00000000 l.......4!....

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l ................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 00000000 00000000 00000000 00000000 l................

 

 <16 bytes per line>

 

BBED>

 

对这里的字节进行一个说明:

Block: 1       Offsets:    0 to 511  Dba:0x00400001

-------------------------------------------------------

 01820101 00000000 00000080 a0d3e459 l............ 夀

这里每行16个自己,即每块4个字节,如:01820101,这块就由01,82,01和01 这4个byte 组成。

 

2.5 对上面的dump信息进行解释

       这部分直接引用Roger同学的成果了。 感谢Roger 的辛勤劳动。


1)第1个byte 01  --这里是对应的endian_kfbh   01即使1 表示的是Little Endian 相反,0的话即使表示BIGendian
2)第2个byte 82  --这里对应kfbh.hard
3)第3个byte 01  --这里对应kfbh.type
4)第4个byte 01  --这里对应的是datfmt_kfbh
5)第5~8个byte   00 00 0000  ---这里对应的是kfbh.block.blk
6)第9~12个byte  00 00 0008  ---这里对应的是kfbh.block.obj
7)第13~16个byte 561d8578    ---这里对应的是kfbh.check   

8)第17~20个byte00000000     ---这里对应的是kfbh.fcn.base
9)第21~23个byte 00000000    ---这里对应的是kfbh.fcn.wrap
10)第24~27个byte 00000000    ---这里对应的是kfbh.spare1
11)第28~32个byte 00000000    ---这里对应的是kfbh.spare2
12)第33~40个byte 4f52434c 4449534b  ---这里对应的是kfdhdb.driver.provstr   --从上面的dump信息可以看出具体的值
13)第41~64个byte 00 00 00 00    ---这里对应的是kfdhdb.driver.reserved[0] ~~kfdhdb.driver.reserved[5]
14)第65~68个byte 0000100a      ---这里对应的是kfdhdb.compat即使我们的oracle版本号
15)第69~70个byte 0000          ---这里对应的是kfdhdb.dsknum 即使disk numer 取值范围 0~65335
16)第71个byte   01             ---这里对应的是kfdhdb.grptyp 即磁盘组的冗余方式 01 表示EXTERNAL冗余
          下面对该值的属性做一下补充:
                KFDGTP_INVALID    ((kfdgtp)0)  -- Illegal value        
               KFDGTP_EXTERNAL   ((kfdgtp)1)  -- External redundancy     
          KFDGTP_NORMAL     ((kfdgtp)2)  -- Normal redundancy        
          KFDGTP_HIGH       ((kfdgtp)3)  -- High redundancy       

17)第72个byte 03               ---这里对应是kfdhdb.hdrsts  即disk group的状态 03表示正常(这里非常重要)
   下面对改值的熟悉做一下补充:
        KFDHDR_INVALID    ((kfdhdr)0)--  Illegal value                        

        KFDHDR_UNKNOWN    ((kfdhdr)1) --  Disk header block unreadable   

     KFDHDR_CANDIDATE  ((kfdhdr)2) --  No OSM or OS disk header found  

     KFDHDR_MEMBER     ((kfdhdr)3) --  Normal member of the group     ---03 正常状态

    KFDHDR_FORMER     ((kfdhdr)4) --  Disk dropped cleanly from group 

    KFDHDR_CONFLICT   ((kfdhdr)5) --  Header conflicts         

   KFDHDR_INCOMPAT   ((kfdhdr)6) --  Written by incompatible software
    KFDHDR_PROVISIONED ((kfdhdr)7) --  Disk was preparedbeforehand    

18)第73~104个byte  44415441 到00000000 32个byte      ---这里对应的是kfdhdb.dskname 即磁盘名称 我们这里的DATA01_0000
19) 第105~~136个byte 44415441 到00000000 32个byte      ---这里对应的是kfdhdb.grpname 即是磁盘组名称 DATA01
20)第137~ 168个byte 也是44415441开始 32个byte        ---这里对应的是kfdhdb.fgname  即failgroup name
21)第169~184 个byte  一共16个byte             ---这里对应的是kfdhdb.capname 即是Capacitygroup name  当然我这里没有使用
22)第185~188个byte   一共4个byte   ---这里对应的是kfdhdb.crestmp.hi 即Creation timestamp high
23)第189~192个byte   一共4个byte   ---这里对应的是kfdhdb.crestmp.lo 即Creation timestamp low
24)第193~196个byte   一共4个byte   ---这里对应的是kfdhdb.mntstmp.hi
25)第197~200个byte   一共4个byte   ---这里对应的是kfdhdb.mntstmp.lo
26)第201~202  一共2个byte        ---这里对应的是kfdhdb.secsize 即physical sector size of the disk 
27)第203~204  一共2个byte        ---这里对应的是fdhdb.blksize  即metadata blocksize asm block大小
28)第205~208  一共4个byte        ---这里对应的是kfdhdb.ausize  即AU 的大小1048576 即是1m
29)第209~212  一共4个byte        ---这里对应的是kfdhdb.mfact   即Stride between physical addresses of allocation units
30)第213~216  一共4个byte        ---这里对应的是kfdhdb.dsksize 即0x00001400 转换为10进制后为5120  即5120个分配units =磁盘组大小
   补充:
          kfdhdb.ausize * dsksize_kfdhdb = disksize
                  即是 1m x 5120 =5120m (注意这个大小是整个磁盘组的大小)
31)第217~220  一共4个byte        ---这里对应的是kfdhdb.pmcnt 这里该值是2  即 Number of physically addressed allocation units
32)第221~224  一共4个byte        ---这里对应的是kfdhdb.fstlocn  即First FreeSpace table block number used to find freespace。
33)第225~228  一共4个byte        ---这里对应的是kfdhdb.altlocn  即First Alocation table block numer used to find allocated space
34)第229~232  一共4个byte        ---这里对应的是kfdhdb.f1b1locn 即File Directory block 1 Allocation Unit number. Beginging for filedirectory
                                    即是第一个file directory 通常这里是2
35)第241~244  一共4个byte        ---这里对应的是kfdhdb.dbcompat 转换以为即为我们的数据库版本
36)第245~248  一共4个byte        ---这里对应的是kfdhdb.grpstmp.hi
                我们这里的值是 HOUR=0x15 DAYS=0x8 MNTH=0xbYEAR=0x7da
                                   0x7da -->2010
                                   0xb   -->11
                                   0x8   -->8
                                   0x15  -->21          

                            即2010/11/08 21   这里只是精确到小时
37)第249~252  一共4个byte        ---这里对应的是kfdhdb.grpstmp.lo
                我们这里的值是 USEC=0x0 MSEC=0x2c6SECS=0x17 MINS=0x29
                                   MINS=0x29  -->41  分钟
                                   SECS=0x17  -->23  秒
                                   MSEC=0x2c6 -->710 微秒即0.7s
                                   USEC=0x0   -->0

 

       这里关键是要弄清楚这些值是怎么计算出来的。 在这里补充一下计算方法,感兴趣的也可以自己去算一下。

 

在前面我们粘贴KFED 显示disk header的结果内容:

[oracle@rac2 ~]$ kfed read/dev/mapper/datap1

kfbh.endian:                         1 ; 0x000: 0x01

kfbh.hard:                         130 ; 0x001: 0x82

kfbh.type:                           1 ; 0x002:KFBTYP_DISKHEAD

kfbh.datfmt:                         1 ; 0x003: 0x01

kfbh.block.blk:                      0 ; 0x004: T=0 NUMB=0x0

kfbh.block.obj:             2147483648 ; 0x008: TYPE=0x8NUMB=0x0

kfbh.check:                 1508168608 ; 0x00c:0x59e4d3a0

kfbh.fcn.base:                       0 ; 0x010: 0x00000000

kfbh.fcn.wrap:                       0 ; 0x014: 0x00000000

kfbh.spare1:                         0 ; 0x018: 0x00000000

kfbh.spare2:                         0; 0x01c: 0x00000000

 

这里面每行都有一个16进制的值和内容。 16进制就是对应的开始bytes。

如:

kfbh.spare1:                         0 ; 0x018: 0x00000000

kfbh.spare2:                         0; 0x01c: 0x00000000

 

       0x018对应的10进制是24,0x01c 对应的10进制是28. 所以24-27bytes 就是kfbh.spare1的内容。

       了解这些内容,我们可以使用BBED 来修改,或者使用KFED 修改disk header, 然后在merge 回去。 这样也能处理disk header 的故障。 关于disk header 故障处理会另篇说明。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15880878/viewspace-720037/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-24

  • 博文量
    118
  • 访问量
    186349