了解和使用kfed维护ASM元数据
以下是转载的两篇文章,这两篇文章分别介绍了kfed工具和ASM磁盘头,两篇文章之间有很强的关联性,所以在这里一并贴出。
1.kfed - ASM metadata editor
Thekfedis an undocumented ASM utility that can be used toread and modifyASM metadata blocks. It is a standaloneutility, independent of ASM instance, so it can be used with either mounted ordismounted disk groups. The most powerful kfed feature is its ability to fixcorrupt ASM metadata.
The kfed binary is present in the recent ASM versions, but if you don't see itin your$ORACLE_HOME/bin directory(e.g. it may not be present inversion 10.1), it can be built as follows:
kfed read
With the kfed read command we can read a single ASM metadata block. Thesyntax is:
· aun- Allocation Unit (AU) number to readfrom. Default is AU0, or the very beginning of the ASM disk.
· aus-AU size. Default is1048576(1MB). Specify the aus when reading from a disk group with non-default AU size.
· blkn-block number to read. Default isblock 0, or the very first block of the AU.
· dev-ASM disk or device name. Notethat the keyworddevcan be omitted, but the ASM disk name ismandatory.
Use kfed to read ASM disk header block
The following is an example of using the kfed utility to read the ASM diskheader from ASM disk /dev/sda1.
Note that the above kfed command is equivalent to this one (with all parametersexplicitly set to their default values):
We see that the above kfed output is nicely formatted and human readable (sortof). The fields are grouped based on the actual content of the ASM metadatablock.
In this example, the kfbh fields show theblock headerdata,and the most important one is kfbh.type, which says KFBTYP_DISKHEAD, meaningthe ASM disk header. This is the expected block type for an ASM disk header.
We then see the actual content of the ASM disk header metadata block - thekfdhdb fields. Some of those are the disk number (kfdhdb.dsknum), 0 in thiscase, the group redundancy type (kfdhdb.grptyp), normal redundancy in thiscase, the disk header status (kfdhdb.hdrsts), member in this case, the diskname (kfdhdb.dskname) -DATA_0000, etc.
Please seeASM disk headerfor the completeexplanation of kfdhdb fields.
Use kfed to read any ASM metadata block
The next example shows how to read an ASMFile Directory block. To dothat we would use the following kfed command:
Is my ASM metadata block corrupt
If you see kfbh.type=KFBTYP_INVALID, in the disk header on a disk you believebelongs to an ASM disk group, that indicates that the ASM disk header iscorrupt. But don't jump to conclusions! Are you looking at the right disk? Isthis the right disk partition? Can you access that disk via some other name -in a multipath setup? If you are not sure, or if the disk header is in factdamaged, contact Oracle Support for assistance.
Note that this applies to any ASM metadata block. If ASM expects to find ametadata block and instead finds a block that is zeroed out or containsrubbish, it will report the block as KFBTYP_INVALID, and an error (usuallyORA-15196) will be reported in the ASM and/or database alert log (depends onwhich instance discovers the problem).
kfed write
With the kfed write command we can write to a single ASM metadata block. Thesyntax is:
· text- a text file with the new blockcontents
· checksum=yes- calculate and write the correctchecksum. Note that the checksum in the text file with the new content does nothave to be correct.
Use kfed to write the correct checksum to ASM metadatablock
An ASM metadata maylookfine, but in fact be corrupt. Forexample the block checksum (kfbh.check) could be wrong, in which case thatwould need to be corrected. Indeed, if theonlyproblem is anincorrect checksum, that can be easily corrected by simply reading the blockand then writing it back! The kfed will calculate the new checksum and writethe block back with the correct checksum.
Here are the complete steps to correct the bad checksum for block 2 in AU0 ondisk /dev/sda1:
NOTE: Please seek Oracle Support assistance with any suspected ASM metadatablock corruption.
kfed find
The kfed find will examine all blocks in an allocation unit and report back onthe block types found. The syntax is:
We see that the find command parameters are the same as for the read command,but the difference is that the find operates on all blocks in an allocationunit.
Use kfed find command to verify blocks in AU0
This is an example of using the kfed find to verify that all blocks in AU0 havethe expected ASM metadata.
The expected result is type 1 for block 0, type 2 for block 1 and type 3 forall other blocks, i.e.:
Data type
Value
kfbh.endian
System endianness. 0 - big endian, 1 - little endian.
kfbh.type
ASM block type.KFBTYP_DISKHEADtells us this is an ASM disk header block.
kfbh.block.blk
ASM block number. Note the ASM disk header isblock number 0.
ImportantASM disk headerspecific data
Data type
Value
kfdhdb.driver.provstr
ORCLDISK+[ASM disk name] for ASMLIB disks.ORCLDISK for non-ASMLIB disks.
kfdhdb.dsknum
ASM disk number.
kfdhdb.grptyp
Disk group redundancy. KFDGTP_EXTERNAL - external, KFDGTP_NORMAL - normal, KFDGTP_HIGH - high.
kfdhdb.hdrsts
ASM disk header status. For possible values see V$ASM_DISK.HEADER_STATUS.
kfdhdb.dskname
ASM disk name.
kfdhdb.grpname
ASM disk group name.
kfdhdb.fgname
ASM failgroup name.
kfdhdb.crestmp.hi|lo
The date and time disk was added to the disk group.
kfdhdb.mntstmp.hi|lo
Last time the disk was mounted.
kfdhdb.secsize
Disk sector size (bytes).
kfdhdb.blksize
ASMmetadata block size(bytes).
kfdhdb.ausize
Alloocation unit size(bytes). 1 MB is the default allocation unit size.
kfdhdb.dsksize
Disk size(allocation units). In this case the disk size is 10239 MB.
kfdhdb.fstlocn
Pointer to ASM Free Space Table. 1 = ASM block 1 in this allocation unit.
kfdhdb.altlocn
Pointer to ASM Allocation Table. 2 = ASM block 2 in this allocation unit.
kfdhdb.f1b1locn
Pointer to ASM File Directory. 2 = allocation unit 2.
kfdhdb.dbcompat
Minimum database version. 0x0a100000 = 10.1.
kfdhdb.grpstmp.hi|lo
The date and time the disk group was created.
kfdhdb.vfstart|vfend
Start and end allocation unit number for theclusterware voting disk. If this is zero, the disk does not have voting disk data. Version 11.2 and later only.
kfdhdb.spfile
Allocation unit number of the ASM spfile.Version 11.2 and later only.
kfdhdb.spfflg
ASM spfile flag. If this is 1, the ASM spfile is on this disk in allocation unit kfdhdb.spfile.Version 11.2 and later only.
ASM disk header backup
In ASM versions 11.1.0.7 and later, the ASM disk header block is backed up inthe second last ASM metadata block in the allocation unit 1. To work out thesecond last blocknumberwe need to know the allocation unitsize and ASM metadata block size.
I talked about this in my post onkfed, but let's do that again - get thosevalues from the block header and calculate the second last block number inallocation unit 1:
$ ausize=`kfed read/dev/oracleasm/disks/ASMD1 | grep ausize | tr -s ' ' | cut -d' ' -f2`
$ blksize=`kfed read /dev/oracleasm/disks/ASMD1 | grep blksize | tr -s ' ' |cut -d' ' -f2`
$ let n=$ausize/$blksize-2
$ echo $n
254
$ kfed read /dev/oracleasm/disks/ASMD1 aun=1 blkn=254
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: 473773689 ; 0x00c: 0x1c3d3679
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKASMD1 ; 0x000: length=13
...
kfdhdb.dsknum: 0 ; 0x024: 0x0000
kfdhdb.grptyp: 1 ; 0x026: KFDGTP_EXTERNAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: ASMD1 ; 0x028: length=5
kfdhdb.grpname: DATA ; 0x048: length=4
kfdhdb.fgname: ASMD1 ; 0x068: length=5
...
So we see the same contents as in block0 in allocation unit 0.
This can be very handy when the diskheader is damaged or lost. All we have to do is runkfed repair [disk_name], and specify the allocation unit sizeif the value is not default (1MB). But as I said in the kfed post, please do notdo this on your own - seek Oracle Support assistance if you suspect problemswith ASM disk header.
ASM disk header in Exadata
ASM disks in Exadata are not exposed to the OS via device names. Instead theycan be accessed via special name - "o/[IP address]/[disk name]". The kfed understands thatsyntax, so we can still use it in Exadata.
Let's have a look at the ASM disk header on an Exadata disk:
$ kfed reado/192.168.10.9/DBFS_DG_CD_03_exadatacel01
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
...
kfdhdb.dskname:DBFS_DG_CD_03_EXADATACEL01 ; 0x028: length=26
kfdhdb.grpname: DBFS_DG ; 0x048: length=7
kfdhdb.fgname: EXADATACEL01 ; 0x068: length=12
...
kfdhdb.ausize: 4194304 ; 0x0bc: 0x00400000
...
Some Exadata specific values in the ASM disk header are as follows:
· ASM disk name that consists of the diskgroup name (DBFS_DG), cell disk label (CD), cell disk number (3) and thestorage cell name (exadatacel01)
· Failgroup name is the same as thestorage cell name
· Default allocation unit size in Exadatais 4 MB
Conclusion
ASM disk header contains the metadata essential for the operation andavailability of an ASM disk group. To prevent the loss and accidental damage ofthe ASM disk header, Oracle recommends to protect it by partitioning the disk -thus 'moving' it away from the physical beginning of the disk. The ASM diskheader in Exadata is protected by not exposing it to the database server OS. InASM version 11.1.0.7 and later, the ASM disk header is further protected bymaintaining a copy in allocation unit 1.
文章来源:
http://asmsupportguy.blogspot.com/2010/04/kfed-asm-metadata-editor.html
http://asmsupportguy.blogspot.com.au/2011/08/asm-disk-header.html
另外还可以参考文章:《ASM tools used by Support : KFOD, KFED, AMDU (文档 ID 1485597.1)》
--end--
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。