Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » ASM

How to use amdu(ASM Metadata Dump Utility)

AMDU(ASM Metadata Dump Utility),从11g开始,oracle提供了这么个工具,在10g中也可以使用,需要从MOS上下载相应版本的文件。功能非常强大,在磁盘头损坏的情况下,可以直接从DiskGroup中抽取出数据文件,还可以用来检测Normal/High redundancy磁盘组的镜像,输出块内容等。在12c中,amdu整合到asmcmd命令中,当然amdu也可单独使用。

[orgrid@ohs1 ~]$ amdu -help
al/lides                Dump indirect blks unconditionally
-allides: AMDU ordinarily skips over empty indirect blocks. Specifying
    this option tells AMDU to dump those blocks unconditionally. Be
    warned that this can make the resulting AMDU dump quite large.

au/size         AU size for corrupt disks
-ausize <bytes>: This option must be set when -baddisks is set. It
    must be a power of 2. This size is required to scan a disk looking
    for metadata, and it is normally read from the disk header. The
    value applies to all disks that do not have a valid header. The
    value from the disk header will be used if a valid header is
    found.

ba/ddisks               Include disks with bad headers
-baddisks <diskgroup>:  Normally disks with bad disk headers, or that
    look like they were never part of a disk group, will not be
    scanned. This option forces them to be scanned anyway and to be
    considered part of the given diskgroup. This is most useful when
    a disk header has been damaged. The disk will still need to have
    a valid allocation table to drive the scan unless -fullscan is
    used. In any case at least one block in the first two AUs must be
    valid so that the disk number can be determined. The options
    -ausize and -blksize are required since these values are normally
    fetched from the disk header. If the diskgroup uses external
    redundancy then -external should be specified. These values will
    be compared against any valid disks found in the diskgroup and
    they must be the same.

bl/ksize                ASM block size for corrupt disks
-blksize <bytes>: This option must be set when -baddisks is set. It
    must be a power of 2. This size is required to scan a disk looking
    for metadata, and it is normally read from the disk header. The
    value applies to all disks that do not have a valid header. The
    value from the disk header will be used if a valid header is
    found.

c/ompare                Compare file mirrors
-compare: This option only applies to file extraction from a normal or
    high redundancy disk group. Every extent that is mirrored on more
    than one discovered disk will have all sides of its mirror
    compared. If they are not identical a message will be reported
    on standard error and the report file. The message will indicate
    which copy was extracted. A count of the blocks that are not
    identical will be in the report file.

dir/ectory              Directory from previous dump
-directory <string>: This option completely eliminates the discovery
    phase of operation. It specifies the name of a dump directory from
    a previous run of AMDU. The report file and map files are read
    instead of doing a discovery and scan. The parsing of these ASCII
    files is very dependent on them being exactly as written by AMDU.
    AMDU is unlikely to work properly if they have been modified by
    a text editor, or if some of the files are missing or truncated.
    Note that the directory may be a copy FTPed from another
    machine. The other machine may even be a different platform
    with a different endianess.

dis/kstring             Diskstring for discovery
 -diskstring <string>: By default the null string is used for
    discovery. The null string should discover all disks the user has
    access to. Many installations specify an asm_diskstring parameter
    for their ASM instance. If so that parameter value should be given
    here. Multiple discovery strings can be specified by multiple
    occurrences of -diskstring <string>. Beware of shell syntax
    conflicts with discovery strings. Diskstrings are usually the same
    syntax the shell uses for expanding path names on command lines so
    they will most likely need to be enclosed in single quotes.

du/mp           Diskgroups to dump
-dump <diskgroup>: This option specifies the name of a diskgroup to
    have its metadata dumped. This option may be specified multiple
    times to dump multiple diskgroups. If the diskgroup name is ALL
    then all diskgroups encountered will be dumped. The diskgroup name
    is not case sensitive, but will be converted to uppercase for all
    reports. If this option is not specified then no map or image
    files will be created, but -extract and -print may still work.

exc/lude                Disks to exclude
-exclude <string>: Multiple exclude options may be specified. These
    strings are used for discovery just like the values for diskstring.
    Only shallow discovery is done on these diskstrings. Any disks
    found in the exclude discovery will not be accessed. If they are
    also discovered using the -diskstring strings, then the report will
    include the information from shallow discovery along with a message
    indicating the disk was excluded.

