暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle数据恢复:AMDU恢复ASM磁盘组数据

原创 eygle 2012-03-04
865

在Oracle 10g中,ASM磁盘组的信息需要在Mount之后才能通过内部视图查询,如果磁盘组因为故障无法正常加载,那么信息将不可用,这为诊断带来了诸多不便。


从Oracle 11g开始,Oracle提供了一个工具AMDU用于协助诊断,通过这个工具可以在磁盘组加载之前将ASM的元数据抽取出来,用于数据库诊断,这个工具可以向后兼容,引入到10g中。AMDU工具也可以用于直接从ASM磁盘组中抽取数据文件,这位ASM的数据恢复提供了极大的便利。我们最近使用这个工具帮助用户挽救了崩溃的数据库。当ASM出现故障时,AMDU就开始大有用武之地。

从MOS上可以下载Oracle 10g版本的AMDU ( Note: 553639.1 ) 工具。






































Platform

Linux X86 (Platform 46)
amdu_lnx_32.zip
Linux X86-64 AMD64/EM64T (Platform 226)
amdu_lnx_X86-64.zip
Solaris 10 Sparc 64bit (Platform 23)
amdu_solaris10_64.zip
Solaris 9 Sparc 64bit (Platform 23)
amdu_solaris9_64.zip
HP-UX PA-RISC 64bits (Platform 59)
amdu_HP-PARISC.zip
HP-UX Itanium (Platform 197)
amdu_hp_itanium.zip
AIX
amdu_aix.zip
* Additional platforms will be added

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

  1. [oracle@enmou1 ~]$ amdu  
  2. amdu_2011_03_29_10_28_41/  
  3. [oracle@enmou1 ~]$ cd amdu_2011_03_29_10_28_41/  
  4. [oracle@enmou1 amdu_2011_03_29_10_28_41]$ ls  
  5. report.txt 

该报告的主要内容如下:

  1. [oracle@enmou1 amdu_2011_03_29_10_28_41]$ more report.txt  
  2. -*-amdu-*-  
  3.  
  4. ******************************* AMDU Settings 
    ********************************  
  5. ORACLE_HOME = /u01/app/db/11.2.0  
  6. System name:    Linux  
  7. Node name:      enmou1  
  8. Release:        2.6.18-128.el5  
  9. Version:        #1 SMP Wed Dec 17 11:41:38 EST 2008  
  10. Machine:        x86_64  
  11. amdu run:       29-MAR-11 10:28:41  
  12. Endianess:      1  
  13. --------------------------------- Operations 
    ---------------------------------  
  14. ********************************* DISCOVERY *
    *********************************  
  15.  
  16. ----------------------------- DISK REPORT N0001 
    ------------------------------  
  17.                 Disk Path: ORCL:VOL1  
  18.            Unique Disk ID:  
  19.                Disk Label: VOL1  
  20.      Physical Sector Size: 512 bytes  
  21.                 Disk Size: 1954 megabytes  
  22.                Group Name: CRSDG  
  23.                 Disk Name: VOL1  
  24.        Failure Group Name: VOL1  
  25.               Disk Number: 0  
  26.             Header Status: 3  
  27.        Disk Creation Time: 2011/03/17 11:39:10.772000  
  28.           Last Mount Time: 2011/03/29 09:21:38.608000  
  29.     Compatibility Version: 0x0b200000(11020000)  
  30.          Disk Sector Size: 512 bytes  
  31.          Disk size in AUs: 1954 AUs  
  32.          Group Redundancy: 1  
  33.       Metadata Block Size: 4096 bytes           
    -〉元数据块大小,4K  
  34.                   AU Size: 1048576 bytes         -〉AU大小:1M  
  35.                    Stride: 113792 AUs  
  36.       Group Creation Time: 2011/03/17 11:39:10.671000  
  37.   File 1 Block 1 location: AU 2                
    -〉文件使用,从AU 2开始  
  38.               OCR Present: NO  
  39.  
  40. ******************************* END OF REPORT **
    ****************************** 

定义特定的参数可以获得ASM磁盘组内部的区间分配等详细信息。以下命令指定转储CRSDG的磁盘组信息,除了报告文件外,还生成了map和img信息文件:

  1. [oracle@enmou1 ~]$ amdu -diskstring '/
    dev/oracleasm/disks/VOL*' -dump 'CRSDG'  
  2. amdu_2011_03_29_10_36_03/  
  3. [oracle@enmou1 ~]$ cd amdu_2011_03_29_10_36_03/  
  4. [oracle@enmou1 amdu_2011_03_29_10_36_03]$ ls  
  5. CRSDG_0001.img  CRSDG.map  report.txt 

这里MAP文件的信息如下,其内容描述了ASM元数据在磁盘组中的位置,最后部分就是指针信息:

  1. [oracle@enmou1 amdu_2011_03_29_10_36_03]$ more CRSDG.map  
  2. N0001 D0000 R00 A00000000 F00000000 I0 E00000000 
    U00 C00256 S0001 B0000000000  
  3. N0001 D0000 R00 A00000001 F00000000 I0 E00000000
    U00 C00256 S0001 B0001048576  
  4. N0001 D0000 R00 A00000002 F00000001 I0 E00000000
    U00 C00256 S0001 B0002097152  
  5. N0001 D0000 R00 A00000003 F00000002 I0 E00000000
    U00 C00256 S0001 B0003145728  
  6. N0001 D0000 R00 A00000004 F00000003 I0 E00000000 
    U00 C00256 S0001 B0004194304 
而IMG文件则是元数据块的镜像转储,为二进制文件,这些文件在ASM出现故障时,可以用于收集信息,分析故障。

使用AMDU恢复ASM磁盘组中的文件,只需要一个命令:
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.

指定磁盘组和文件号即可恢复ASM磁盘组中的文件,以下是为用户恢复数据的过程日志记录:
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.271
amdu_2012_02_21_17_53_49/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.272
amdu_2012_02_21_17_54_00/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.273
amdu_2012_02_21_17_54_29/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.274
amdu_2012_02_21_17_55_01/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.276
amdu_2012_02_21_17_55_12/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.275
amdu_2012_02_21_17_55_23/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.277
amdu_2012_02_21_17_55_33/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.278
amdu_2012_02_21_17_55_47/
[grid@svr06 /amdu_data]$ amdu -extract DG_DATA.279
amdu_2012_02_21_17_56_01/
[grid@svr06 /amdu_data]$cd amdu_2012_02_21_17_56_01
[grid@svr06 /amdu_data/amdu_2012_02_21_17_56_01]$ls -lt
total 205036
-rw-r--r-- 1 grid oinstall 209723392 Feb 21 17:56 DG_DATA_279.f
-rw-r--r-- 1 grid oinstall     13889 Feb 21 17:56 report.txt
有效的使用extract选项,Oracle ASM的恢复不再复杂。

同事曾经记录过的内容:
http://blog.csdn.net/marvelyu/article/details/7296524


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论