如其名是个比较internal的工具,并不被Oracle官方文档对外支持,算是属于常规兵器谱外的工具。KFED主要用来编辑和修复ASM metadata,可以在DG没有mount的情况下使用,因此在ASM无法启动、DG无法mount的时候可以尝试使用这个利器。

在10G中默认KFED是没有现成可以使用的,但是我们可以手工编译它。

0. 编译KFED

我们可以使用make -f $ORACLE_HOME/rdbms/lib/ins_rdbms.mk ikfed命令来编译它,记得要在lib目录下执行编译:

[oracle@gtser1 ~]$ which kfed

/usr/bin/which: no kfed in (/home/oracle/bin:/u01/oracle/10g/product/10.2.0/db_1/bin:/usr/bin:/usr/ccs/bin:/etc:/bin:/usr/openwin/bin:/usr/local/bin:/usr/X11R6/bin:)

[oracle@gtser1 ~]$ cd $ORACLE_HOME/rdbms/lib

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

Linking KFED utility (kfed)

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

gcc -o /u01/oracle/10g/product/10.2.0/db_1/rdbms/lib/kfed -L/u01/oracle/10g/product/10.2.0/db_1/rdbms/lib/ -L/u01/oracle/10g/product/10.2.0/db_1/lib/ -L/u01/oracle/10g/product/10.2.0/db_1/lib/stubs/  /u01/oracle/10g/product/10.2.0/db_1/lib/s0main.o /u01/oracle/10g/product/10.2.0/db_1/rdbms/lib/sskfeded.o /u01/oracle/10g/product/10.2.0/db_1/rdbms/lib/skfedpt.o  /u01/oracle/10g/product/10.2.0/db_1/rdbms/lib/defopt.o -ldbtools10 -lclntsh  `cat /u01/oracle/10g/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/oracle/10g/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/oracle/10g/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/oracle/10g/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/oracle/10g/product/10.2.0/db_1/lib/sysliblist` -Wl,-rpath,/u01/oracle/10g/product/10.2.0/db_1/lib -lm    `cat /u01/oracle/10g/product/10.2.0/db_1/lib/sysliblist` -ldl -lm   -L/u01/oracle/10g/product/10.2.0/db_1/lib

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

mv /u01/oracle/10g/product/10.2.0/db_1/rdbms/lib/kfed /u01/oracle/10g/product/10.2.0/db_1/bin/kfed

chmod 751 /u01/oracle/10g/product/10.2.0/db_1/bin/kfed

[oracle@gtser1 lib]$ which kfed

/u01/oracle/10g/product/10.2.0/db_1/bin/kfed

这样我们就完成了KFED工具编译,接下来就可以正常使用它了。

1. 使用KFED命令

KFED提供了哪些命令选项呢?我们看下帮助选项就知道了。

[oracle@gtser1 lib]$ kfed -help

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/REPAIR/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]

2. KFED查看header信息

这个工具可以在ASM没有启动的情况下使用,因此我们就关闭ASM验证下到底可不可以。

[oracle@gtser1 lib]$ export ORACLE_SID=+ASM

[oracle@gtser1 lib]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 16:24:14 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;

ASM diskgroups dismounted

ASM instance shutdown

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

在10.2.0.5版本之前header信息是没有额外保护的,而且header信息非常容易损坏,好在之后版本做了额外的备份保护,我们后面会描述到。

使用KFED查看header信息:

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1

kfbh.endian:                          1 ; 0x000: 0x01

kfbh.hard:                          130 ; 0x001: 0x82

kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD--表示这是HEAD数据信息

kfbh.datfmt:                          1 ; 0x003: 0x01

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

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

kfbh.check:                  3544975665 ; 0x00c: 0xd34c0931

kfbh.fcn.base:                       48 ; 0x010: 0x00000030

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

kfbh.spare1:                          0 ; 0x018: 0x00000000

kfbh.spare2:                          0 ; 0x01c: 0x00000000

kfdhdb.driver.provstr:         ORCLDISK ; 0x000: length=8

kfdhdb.driver.reserved[0]:            0 ; 0x008: 0x00000000

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--disk号

kfdhdb.grptyp:                        1 ; 0x026: KFDGTP_EXTERNAL--DG冗余类型

kfdhdb.hdrsts:                        3 ; 0x027: KFDHDR_MEMBER--disk status信息

kfdhdb.dskname:                   DISK1 ; 0x028: length=5--disk name

kfdhdb.grpname:                  DATA01 ; 0x048: length=6--dg name

