查看原文
其他

ASM 管理的内部工具:KFED、KFOD、AMDU

JiekeXu JiekeXu DBA之路 2024-03-03

作者 | JiekeXu

来源 | JiekeXu DBA之路(ID: JiekeXu_IT)

大家好,我是 JiekeXu,很高兴又和大家见面了,今天和大家聊聊 Oracle ASM 管理的内部工具:KFED、KFOD、AMDU,欢迎点击上方蓝字关注我,标星或置顶,更多干货第一时间到达!

ASM 管理命令功能十分强大,当 ASM 实例或者磁盘组出现异常时,还可以使用 ASM 管理的内部工具:KFED、KFOD、AMDU 命令来诊断问题,检查处理 ASM 磁盘异常问题。


在 Oracle 19c 的环境中,如下所示,不管单机还是 RAC 均存在这三个命令,在 11g 中也是,可见 11g 以上的环境这三个命令已经集成到了各自环境下的 bin 目录下了。

[root@JiekeXu ~]# su - oracle Last login: Tue Apr 20 09:21:16 CST 2021 on pts/1[oracle@JiekeXu ~]$ which kfed/opt/oracle/product/19c/dbhome_1/bin/kfed[oracle@JiekeXu ~]$ ls -l /opt/oracle/product/19c/dbhome_1/bin/kfed-rwxr-x--x 1 oracle oinstall 142480 Mar 14 20:54 /opt/oracle/product/19c/dbhome_1/bin/kfed[oracle@JiekeXu ~]$ ps -ef | grep d.binoracle 26844 26812 0 17:07 pts/1 00:00:00 grep --color=auto d.bin[oracle@JiekeXu ~]$ ps -ef | grep smon oracle 2963 1 0 Mar21 ? 00:01:12 ora_smon_JiekeCDBoracle 26848 26812 0 17:07 pts/1 00:00:00 grep --color=auto smon[oracle@JiekeXu ~]$ which kfod/opt/oracle/product/19c/dbhome_1/bin/kfod[oracle@JiekeXu ~]$ ls -l /opt/oracle/product/19c/dbhome_1/bin/kfod-rwxr-xr-x 1 oracle oinstall 484 Apr 18 2019 /opt/oracle/product/19c/dbhome_1/bin/kfod[oracle@JiekeXu ~]$ iduid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(oper),54324(backupdba),54325(dgdba),54326(kmdba),54330(racdba)[oracle@JiekeXu ~]$ sqlSQL*Plus: Release 19.0.0.0.0 - Production on Fri Apr 23 17:08:09 2021Version 19.10.0.0.0Copyright (c) 1982, 2020, Oracle.  All rights reserved.Connected to:Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.10.0.0.0SYS@JiekeCDB> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 JIEKEPDB READ WRITE NO         5 JIEKEPDB1                      READ WRITE NO
19c RAC 环境
jieke2:/home/grid(+ASM2)$ which kfod/u01/app/19.0.0.0/grid/bin/kfodjieke2:/home/grid(+ASM2)$ which kfed/u01/app/19.0.0.0/grid/bin/kfedjieke2:/home/grid(+ASM2)$ ls -l /u01/app/19.0.0.0/grid/bin/kfed-rwxr-x--x 1 root oinstall 102416 Apr 22 17:00 /u01/app/19.0.0.0/grid/bin/kfedjieke2:/home/grid(+ASM2)$ which amdu/u01/app/19.0.0.0/grid/bin/amdujieke2:/home/grid(+ASM2)$ ls -l /u01/app/19.0.0.0/grid/bin/amdu-rwxr-x--x 1 root oinstall 131072 Apr 22 17:00 /u01/app/19.0.0.0/grid/bin/amdujieke2:/home/grid(+ASM2)$ exitlogoutjieke2:~ # su - oracle jieke2:/home/oracle(jiekexu2)$ which kfed/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/kfedjieke2:/home/oracle(jiekexu2)$ ls -l /u01/app/oracle/product/19.0.0.0/dbhome_1/bin/kfed-rwxr-x--x 1 oracle oinstall 98320 Apr 22 22:47 /u01/app/oracle/product/19.0.0.0/dbhome_1/bin/kfed
11g 单机环境
JIEKEADG:/home/oracle$which kfed/app/product/11.2.0/db/bin/kfedJIEKEADG:/home/oracle$which kfod/app/product/11.2.0/db/bin/kfodJIEKEADG:/home/oracle$which amdu /app/product/11.2.0/db/bin/amdu