exte/rnal               Assume external redundancy
-external: Normally AMDU determines the diskgroup redundancy from the
    disk headers. However this is not possible with the -baddisks
    option. It is assumed that the redundancy of the -baddisks
    diskgroup is normal or high unless this option is given to specify
    external redundancy.

extr/act                Files to extract
-extract <diskgroup>.<file_number>: This extracts the numbered file
    from the named diskgroup, case insensitive. This option may be
    specified multiple times to extract multiple files. The extracted
    file is placed in the dump directory under the name
    <diskgroup>_<number>.f  where <diskgroup> is the diskgroup name
    in uppercase, and <number> is the file number. The -output option
    may be used to write the file to any location. The extracted file
    will appear to have the same contents it would have if accessed
    through the database. If some portion of the file is unavailable
    then that portion of the output file will be filled with
    0xBADFDA7A, and a message will appear on stderr.

fi/ledump               Dump files rather than extract
-filedump: This option causes the file objects in the command line to
    have their blocks dumped to the image files rather than extracted.
    This can be combined with the -novirtual option to selectively
    dump only some of the metadata files. It may also be used to dump
    user files (number >= 256) so that all mirrored copies can be
    examined.

fo/rmer         Include dropped disks
-former: Normally disks marked as former are not scanned, but this
    option will scan them and include their contents in the output.
    This is useful when it is necessary to look at the contents of a
    disk that was dropped. Note that dropped normal disks will not have
    any entries in their allocation tables and thus only the physically
    addressed extents will be dumped. Force dropped disks will not have
    status former in their disk headers and are not affected by this
    option. However if DROP DISKGROUP is used, the disks will have the
    contents as of the time of the drop, and will be in status former.
    Thus this option is useful for extracting files from a dropped
    diskgroup.

fu/llscan               Scan entire disk
-fullscan: This option reads every AU on the disk and looks at the
    contents of the AU rather than limiting the AU's read based on the
    allocation table. This is useful when the allocation table is
    corrupt or needs recovery. An AU will be written to the image file
    if it starts with a block that contains a valid ASM block header.
    The file and extent information for the map will be extracted from
    the block header. Physically addressed metadata will be dumped
    regardless of its contents. This option is incompatible with
    extracting a file. It is an error to specify -extract with this
    option. Note that this option is likely to find old garbage
    metadata in unallocated AU's since there is no means of
    determining what is allocated. Thus there may be many different
    copies of the same block, possibly of different versions.

h/ex            Always print block contents in hex
-hex: This prints the block contents in hex without attempting to print
    them as ASM metadata. This is useful when the block is known to not
    be ASM metadata. It avoids the ASM block header dump and ensures
    the block is not accidentally interpreted as ASM metadata. This
    option requires at least one -print option.

noa/cd          Do not dump ACD
-noacd: This option limits the dumping of the Active Change Directory
    to just the control blocks that contain the checkpoint. There is
    126 MB of ACD per ASM instance (42 MB for external redundancy). It
    is normally of no interest if there has been a clean shutdown or
    no updates for a while. This option avoids dumping a lot of
    unimportant data. The blocks will still be read and checked for
    corruption. The map file will still contain entries for the ACD
    extents, but the block counts will be zero.

nod/ir          Do not create a dump directory
-nodir: No dump directory is created, and no files are created in it.
    The directory name is not written to standard out. The report file
    is written to standard out before any block printouts from any
    -print options.  This option conflicts with -filedump. It is an
    error to specify this and extract a file to the dump directory.

noe/xtract              Do not create extracted file
-noextract: This prevents files from being extracted to an output
    file, but the file will be read and any errors in selecting the
    correct output will be reported. This is most useful in
    combination with the -compare option.

noh/eart                Do not check for heartbeat
-noheart: Normally the heartbeat block will be saved at discovery time
    and checked when the disk is scanned. A sleep is added between
    discovery and scanning to ensure there is time for the heartbeat
    to be written. If the heartbeat block changes then it is most
    likely that the diskgroup containing this disk is mounted by an
    active ASM instance. An error and warning is generated but
    operation proceeds normally. This option suppresses this check
    and avoids the sleep.