kfdhdb.fgname:                    DISK1 ; 0x068: length=5--fg name

kfdhdb.capname:                         ; 0x088: length=0

kfdhdb.crestmp.hi:             32983791 ; 0x0a8: HOUR=0xf DAYS=0x17 MNTH=0x2 YEAR=0x7dd

kfdhdb.crestmp.lo:           2630343680 ; 0x0ac: USEC=0x0 MSEC=0x1f7 SECS=0xc MINS=0x27

kfdhdb.mntstmp.hi:             32984143 ; 0x0b0: HOUR=0xf DAYS=0x2 MNTH=0x3 YEAR=0x7dd

kfdhdb.mntstmp.lo:           1001101312 ; 0x0b4: USEC=0x0 MSEC=0x2e6 SECS=0x3a MINS=0xe

kfdhdb.secsize:                     512 ; 0x0b8: 0x0200--sector size

kfdhdb.blksize:                    4096 ; 0x0ba: 0x1000--block size

kfdhdb.ausize:                  1048576 ; 0x0bc: 0x00100000--allocation size AU

kfdhdb.mfact:                    113792 ; 0x0c0: 0x0001bc80

kfdhdb.dsksize:                    1024 ; 0x0c4: 0x00000400--disk size

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]:            65535 ; 0x0da: 0xffff

kfdhdb.redomirrors[2]:            65535 ; 0x0dc: 0xffff

kfdhdb.redomirrors[3]:            65535 ; 0x0de: 0xffff

kfdhdb.dbcompat:              168820736 ; 0x0e0: 0x0a100000

kfdhdb.grpstmp.hi:             32983791 ; 0x0e4: HOUR=0xf DAYS=0x17 MNTH=0x2 YEAR=0x7dd

kfdhdb.grpstmp.lo:           2630330368 ; 0x0e8: USEC=0x0 MSEC=0x1ea SECS=0xc MINS=0x27

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

上面我们说到从10.2.0.5开始之后的版本header信息是有额外保护和备份的,那么是备份在哪个位置呢?也是在disk的特定位置,这对au=1MB的dg,备份信息是在第510blkn的位置,我们可以看下位置510的信息:

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1 blkn=510 | grep kfbh.type

kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD

果不其然,510确实也是HEAD信息,我们把它读出来:

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1 blkn=510

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=0x8 NUMB=0x0

kfbh.check:                  2487934254 ; 0x00c: 0x944add2e

kfbh.fcn.base:                       48 ; 0x010: 0x00000030

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

kfbh.spare1:                          0 ; 0x018: 0x00000000

kfbh.spare2:                          0 ; 0x01c: 0x00000000

kfdhdb.driver.provstr:         ORCLDISK ; 0x000: length=8

kfdhdb.driver.reserved[0]:            0 ; 0x008: 0x00000000

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

kfdhdb.hdrsts:                        3 ; 0x027: KFDHDR_MEMBER

kfdhdb.dskname:                   DISK1 ; 0x028: length=5

kfdhdb.grpname:                  DATA01 ; 0x048: length=6

kfdhdb.fgname:                    DISK1 ; 0x068: length=5

kfdhdb.capname:                         ; 0x088: length=0

kfdhdb.crestmp.hi:             32983791 ; 0x0a8: HOUR=0xf DAYS=0x17 MNTH=0x2 YEAR=0x7dd

kfdhdb.crestmp.lo:           2630343680 ; 0x0ac: USEC=0x0 MSEC=0x1f7 SECS=0xc MINS=0x27

kfdhdb.mntstmp.hi:             32984144 ; 0x0b0: HOUR=0x10 DAYS=0x2 MNTH=0x3 YEAR=0x7dd

kfdhdb.mntstmp.lo:           2091731968 ; 0x0b4: USEC=0x0 MSEC=0x353 SECS=0xa MINS=0x1f

kfdhdb.secsize:                     512 ; 0x0b8: 0x0200

kfdhdb.blksize:                    4096 ; 0x0ba: 0x1000

kfdhdb.ausize:                  1048576 ; 0x0bc: 0x00100000

kfdhdb.mfact:                    113792 ; 0x0c0: 0x0001bc80

kfdhdb.dsksize:                    1024 ; 0x0c4: 0x00000400

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]:            65535 ; 0x0da: 0xffff

kfdhdb.redomirrors[2]:            65535 ; 0x0dc: 0xffff

kfdhdb.redomirrors[3]:            65535 ; 0x0de: 0xffff

kfdhdb.dbcompat:              168820736 ; 0x0e0: 0x0a100000