相反在 Oracle 10g 时的环境中只有 kfod 命令,kfed 和 amdu 都不存在,10g 中也不存在 ASM 的概念,只有裸设备的概念,当然只有 kfod 也可以满足了。 

ZBJIEKEXU:[jiekexu]/software/oracle $ sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on Fri Apr 23 17:26:52 2021Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> exitDisconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsZBJIEKEXU:[jiekexu]/software/oracle $ which kfedno kfed in /usr/bin /etc /usr/sbin /usr/ucb /software/oracle/bin /usr/bin/X11 /sbin . /software/app1/oracle/product/10.2.0/db/bin /bin /usr/bin /usr/sbin /etl_pc/oracledata/dds/bin /etl_pc/oracledata/dds/dt /software/app1/oracle/product/10.2.0/db/OPatchZBJIEKEXU:[jiekexu]/software/oracle $ which kfod/software/app1/oracle/product/10.2.0/db/bin/kfodZBJIEKEXU:[jiekexu]/software/oracle $ which amduno amdu in /usr/bin /etc /usr/sbin /usr/ucb /software/oracle/bin /usr/bin/X11 /sbin . /software/app1/oracle/product/10.2.0/db/bin /bin /usr/bin /usr/sbin /etl_pc/oracledata/dds/bin /etl_pc/oracledata/dds/dt /software/app1/oracle/product/10.2.0/db/OPatchZBJIEKEXU:[jiekexu]/software/oracle $ 


kfed 工具

KFED is a useful tool which allows to analyze ASM disk header information when ASM diskgroups can not be mounted.
KFED 是当 ASM 实例不能挂载磁盘组时,读 ASM 磁盘头的工具。

读磁盘头

命令示例:

kfed read /dev/rhdisk123
kfed read /dev/rhdisk13 text=/tmp/asmdisk13.txt
kfed read /dev/rhdisk12 text=/tmp/asmdisk12.txt

jieke2:/home/grid(+ASM2)$ kfed read /dev/mapper/asm4kfbh.endian: 0 ; 0x000: 0x00kfbh.hard: 130 ; 0x001: 0x82kfbh.type: 1 ; 0x002: KFBTYP_DISKHEADkfbh.datfmt: 1 ; 0x003: 0x01kfbh.block.blk: 0 ; 0x004: blk=0kfbh.block.obj: 2147483648 ; 0x008: disk=0kfbh.check: 3593069111 ; 0x00c: 0xd629e237kfbh.fcn.base: 0 ; 0x010: 0x00000000kfbh.fcn.wrap: 0 ; 0x014: 0x00000000kfbh.spare1: 0 ; 0x018: 0x00000000kfbh.spare2: 0 ; 0x01c: 0x00000000kfdhdb.driver.provstr: ORCLDISK ; 0x000: length=8kfdhdb.driver.reserved[0]: 0 ; 0x008: 0x00000000kfdhdb.driver.reserved[1]: 0 ; 0x00c: 0x00000000kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000kfdhdb.compat: 318767104 ; 0x020: 0x13000000kfdhdb.dsknum: 0 ; 0x024: 0x0000kfdhdb.grptyp: 1 ; 0x026: KFDGTP_EXTERNALkfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBERkfdhdb.dskname: JIEKE_ARCH_0000 ; 0x028: length=15kfdhdb.grpname: JIEKE_ARCH ; 0x048: length=10kfdhdb.fgname: JIEKE_ARCH_0000 ; 0x068: length=15kfdhdb.siteguid[0]: 0 ; 0x088: 0x00kfdhdb.siteguid[1]: 0 ; 0x089: 0x00kfdhdb.siteguid[2]: 0 ; 0x08a: 0x00


修复盘头:
kfed repair /dev/rhdisk1
kfed repair /dev/rhdisk3

在原操作系统中,编译 asmdisk13.txt
把第12行 kfdhdb.driver.provstr: 的内容修改成
“kfdhdb.driver.provstr: ORCLDISK ; 0x000: length=8” 和 asmdisk12.txt 一样。

用下面的命令把每一个写回对应的磁盘:
kfed merge /dev/rhdisk13 text=asmdisk13.txt

生产环境示例:

kfed read /dev/mapper/asm12

kfod 工具

在系统级别,Oracle 还提供一个 KFOD 工具,用于列举搜索磁盘,在 ASM 实例启动之后,这些信息可以通过视图提供。