noi/mage                Do not create image files
-noimage: No image files will be created n the dump directory. All
    the reads specified by the read options will still be done. The
    map files may be used to find blocks on the disks themselves. In
    the map file, the count of blocks dumped, the image file sequence
    number, and the byte offset in the image file will all always be
    zero (C00000 S0000 B0000000000)

nom/ap          Do not create map or image files
-nomap: No map file is created and no image file is created. The only
    output is the report file. The -noimage option is assumed if this
    is set since an image file without a map is useless. The options
    -noscan and -noread also result in no map or image files, but
    -nomap still reads the metadata to check for I/O errors and corrupt
    blocks.

nop/rint                Do no print block contents
-noprint: This suppresses the printout of the block contents for
    blocks printed with the -print option. It is useful for getting
    just the block reports without a lot of data. This option requires
    at least one -print option.

norea/d         Shallow discovery only
-noread: This eliminates any reading of any disks at all. Only shallow
    discovery will be done. The report will end after the discovery
    section. It is an error to specify this option and specify a file
    to extract or blocks to print. It is an error to specify this
    and -fullscan.

norep/ort               Do not generate a report
-noreport: This suppresses the generation of the report file. It is
    most useful in combination with -nodir and -print to get block
    printouts without a lot of clutter. It is unnecessary to include
    this with -directory since no report is generated then anyway.

nosc/an         Deep discovery only
-noscan: This eliminates any reading of any disks after deep
    discovery. This results in just doing a deep discovery using the
    disksting parameter. The report will end after the discovery
    section. It is an error to specify this option and specify a file
    to extract. It is an error to specify this and -fullscan.

nosu/bdir               Do not create a dump directory
-nosubdir: No dump directory is created, but files are still created.
    The directory name is not written to standard out. The report file
    and any other dump or extract  files are written to the current
    directory or to the directory indicated by -parentdir. This means
    that if multiple AMDU dumps are requested using this option, the
    report file will always correspond to the last dump requested.

nov/irtual              Do not dump virtual metadata
-novirtual: This option eliminates reading of any virtual metadata.
    Only the physically addressed metadata will be read. This
    implicitly eliminates the ACD and extent maps so -noacd and
    -noxmap will be assumed.

nox/map         Do not dump extent maps
-noxmap: This option eliminates reading of the indirect extents
    containing the file extent maps. This is the bulk of the metadata
    in most diskgroups. Even the entries in the map file will be
    eliminated.

o/utput         Files to create for extract
-output <file_name>: This option specifies a different file for
    writing an extracted file. The file will be overwritten if it
    already exists. This option requires that exactly one file is
    extracted via the -extract option. Required with -directory

pa/rent         Parent for dump directory
-parent <path_name>: By default the dump directory is created in the
    current directory, but another directory can be specified using
    this option. The parent directory for the dump directory must
    already exist.

pr/int          Block to print
-print <block_spec>: This option prints one or more blocks to standard
    out. This option may be specified multiple times to print multiple
    <block_spec>s. The printout contains information about how each
    block was read as well as a formatted printout. Multiple blocks
    matching the same <block_spec> may be found when scanning the
    disks. For example there may be multiple disks that have headers
    for the same diskgroup and disk number. If the block is from a
    mirrored file then multiple copies should exist on different disks.
    If multiple copies of the same block have identical contents then
    only one formatted printout of the contents will be generated, but
    a header will be printed for each copy. A <block_spec> may include
    a count of sequential blocks to print. A <block_spec> may specify
    a block either by disk or file.
   <block_spec> ::= <single_block> | <single_block>.C<count>
   <single_block> ::= <report_disk_block> | <group_disk_block> |
        <extent_file_block> | <virtual_file_block> | <xmap_file_block>
   <report_disk_block> ::=
        <group_name>.N<report_number>.A<au_number>.B<block_number>
   <group_disk_block> ::=
         <group_name>.D<disk_number>.A<au_number>.B<block_number>
   <extent_file_block> ::=
         <group_name>.F<file_number>.X<physical_extent>.B<block_number>
   <virtual_file_block> ::=
         <group_name>.F<file_number>.V<virtual_block_number>
   <xmap_file_block> ::=
         <group_name>.F<file_number>.M<extent_map_block_number>

r/egistry               Dump registry files
-registry: The ASM registries will be read and dumped to the image
    file. There will be no block consistency checks since these files
    do not have ASM cache headers. To dump one specific registry
    specify -filedump and include the file object for the registry
    (e.g. DATA.255).