kfdhdb.grpstmp.hi:             32983791 ; 0x0e4: HOUR=0xf DAYS=0x17 MNTH=0x2 YEAR=0x7dd

kfdhdb.grpstmp.lo:           2630330368 ; 0x0e8: USEC=0x0 MSEC=0x1ea SECS=0xc MINS=0x27

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

通过对比我们可以发现这两者的内容是一摸一样的。那么我们可以做个试验,就是把0位置的信息破坏掉,然后用510位置的信息进行还原,看看是否可以成功还原DISK。

3. KFED备份header信息

为了安全,我们在使用KFED之前还是停掉ASM针对设备做个物理备份。

[oracle@gtser1 lib]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 16:40:05 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;

ASM diskgroups dismounted

ASM instance shutdown

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@gtser1 lib]$ dd if=/dev/raw/raw1 of=/tmp/raw1 bs=4096 count=1

1+0 records in

1+0 records out

4096 bytes (4.1 kB) copied, 0.000461594 seconds, 8.9 MB/s

好了,接下来启动ASM进行在线KFED备份,KFED支持在线编辑,虽然10.2.0.5支持header的自动备份和快捷修复(我们也会演示到),但是我们想通过510的信息来恢复0的信息以还原DISK。

[oracle@gtser1 lib]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 16:44:51 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup

ASM instance started

Total System Global Area  125829120 bytes

Fixed Size                  2094512 bytes

Variable Size              98568784 bytes

ASM Cache                  25165824 bytes

ASM diskgroups mounted

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@gtser1 lib]$ asmcmd lsdg

State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name

MOUNTED  EXTERN  N      N         512   4096  1048576      2048      928                0             928              0  DATA01/

MOUNTED  EXTERN  N      N         512   4096  1048576      2048     1964                0            1964              0  FRA/

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1 te=/tmp/raw1.head

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1 blkn=510 te=/tmp/raw1.head.bak

接下来我们人为的破坏disk的内容:

[oracle@gtser1 lib]$ dd if=/dev/zero of=/dev/raw/raw1 bs=4096 count=1

1+0 records in

1+0 records out

4096 bytes (4.1 kB) copied, 0.000424761 seconds, 9.6 MB/s

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1 te=/tmp/raw1.head.bad

[oracle@gtser1 lib]$ cat /tmp/raw1.head.bad

kfbh.endian:                          0 ; 0x000: 0x00

kfbh.hard:                            0 ; 0x001: 0x00

kfbh.type:                            0 ; 0x002: KFBTYP_INVALID

kfbh.datfmt:                          0 ; 0x003: 0x00

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

kfbh.block.obj:                       0 ; 0x008: TYPE=0x0 NUMB=0x0

kfbh.check:                           0 ; 0x00c: 0x00000000

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

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

kfbh.spare1:                          0 ; 0x018: 0x00000000

kfbh.spare2:                          0 ; 0x01c: 0x00000000

然后启动ASM:

[oracle@gtser1 lib]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 17:08:20 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup

ASM instance started

Total System Global Area  125829120 bytes

Fixed Size                  2094512 bytes

Variable Size              98568784 bytes

ASM Cache                  25165824 bytes

ORA-15032: not all alterations performed

ORA-15063: ASM discovered an insufficient number of disks for diskgroup

"DATA01"

SQL>

正如预期的DG data01 mount失败,我们也可以在alter日志看到:

Sat Mar 02 17:08:28 CST 2013

SQL> ALTER DISKGROUP ALL MOUNT

Sat Mar 02 17:08:28 CST 2013

NOTE: cache registered group DATA01 number=1 incarn=0x7af2d794

NOTE: cache registered group FRA number=2 incarn=0x7b02d795

Sat Mar 02 17:08:28 CST 2013

ERROR: no PST quorum in group 1: required 1, found 0

Sat Mar 02 17:08:28 CST 2013

NOTE: cache dismounting group 1/0x7AF2D794 (DATA01)

NOTE: dbwr not being msg'd to dismount

ERROR: diskgroup DATA01 was not mounted

Sat Mar 02 17:08:28 CST 2013

NOTE: Hbeat: instance first (grp 2)

Sat Mar 02 17:08:33 CST 2013

NOTE: start heartbeating (grp 2)

NOTE: cache opening disk 0 of grp 2: D3 path:/dev/raw/raw3

Sat Mar 02 17:08:33 CST 2013

NOTE: F1X0 found on disk 0 fcn 0.0

NOTE: cache opening disk 1 of grp 2: D4 path:/dev/raw/raw4