$> kfod help=y_asm_a/llow_only_raw_disks KFOD allow only raw devices [_asm_allow_only_raw_disks=TRUE/(FALSE)]_asm_l/ibraries ASM Libraries[_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)]
kfod status=TRUE asm_diskstring='/dev/rhdisk*' disks=ALL

kfod disks=all status=true

$ export LD_LIBRARY_PATH=/u01/stage/11.2.0.1/grid/stage/ext/lib
$ /u01/stage/11.2.0.1/grid/stage/ext/bin/kfod status=TRUE asm_diskstring='/dev/rdsk/*' disk=all dscvgroup=TRUE
--------------------------------------------------------------------------------
Disk Size Header Path Disk Group User Group
================================================================================
1: 10040 Mb MEMBER /dev/rdsk/c0t600144F0E08ACF0000004C2F6FBB0005d0s1 DG oracle oinstall
2: 10040 Mb MEMBER /dev/rdsk/c0t600144F0E08ACF0000004C2F6FBC0006d0s1 DG oracle oinstall
3: 10142 Mb MEMBER /dev/rdsk/c0t600144F0E08ACF0000004C2F6FBE0007d0s1 DG oracle oinstall
4: 10142 Mb MEMBER /dev/rdsk/c0t600144F0E08ACF0000004C2F6FBF0008d0s1 DG oracle oinstall
5: 9734 Mb MEMBER /dev/rdsk/c0t600144F0E08ACF0000004C2F6FC00009d0s1 FRA oracle oinstall
--------------------------------------------------------------------------------
读 ASM 使用的所有磁盘以及大小和磁盘相关路径jieke2:/home/grid(+ASM2)$ kfod disks=all status=true-------------------------------------------------------------------------------- Disk Size Header Path User Group ================================================================================ 1: 2048 MB MEMBER /dev/mapper/asm1 grid asmadmin 2: 2097152 MB MEMBER /dev/mapper/asm10 grid asmadmin 3: 2097152 MB MEMBER /dev/mapper/asm11 grid asmadmin 4: 2097152 MB MEMBER /dev/mapper/asm12 grid asmadmin 5: 2097152 MB MEMBER /dev/mapper/asm13 grid asmadmin 6: 2097152 MB MEMBER /dev/mapper/asm14 grid asmadmin 7: 2097152 MB MEMBER /dev/mapper/asm15 grid asmadmin 8: 2097152 MB MEMBER /dev/mapper/asm16 grid asmadmin 9: 2097152 MB MEMBER /dev/mapper/asm17 grid asmadmin 10: 2097152 MB MEMBER /dev/mapper/asm18 grid asmadmin 11: 2097152 MB MEMBER /dev/mapper/asm19 grid asmadmin 12: 2048 MB MEMBER /dev/mapper/asm2 grid asmadmin 13: 2097152 MB MEMBER /dev/mapper/asm20 grid asmadmin 14: 2097152 MB MEMBER /dev/mapper/asm21 grid asmadmin 15: 2097152 MB MEMBER /dev/mapper/asm22 grid asmadmin 16: 2048 MB MEMBER /dev/mapper/asm3 grid asmadmin 17: 1048576 MB MEMBER /dev/mapper/asm4 grid asmadmin 18: 2097152 MB MEMBER /dev/mapper/asm5 grid asmadmin 19: 2097152 MB MEMBER /dev/mapper/asm6 grid asmadmin 20: 2097152 MB MEMBER /dev/mapper/asm7 grid asmadmin 21: 2097152 MB MEMBER /dev/mapper/asm8 grid asmadmin 22: 2097152 MB MEMBER /dev/mapper/asm9 grid asmadmin--------------------------------------------------------------------------------ORACLE_SID ORACLE_HOME ================================================================================


amdu 工具

在 Oracle 10g 中,ASM 磁盘组的信息需要在 Mount 之后才能通过内部视图查询,如果磁盘组因为故障无法正常加载,那么信息将不可用,这为诊断带来了诸多不便。从 Oracle 11g 开始,Oracle 提供了一个工具 AMDU 用于协助诊断,通过这个工具可以在磁盘组加载之前将 ASM 的元数据抽取出来,用于数据库诊断,这个工具可以向后兼容,引入到 10g 中。

通过 amdu –h 可以查看详细的帮助说明,缺省的调用 amdu,会自动生成一个以时间命名的目录,该目录下生成的报告文件会记录磁盘组的相关信息:

