Oracle KFED and KFOD tool descriptions



Oracle ASM is a packaged disk management tool, so we need to have a good understanding of ASM, otherwise ASM problems can be very difficult, KFED and KFOD two commands can help us understand ASM.

I. KFED (Kernel Files Editor) instructions

KFED is a tool that COMESACLE 10gR2 comes with, but like the BBED command, it needs to be compiled before it can be used.

1.1 COMPILE KFED

[[email protected] lib]$ cd $ORACLE_HOME/rdbms/lib

[[email protected] lib]$ pwd

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

[[email protected] 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

[[email protected] lib]$

--VIEW KFED LOCATION

[[email protected] lib]$ which kfed

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

1.2 KFED COMMAND USED

--CHECK OUT KFED HELP

[[email protected] 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]

--VIEW THE ASM DISK GROUP

[email protected](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

[email protected](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

--view at the system level

[[email protected] ~]$ /etc/init.d/oracleasm listdisks

DATA

FRA

[[email protected] ~]$ 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

--USE KFED TO VIEW ASM DISK GROUPS

[[email protected] ~]$ kfed read /dev/mapper/datap1 text=datap1.txt

[[email protected] ~]$ ls

datap1.txt Desktop  oradiag_oracle

[[email protected] ~]$ cat datap1.txt

...

the kfed command can be added or not, and if the text parameter is used, the content read by the kfed is saved to the document specified by text and entered directly into the screen if it is not used.

[[email protected] ~]$ 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

--> the name of the disk volume

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 SOME NOUNS IN THE ASM DISK ARE INTERPRETED

(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=<disknumber>

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 A damaged disk KFED result

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) description

Here's OSM: Order and Service Management, where the KFOD command can find ASMs in system-level pairs. It can also be used to monitor ASM.

2.1 KFOD HELP

[[email protected] ~]$ 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 EXAMPLE

[[email protected] ~]$ 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

[[email protected] ~]$ 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

[[email protected] ~]$ kfod op=disks

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

Disk         Size Path

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

1:        101 Mb /dev/raw/raw3

2:        101 Mb /dev/raw/raw4

3:        101 Mb /dev/raw/raw8

This article briefly describes these two commands, and takes a detailed look at the use of these two commands in the next ASM disk header backup and recovery.

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

QQ:492913789

Email:[email protected]

Blog: http://www.cndba.cn/dave

Weibo: http://weibo.com/tianlesoftware

Twitter: http://twitter.com/tianlesoftware

Facebook: http://www.facebook.com/tianlesoftware

Linkedin: http://cn.linkedin.com/in/tianlesoftware

DBA1 GROUP: 62697716 (FULL); DBA2 GROUP: 62697977 (FULL) DBA3 GROUP: 62697850 (FULL)

DBA SUPERGROUP: 63306533 (FULL); DBA4 GROUP: 83829929 (FULL) DBA5 GROUP: 142216823 (FULL)

DBA6 GROUP: 158654907 (FULL) CHAT GROUP: 40132017 (FULL) CHAT GROUP 2: 69087192 (FULL)

--Adding groups is required to explain the relationship between Oracle table space and data files in the notes, otherwise the request will be rejected