NOTE: cache mounting (first) group 2/0x7B02D795 (FRA)

NOTE: cache recovered group 2 to fcn 0.3474

Sat Mar 02 17:08:33 CST 2013

NOTE: LGWR attempting to mount thread 1 for disk group 2

NOTE: LGWR mounted thread 1 for disk group 2

NOTE: opening chunk 1 at fcn 0.3474 ABA

NOTE: seq=18 blk=796

Sat Mar 02 17:08:33 CST 2013

NOTE: cache mounting group 2/0x7B02D795 (FRA) succeeded

SUCCESS: diskgroup FRA was mounted

Sat Mar 02 17:08:34 CST 2013

NOTE: recovering COD for group 2/0x7b02d795 (FRA)

SUCCESS: completed COD recovery for group 2/0x7b02d795 (FRA)

显示的也是磁盘组data01无法mount,通过asmcmd查看也是如此:

[oracle@gtser1 lib]$ asmcmd lsdg

State       Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name

DISMOUNTED          N      N         512   4096  1048576         0        0                0               0              0  DATA01/

MOUNTED     EXTERN  N      N         512   4096  1048576      2048     1964                0            1964              0  FRA/

4. KFED恢复header信息

接下来我们就用510位置的备份还原:

[oracle@gtser1 lib]$ kfed write /dev/raw/raw1 te=/tmp/raw1.head.bak

[oracle@gtser1 lib]$ kfed read /dev/raw/raw1 te=/tmp/raw1.head.new

[oracle@gtser1 lib]$ cat /tmp/raw1.head.new|grep kfbh.type

kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD

[oracle@gtser1 lib]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 17:12:58 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup force;

ASM instance started

Total System Global Area  125829120 bytes

Fixed Size                  2094512 bytes

Variable Size              98568784 bytes

ASM Cache                  25165824 bytes

ASM diskgroups mounted

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@gtser1 lib]$ asmcmd lsdg

State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name

MOUNTED  EXTERN  N      N         512   4096  1048576      2048      928                0             928              0  DATA01/

MOUNTED  EXTERN  N      N         512   4096  1048576      2048     1964                0            1964              0  FRA/

OK,一切正常,恢复成功了。

5. KFED修复header信息

[oracle@gtser1 ~]$ kfed read /dev/raw/raw2 te=/tmp/raw2.head

[oracle@gtser1 ~]$ dd if=/dev/raw/raw2 of=/tmp/raw2head bs=4096 count=1

1+0 records in

1+0 records out

4096 bytes (4.1 kB) copied, 0.000448689 seconds, 9.1 MB/s

[oracle@gtser1 ~]$ dd if=/dev/zero of=/dev/raw/raw2 bs=4096 count=1

1+0 records in

1+0 records out

4096 bytes (4.1 kB) copied, 0.000238479 seconds, 17.2 MB/s

[oracle@gtser1 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 22:32:11 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup force;

ASM instance started

Total System Global Area  125829120 bytes

Fixed Size                  2094512 bytes

Variable Size              98568784 bytes

ASM Cache                  25165824 bytes

ORA-15032: not all alterations performed

ORA-15040: diskgroup is incomplete

ORA-15042: ASM disk "1" is missing

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@gtser1 ~]$ asmcmd lsdg

State       Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name

DISMOUNTED          N      N         512   4096  1048576         0        0                0               0              0  DATA01/

MOUNTED     EXTERN  N      N         512   4096  1048576      2048     1964                0            1964              0  FRA/

[oracle@gtser1 ~]$ kfed repair /dev/raw/raw2

[oracle@gtser1 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sat Mar 2 22:34:34 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup force;

ASM instance started

Total System Global Area  125829120 bytes

Fixed Size                  2094512 bytes

Variable Size              98568784 bytes

ASM Cache                  25165824 bytes

ASM diskgroups mounted

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@gtser1 ~]$ asmcmd lsdg

State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Name

MOUNTED  EXTERN  N      N         512   4096  1048576      2048      928                0             928              0  DATA01/

MOUNTED  EXTERN  N      N         512   4096  1048576      2048     1964                0            1964              0  FRA/

-The End-

