ITPub博客

首页 > 数据库 > Oracle > ASM磁盘头信息损坏和修复(kfed/dd)

ASM磁盘头信息损坏和修复(kfed/dd)

Oracle 作者:风行年华 时间:2015-10-11 23:54:17 0 删除 编辑

文章整理与网络
这个实验来演示一下asm头的损坏的情况下,用kfed工具来修复的一个案例。

而kfed工具支持对于ASM信息的READ/WRITE/MERGE/NEW/ FORM/FIND/STRUCT等操作,但是需要手工编译:


cd $ORACLE_HOME/rdbms/lib  
make -f ins_rdbms.mk ikfed

Linking KFED utility (kfed)
rm -f /opt/rac/database/rdbms/lib/kfed
gcc -o /opt/rac/database/rdbms/lib/kfed -L/opt/rac/database/rdbms/lib/ -L/opt/rac/database/lib/ -L/opt/rac/database/lib/stubs/ -L/usr/lib -lirc  /opt/rac/database/lib/s0main.o /opt/rac/database/rdbms/lib/sskfeded.o /opt/rac/database/rdbms/lib/skfedpt.o  /opt/rac/database/rdbms/lib/defopt.o -ldbtools10 -lclntsh  `cat /opt/rac/database/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /opt/rac/database/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 /opt/rac/database/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /opt/rac/database/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 /opt/rac/database/lib/sysliblist` -Wl,-rpath,/opt/rac/database/lib -lm    `cat /opt/rac/database/lib/sysliblist` -ldl -lm   -L/opt/rac/database/lib
mv -f /opt/rac/database/bin/kfed /opt/rac/database/bin/kfedO
mv /opt/rac/database/rdbms/lib/kfed /opt/rac/database/bin/kfed
chmod 751 /opt/rac/database/bin/kfed
-bash-3.2$ 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/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的每个磁盘上有存放有asm的元数据,元数据一般大小为4k。disk header一般在第0个au,的第0个块上。

接下来是详细的步骤

–以防万一备份一下asm的元数据
[grid@s1-11g dev]$ 备份磁盘头的信息:
dd if=/dev/oracleasm/disks/CRSVOL of=/rman/racbackupinfo/CRSVOL.dd bs=1M count=2
dd if=/dev/oracleasm/disks/FRAVOL of=/rman/racbackupinfo/FRAVOL.dd bs=1M count=2
dd if=/dev/oracleasm/disks/DATVOL of=/rman/racbackupinfo/DATVOL.dd bs=1M count=2


–破坏磁盘头的元数据
[grid@s1-11g dev]$ dd if=/dev/zero of=/dev/asm-ndata3 bs=4096 count=1

–查看一下磁盘头的状态
SQL>  select group_Number,DISK_NUMBER,name,HEADER_STATUS,path from v$asm_disk;
 GROUP_NUMBER DISK_NUMBER NAME                           HEADER_STATU PATH
———— ———– —————————— ———— —————————————-
           1           0 DATA3_0000                     MEMBER       /dev/asm-ndata2
            4           2 OCRVOTE_0002                   MEMBER       /dev/asm-nocr2
            4           0 OCRVOTE_0000                   MEMBER       /dev/asm-nocr1
            2           0 DISK6                          MEMBER       /dev/asm-ndata6
            2           1 DISK7                          MEMBER       /dev/asm-ndata7
            5           0 TEMPOCR_0000                   MEMBER       /dev/asm-ndata1
            3           0 DATA_0000                      MEMBER       /dev/asm-ndata4
            3           2 DATA_0002                      CANDIDATE    /dev/asm-ndata3

–kfed查看一下磁盘头的状态
[grid@s1-11g dev]$
kfed read /dev/oracleasm/disks/CRSVOL aun=0 blkn=0
kfed read /dev/oracleasm/disks/FRAVOL aun=0 blkn=0
kfed read /dev/oracleasm/disks/DATVOL aun=0 blkn=0
 
