当前位置:数据库 > Oracle >>

Oracle兵器谱上古神器之-KFED

Oracle兵器谱上古神器之-KFED
 
如其名是个比较internal的工具,并不被Oracle官方文档对外支持,算是属于常规兵器
谱外的工具。KFED主要用来编辑和修复ASM metadata,可以在DG没有mount的情况
下使用,因此在ASM无法启动、DG无法mount的时候可以尝试使用这个利器。
在10G中默认KFED是没有现成可以使用的,但是我们可以手工编译它。
  www.zzzyk.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.zzzyk.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
kf
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,