oracle16c,Oracle兵器谱上古神器之-KFED相关推荐

  1. oracle16c,Oracle兵器谱上古神器之-KFED-Oracle

    Oracle兵器谱上古神器之-KFED 如其名是个比较internal的工具,并不被Oracle官方文档对外支持,算是属于常规兵器 谱外的工具.KFED主要用来编辑和修复ASM metadata,可以 ...

  2. Oracle兵器谱上古神器之-KFED

    如其名是个比较internal的工具,并不被Oracle官方文档对外支持,算是属于常规兵器谱外的工具.KFED主要用来编辑和修复ASM metadata,可以在DG没有mount的情况下使用,因此在A ...

  3. 学习——Regression Tree 回归树

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/weixin_40604987/arti ...

  4. Oracle KFED 和 KFOD 工具说明

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

  5. oracle12c asmfd,Oracle 12c新特性--ASMFD(ASM Filter Driver)特性

    1 说明 ASMFD 是 12.1 中就引入的新特性,它可以不用手动配置 ASM 磁盘,更重要的是它可以保护磁盘被其他非 Oracle 操作复写,例如 dd , echo 等命令. 更为详尽的介绍,请 ...

  6. oracle 数据文件 属组,kfed找出来asm 磁盘组中数据文件别名对应的文件号—amdu恢复...

    前段时间有多个朋友问我,在amdu中,如果数据文件命名不是omf的方式,该如何找出来数据文件的asm file_number,从而实现通过amdu对不能mount的磁盘组中的数据文件进行恢复,这里通过 ...

  7. asmlib方式管理oracle asm环境下,新加存储需特别注意

    oracle10g 数据库主机已经连接有使用RDAC的存储,计划新增扩容IBM新存储(要求使用dm-multipath多路径软件),多个多路径软件能否共存?启后sd设备名是否会发生改变,是否影响asm ...

  8. Windows Server 2008 下ASP程序连接ORACLE数据库驱动错误

    今天开发那边升级.改造系统过程中,在测试服务器碰到关于ASP程序连接ORACLE数据库的小问题,虽然是小问题,但是整起来真要命啊,花了不少时间,主要是ASP程序啊,这种上古神器,哥还是当年毕业的时候弄 ...

  9. Oracle ASM 翻译系列第十二弹:ASM Internal amdu - ASM Metadata Dump Utility

    amdu - ASM Metadata Dump Utility ASM Metadata Dump Utility,即ASM元数据导出工具,它的简写amdu更被人所熟知,常被Oracle技术支持人员 ...

最新文章

  1. 查看和设置MySQL数据库字符集(转)
  2. CTRL+SHIFT
  3. oralce load的时候使用触发器会导致load慢吗_一次FGC导致CPU飙高的排查过程
  4. C 语言的标准输入对象是,《面向对象程序设计C+》期末试卷及标准答案
  5. 友源社区APP论坛源码+网站源码
  6. android仿bilibili ui,android指纹识别、拼图游戏、仿MIUI长截屏、bilibili最美创意等源码...
  7. SGU 231 Prime Sum 求lt;=n内有多少对素数(a,b)使得a+b也为素数 规律题
  8. jquery内核学习(3)--作用域分割(下)
  9. java匹配uri_使用查询字符串中的:在Java中创建URI
  10. CSS中文字体如宋体/微软雅黑的英文名称写法
  11. Landscape-施密特版图触发器设计
  12. 论如何熟悉HTML与css的方法-孰能生巧第一步:美食网编写(详细代码)
  13. 关于matlab 画水平线
  14. R语言使用epiDisplay包的summ函数计算向量数据在不同分组下的描述性统计汇总信息并可视化有序点图(名称、有效值个数、均值、中位数、标准差、最大值、最小值)
  15. QMS-云质-质量管理软件-闲聊霍尼韦尔用13亿美元收购一家质量管理软件(QMS)小公司
  16. 云服务器gitlab,云服务器CentOS7.4下搭建GitLab
  17. 河南科技学院教务管理系统服务器,河南科技学院教务管理系统:http://jwc.hist.edu.cn...
  18. 【DSP开发】gel文件编写
  19. Windows XP快捷键大全
  20. Matlab生成sinc信号

热门文章

  1. 卓有成效的团队建设经验与见解 Team Leader你会带团队吗?
  2. 端午节蓝屏之谜:金山系列软件同微软KB2839229冲突技术分析
  3. 2022AI决策智能实践:美宜佳
  4. 墨西哥萨卡特卡斯将举行GNOME GUADEC 2020 峰会
  5. 音频codec调试心得
  6. pdfminer __init__() got an unexpected keyword argument ‘codec‘解决方案
  7. python分钟转换小时_Python程序将秒转换为小时,分钟和秒
  8. 【ABC 203】D - Pond:二分 + 前缀和
  9. 熊猫烧香作者李俊的个人简历
  10. pu是什么单位(pu革是什么材料)