kfbh.endian:                          0 ; 0×000: 0×00
 kfbh.hard:                            0 ; 0×001: 0×00
 kfbh.type:                            0 ; 0×002: KFBTYP_INVALID
 kfbh.datfmt:                          0 ; 0×003: 0×00
 kfbh.block.blk:                       0 ; 0×004: T=0 NUMB=0×0
 kfbh.block.obj:                       0 ; 0×008: TYPE=0×0 NUMB=0×0
 kfbh.check:                           0 ; 0×00c: 0×00000000
 kfbh.fcn.base:                        0 ; 0×010: 0×00000000
 kfbh.fcn.wrap:                        0 ; 0×014: 0×00000000
 kfbh.spare1:                          0 ; 0×018: 0×00000000
 kfbh.spare2:                          0 ; 0×01c: 0×00000000
 2B6BCD150400 00000000 00000000 00000000 00000000  [................]
   Repeat 255 times
 KFED-00322: Invalid content encountered during block traversal: [kfbtTraverseBlock][Invalid OSM block type][][0]

–kfed查看备份的的磁盘头情况
[grid@s1-11g dev]$
kfed read /dev/oracleasm/disks/CRSVOL aun=1 blkn=254
kfed read /dev/oracleasm/disks/FRAVOL aun=1 blkn=254
kfed read /dev/oracleasm/disks/DATVOL aun=1 blkn=254
  kfbh.type:                            1 ; 0×002: KFBTYP_DISKHEAD

–kfed修复磁盘头
[grid@s1-11g dev]$
kfed repair /dev/oracleasm/disks/CRSVOL
kfed repair /dev/oracleasm/disks/FRAVOL
kfed repair /dev/oracleasm/disks/DATVOL
或者dd修复
[grid@s1-11g dev]$
dd if=/rman/racbackupinfo/CRSVOL.dd of=/dev/oracleasm/disks/CRSVOL
dd if=/rman/racbackupinfo/DATVOL.dd of=/dev/oracleasm/disks/DATVOL 
dd if=/rman/racbackupinfo/FARVOL.dd of=/dev/oracleasm/disks/FARVOL

–查看磁盘头情况
[grid@s1-11g dev]$ kfed read /dev/asm-ndata3 aun=0 blkn=0
 kfbh.type:                            1 ; 0×002: KFBTYP_DISKHEAD

GROUP_NUMBER DISK_NUMBER NAME                           HEADER_STATU PATH
———— ———– —————————— ———— —————————————-
           1           0 DATA3_0000                     MEMBER       /dev/asm-ndata2
            4           2 OCRVOTE_0002                   MEMBER       /dev/asm-nocr2
            4           0 OCRVOTE_0000                   MEMBER       /dev/asm-nocr1
            2           0 DISK6                          MEMBER       /dev/asm-ndata6
            2           1 DISK7                          MEMBER       /dev/asm-ndata7
            5           0 TEMPOCR_0000                   MEMBER       /dev/asm-ndata1
            3           0 DATA_0000                      MEMBER       /dev/asm-ndata4
            3           2 DATA_0002                      MEMBER    
利用oracle的kfed工具来备份,将磁盘头信息转换成文本明文形式记录下来,恢复时使用kfed merge进去
备份:
kfed read  /dev/oracleasm/disks/CRSVOL      aunum=0 blknum=0 text=raw1.txt
kfed read  /dev/oracleasm/disks/FRAVOL      aunum=0 blknum=0 text=raw1.txt
kfed read  /dev/oracleasm/disks/DATVOL      aunum=0 blknum=0 text=raw1.txt
恢复:
kfed write /dev/oracleasm/disks/CRSVO       aunum=0 blknum=0 text=raw1.txt
kfed write /dev/oracleasm/disks/FRAVOL      aunum=0 blknum=0 text=raw1.txt
kfed write /dev/oracleasm/disks/DATVOL      aunum=0 blknum=0 text=raw1.txt   /dev/asm-ndata3

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

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

注册时间:2013-11-22

  • 博文量
    19
  • 访问量
    43726