amdu -diskstring ‘<your_path_to_ASM_disks>’ -dump ‘

amdu -diskstring ‘/dev/oracleasm/disks/VOL*’ -dump ‘CRSDG’

$> amdu -diskstring '/dev/raw/raw*' -dump 'DG11'

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

<report.txt content>

----------------------------- DISK REPORT N0003 ---------------------------
Disk Path: /dev/raw/raw3
Physical Sector Size: 512 bytes
Disk Size: 977 megabytes
Group Name: DG11
Disk Name: DG11_0000
Failure Group Name: DG11_0000

----------------------------- DISK REPORT N0004 ---------------------------
Disk Path: /dev/raw/raw4
Physical Sector Size: 512 bytes
Disk Size: 978 megabytes
Group Name: DG11
Disk Name: DG11_0001
Failure Group Name: DG11_0001

amdu 抽取 ASM 磁盘组的数据文件语法如下:

amdu -diskstring ‘’ -extract ‘.’

数据文件号 可以根据 asm 实例 查询 v$asm_file视图得出

也可以查 vdatafile,如果用了别名,可以用 vasm_alias;

SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/db1/datafile/system.256.794361477
+DATA/db1/datafile/sysaux.257.794361477
+DATA/db1/datafile/undotbs1.258.794361477
+DATA/db1/datafile/users.259.794361477 <(=== this files need to be extracted
+DATA/db1/datafile/example.261.794361601
+DATA/db1/datafile/testasm.263.817147851
+DATA/db1/datafile/dbfs_ts.264.822088469

比如我们要抽取 users 表空间下面对应的数据文件

Full File name = “+DATA/db1/datafile/users.259.794361477”File Number = “259”Disk String = “/dev/oracleasm/disks/*”Diskgroup Name = “DATA”Extracted File = DATA_259.famdu -diskstring ‘/dev/oracleasm/disks/*’ -extract ‘DATA.259’

在当前目录下会生成 amdu_ 加日期格式的文件夹

[grid@dbaasm ~]$ cd amdu_2013_08_31_00_17_17/[grid@dbaasm amdu_2013_08_31_00_17_17]$ ls -ltotal 2099228-rw-r–r-- 1 grid oinstall 2147491840 Aug 31 00:18 DATA_259.f-rw-r–r-- 1 grid oinstall 14514 Aug 31 00:18 report.txt

生成数据文件的格式为磁盘组+数据文件号,并且加后缀名为点 f,然后重命名为对应表空间名字 users.dbf 即可

[grid@dbaasm amdu_2013_08_31_00_17_17]$ mv DATA_259.f users.dbf[grid@dbaasm amdu_2013_08_31_00_17_17]$ ls -ltotal 2099228-rw-r–r-- 1 grid oinstall 14514 Aug 31 00:18 report.txt-rw-r–r-- 1 grid oinstall 2147491840 Aug 31 00:18 users.dbf <(======

关于这三个命令的就说这么多,涉及到 ASM 磁盘的相关查看三个命令的功能才能发挥出来,网上关于此工具的资料少之又少,这里先记录下来,分享给需要的小伙伴们。如果此文对您有帮助,欢迎点赞、在看与转发,写作不易,举手之劳,便是对作者最大的支持。

参考链接:
https://www.modb.pro/db/6665
http://blog.itpub.net/7199859/viewspace-1246627/
ASM tools used by Support : KFOD, KFED, AMDU (Doc ID 1485597.1)

————————————————————————————
公众号:JiekeXu DBA之路
墨天轮:https://www.modb.pro/u/4347
CSDN :https://blog.csdn.net/JiekeXu
腾讯云:https://cloud.tencent.com/developer/user/5645107

————————————————————————————



Oracle 12c 及以上版本补丁更新说明及下载方法(收藏版)

Oracle 19c 19.10DBRU 最新补丁升级看这一篇就够了

一线运维 DBA 五年经验常用 SQL 大全(一)

一线运维 DBA 五年经验常用 SQL 大全(二)

ORA-00349|激活 ADG 备库时遇到的问题

Oracle 轻量级实时监控工具 oratop

MySQL OCP 认证考试你知道吗?

Oracle 19C RAC 安装遇到的坑

Oracle 每日一题系列合集

百花齐放的国产数据库

继续滑动看下一个

ASM 管理的内部工具:KFED、KFOD、AMDU

JiekeXu JiekeXu DBA之路
向上滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存