s/pfile         Extract usable spfile
-spfile: This causes extract to render the resulting file in a form   
    that is directly usable by startup. Without this option, AMDU   
    will extract the file as a regular ASM file including all ASM   
    specific headers and such
.
[orgrid@ohs1 ~]$

12c amdu已整合到asmcmd中
[orgrid@ohs1 ~]$ asmcmd help amdu_extract
amdu_extract
        Calls AMDU to extract <file> from <disk group>

Synopsis
        amdu_extract <disk group> <file> <diskstring>

Description
        The options for amdu_extract command are described below:
        disk group - Name of the disk group containing the file to be extracted.        
        file       - Name of the file to be extracted. Can be specified as either an absolute or a relative path.
        diskstring - Specifies the value for the discovery diskstring.

Examples
        The following example uses amdu_extract to extract the parameter file from the '+datafile'
        disk group.

        ASMCMD [+] > amdu_extract datafile +datafile/parameterfile/spfile.ora /devices/disk*
[orgrid@ohs1 ~]$ 

amdu不创建目录直接生成报告
[orgrid@ohs1 ~]$ amdu -nodir
******************************* AMDU Settings ********************************
ORACLE_HOME = /pgold/orgrid/oracle/product/121
System name:    Linux
Node name:      ohs1.ohsdba.cn
Release:        4.1.12-37.4.1.el6uek.x86_64
Version:        #2 SMP Tue May 17 07:23:38 PDT 2016
Machine:        x86_64
amdu run:       07-SEP-16 02:35:28
Endianess:      1

--------------------------------- Operations ---------------------------------

------------------------------- Disk Selection -------------------------------
 -diskstring ''

------------------------------ Reading Control -------------------------------

------------------------------- Output Control -------------------------------
    -noimage
      -nomap
      -nodir

********************************* DISCOVERY **********************************

