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

Oracle兵器谱上古神器之-KFED

如其名是个比较internal的工具,并不被Oracle官方文档对外支持,算是属于常规兵器

谱外的工具。KFED主要用来编辑和修复ASM metadata,可以在DG没有mount的情况

下使用,因此在ASM无法启动、DG无法mount的时候可以尝试使用这个利器。

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

www.2cto.com

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)  www.2cto.com

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-

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值