Oracle 使用BBED 檢視 ASM Disk Header 內容

roominess發表於2012-03-31

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

--&gt磁碟卷名

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

--&gt This indicatesRedundancy for Group.Check TYPE in query output.

kfdhdb.hdrsts:                        3 ; 0x027:KFDHDR_MEMBER

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

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

--&gt This indicatesDisk Name

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

--&gt This indicates theGroup Name for the disk.

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

--&gt 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

--&gt磁碟卷名

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

--&gt ThisindicatesRedundancy for Group.Check TYPE in query output.

kfdhdb.hdrsts:                       3 ; 0x027:KFDHDR_MEMBER

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

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

--&gt This indicatesDiskName

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

--&gt This indicatestheGroup Name for the disk.

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

--&gt 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 --&gt2010
                                   0xb   --&gt11
                                   0x8   --&gt8
                                   0x15  --&gt21          

                            即2010/11/08 21   這裡只是精確到小時
37)第249~252  一共4個byte        ---這裡對應的是kfdhdb.grpstmp.lo
                我們這裡的值是 USEC=0x0 MSEC=0x2c6SECS=0x17 MINS=0x29
                                   MINS=0x29  --&gt41  分鐘
                                   SECS=0x17  --&gt23  秒
                                   MSEC=0x2c6 --&gt710 微秒即0.7s
                                   USEC=0x0   --&gt0

 

       這裡關鍵是要弄清楚這些值是怎麼計算出來的。 在這裡補充一下計算方法,感興趣的也可以自己去算一下。

 

在前面我們貼上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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章