----------------------------- DISK REPORT N0001 ------------------------------
                Disk Path: ORCL:ASM1
           Unique Disk ID:
               Disk Label: ASM1
     Physical Sector Size: 512 bytes
                Disk Size: 8189 megabytes
               Group Name: SYSTEMDG
                Disk Name: ASM1
       Failure Group Name: ASM1
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/09/04 02:16:33.002000
          Last Mount Time: 2016/09/06 13:01:02.906000
    Compatibility Version: 0x0c100000(12010000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 8189 AUs
         Group Redundancy: 1
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/09/04 02:16:32.955000
  File 1 Block 1 location: AU 10
     Voting File Start AU: 224
       Voting File End AU: 256
              OCR Present: YES
             Exadata Disk: NO

----------------------------- DISK REPORT N0002 ------------------------------
                Disk Path: ORCL:ASM2
           Unique Disk ID:
               Disk Label: ASM2
     Physical Sector Size: 512 bytes
                Disk Size: 4102 megabytes
               Group Name: FRA_PGOLD
                Disk Name: ASM2
       Failure Group Name: ASM2
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/09/04 09:30:48.112000
          Last Mount Time: 2016/09/06 20:31:11.790000
    Compatibility Version: 0x0c100000(12010000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 4102 AUs
         Group Redundancy: 1
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/09/04 09:30:48.062000
  File 1 Block 1 location: AU 10
     Voting File Start AU: 0
       Voting File End AU: 0
              OCR Present: NO
             Exadata Disk: NO

----------------------------- DISK REPORT N0003 ------------------------------
                Disk Path: ORCL:ASM3
           Unique Disk ID:
               Disk Label: ASM3
     Physical Sector Size: 512 bytes
                Disk Size: 8181 megabytes
               Group Name: DATA_PGOLD
                Disk Name: ASM3
       Failure Group Name: ASM3
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/09/04 09:28:51.184000
          Last Mount Time: 2016/09/06 13:01:02.481000
    Compatibility Version: 0x0c100000(12010000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 8181 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/09/04 09:28:51.061000
  File 1 Block 1 location: AU 10
     Voting File Start AU: 0
       Voting File End AU: 0
              OCR Present: NO
             Exadata Disk: NO

----------------------------- DISK REPORT N0004 ------------------------------
                Disk Path: ORCL:ASM4
           Unique Disk ID:
               Disk Label: ASM4
     Physical Sector Size: 512 bytes
                Disk Size: 4102 megabytes
** NOT A VALID ASM DISK HEADER. BAD VALUE IN FIELD blksize_kfdhdb **

----------------------------- DISK REPORT N0005 ------------------------------
                Disk Path: ORCL:ASM5
           Unique Disk ID:
               Disk Label: ASM5
     Physical Sector Size: 512 bytes
                Disk Size: 8181 megabytes
               Group Name: DATA_PGOLD
                Disk Name: ASM5
       Failure Group Name: ASM5
              Disk Number: 1
            Header Status: 3
       Disk Creation Time: 2016/09/04 09:28:51.184000
          Last Mount Time: 2016/09/06 13:01:02.481000
    Compatibility Version: 0x0c100000(12010000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 8181 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/09/04 09:28:51.061000
  File 1 Block 1 location: AU 10
     Voting File Start AU: 0
       Voting File End AU: 0
              OCR Present: NO
             Exadata Disk: NO
[orgrid@ohs1 ~]$

amdu dump metadata
$amdu -dis '/dev/oracleasm/disks/ASM*'  -dump 'DATA_PGOLD'
amdu_2016_08_14_09_14_11/
目录下会生成3个文件,一个map文件,一个img文件,一个report.txt文件,目录格式为amdu_YYYY_MM_DD_HH24_MM_SS
map文件是ASM元数据在磁盘上准确位置
img文件是磁盘组元数据的二进制文件
txt文件包含了磁盘组的信息,磁盘信息,AU信息等
map的格式为
N0014 D0002 R00 A00000002 F00000002 I0 E00000000 U00 C00256 S0001 B0035663872
N0014 -- DISK REPORT N0014
D0002 -- Disk # 2
A00000002 -- Allocation Unit 2
F00000002 -- File#2

如何使用amdu抽取数据文件
 可以通过数据库alert日志,找到控制文件的编号
 通过amdu抽取出控制文件
     amdu -dis '/dev/oracleasm/disks/ASM*' -extract DATA_PGOLD.261
 通过strings或其他命令查看控制文件中数据文件信息
     strings -a DATA_PGOLD_261.f |grep DATA_PGOLD
 通过amdu抽取其他数据文件
     amdu -dis '/dev/oracleasm/disks/ASM*' -extract DATA_PGOLD.262
     amdu -dis '/dev/oracleasm/disks/ASM*' -extract DATA_PGOLD.<File Number>

如何检查潜在的损坏问题,可查看report.txt文件
  amdu -dis '/dev/oracleasm/disks/ASM*' -compare -extract DATA_PGOLD.262 -noextract

如何打印块的信息,下面列出了能用的格式
-print <block_spec>: This option prints one or more blocks to standard out.
   <block_spec> ::= <single_block> | <single_block>.C<count>
   <single_block> ::= <report_disk_block> | <group_disk_block> | <extent_file_block> | <virtual_file_block> | <xmap_file_block>
   <report_disk_block> ::=
        <group_name>.N<report_number>.A<au_number>.B<block_number>
   <group_disk_block> ::=
         <group_name>.D<disk_number>.A<au_number>.B<block_number>
   <extent_file_block> ::=
         <group_name>.F<file_number>.X<physical_extent>.B<block_number>
   <virtual_file_block> ::=
         <group_name>.F<file_number>.V<virtual_block_number>
   <xmap_file_block> ::=
         <group_name>.F<file_number>.M<extent_map_block_number>

  amdu -dis '/dev/oracleasm/disks/ASM*' -print DATA_PGOLD.D2.A1.B1.C5


Reference
Placeholder for AMDU binaries and using with ASM 10g (Doc ID 553639.1)

http://canali.web.cern.ch/canali/



关键词:amdu asm 

相关文章

Oracle ASM from 10g to 18c
在18c中通过ASM Flex DiskGroup克隆PDB
Exadata and ASM
Oracle ASM Storage Limits
12c 如何将Standard ASM转化为Flex ASM
How to use amdu(ASM Metadata Dump Utility)
How to use kfed(Kernel Files metadata Editor)
How to use kfod(Kernel Files OSM Disk)
如何计算ASM磁盘头自动备份的位置
What is disk_repair_time?
Find block in ASM
12c新特性ASMFD
Top