zoukankan      html  css  js  c++  java
  • 如何用AMDU从不能mount的ASM磁盘组中往外抽取数据文件

        AMDU是Oracle 11g里自带的一个免费的工具,用于分析ASM磁盘组的元数据以及从不能mount的磁盘组中往外抽取数据文件。

     “NOTE:553639.1 Placeholder for AMDU binaries and using with ASM 10g明确指出:AMDU也可用于10g,并提供了可用于10g的AMDU的各个操作系统的版本供大家下载。

         AMDU的原理是解析file directory,这一点ODU也是一样,只不过ODU做的更彻底一些,即使file directory全部损坏,ODU也可以把数据文件抽取出来,尽最大的可能挽救用户的数据。

     
    通过 ASMCMD 的find命令,结合--type 参数 , 指定查找文件类型 为controfile 的文件:
    $ asmcmd find --type controlfile + "*"
     
     
    [oracle@host01 ~]$ asmcmd find --type controlfile + "*"
    +DATA/RACDB/CONTROLFILE/Current.260.1008788305
    +FRA/RACDB/CONTROLFILE/Current.256.1008788307
     
    [oracle@host01 ~]$ asmcmd find --type ASMPARAMETERFILE +DATA "*"
    +DATA/cluster/ASMPARAMETERFILE/REGISTRY.253.1008778067
    ​
    [oracle@host01 ~]$ asmcmd find --type PARAMETERFILE +DATA "*"   
    +DATA/RACDB/PARAMETERFILE/spfile.267.1008788603
    +DATA/RACDB/spfileRACDB.ora
     
    [oracle@host01 ~]$ asmcmd find --type datafile  + "*"  
    +DATA/RACDB/DATAFILE/SYSAUX.257.1008788141
    +DATA/RACDB/DATAFILE/SYSTEM.256.1008788139
    +DATA/RACDB/DATAFILE/UNDOTBS1.258.1008788143
    +DATA/RACDB/DATAFILE/UNDOTBS2.264.1008788475
    +DATA/RACDB/DATAFILE/USERS.259.1008788145
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ asmcmd find --type onlinelog  + "*"         
    +DATA/RACDB/ONLINELOG/group_1.261.1008788309
    +DATA/RACDB/ONLINELOG/group_2.262.1008788317
    +DATA/RACDB/ONLINELOG/group_3.265.1008788583
    +DATA/RACDB/ONLINELOG/group_4.266.1008788591
    +FRA/RACDB/ONLINELOG/group_1.257.1008788313
    +FRA/RACDB/ONLINELOG/group_2.258.1008788321
    +FRA/RACDB/ONLINELOG/group_3.259.1008788587
    +FRA/RACDB/ONLINELOG/group_4.260.1008788597
     
    提取控制文件:
    我们提取+DATA  下的控制文件Current.260.1008788305
    首先查看:+DATA 磁盘组里有那些磁盘:
    [oracle@host01 ~]$ asmcmd lsdsk -G data
    Path
    /dev/oracleasm/disks/ASMDISK1
    /dev/oracleasm/disks/ASMDISK2
    /dev/oracleasm/disks/ASMDISK3
    /dev/oracleasm/disks/ASMDISK4
     
     
    详细的磁盘名:也可能通过spfile里查询的  asm_diskstring 参数查询:
    SQL> show parameter asm_diskstring
    ​
    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    asm_diskstring string /dev/oracleasm/disks/*
     
     
    用amdu  导出控制文件 :amdu -diskstring="/dev/oracleasm/disks/*" -extract DATA.260 -output control.260 -noreport -nodir
    amdu :参数说明:
     diskstring: "使用磁盘的全路径,或者是ASM_DISKSTRING" 参数值      例: “ORCL:*”
     extract :   磁盘名.ASM文件序号  ;                                                           例: DATA.260
     output:    提取的输出文件(当前目录下)
     noreport: 不输出amdu 的执行过程 
     nodir : 不创建dump 目录 
     
    [oracle@host01 tmp]$cd /tmp
    [oracle@host01 tmp]$ amdu -diskstring="/dev/oracleasm/disks/*" -extract  DATA.260  -output control.260 -noreport -nodir
    AMDU-00204: Disk N0001 is in currently mounted diskgroup DATA
    AMDU-00201: Disk N0001: '/dev/oracleasm/disks/ASMDISK1'
    AMDU-00204: Disk N0007 is in currently mounted diskgroup DATA
    AMDU-00201: Disk N0007: '/dev/oracleasm/disks/ASMDISK2'
    AMDU-00204: Disk N0008 is in currently mounted diskgroup DATA
    AMDU-00201: Disk N0008: '/dev/oracleasm/disks/ASMDISK3'
    ​
    [oracle@host01 tmp]$ ls -l control.260
    -rw-r--r-- 1 oracle oinstall 18497536 May 21 14:39 control.260
    ​
    [oracle@host01 tmp]$ strings control.260                          #查看控制文件内容 
    ​
    +DATA/racdb/onlinelog/group_2.262.1008788317
    +FRA/racdb/onlinelog/group_2.258.1008788321
    +DATA/racdb/onlinelog/group_1.261.1008788309
    +FRA/racdb/onlinelog/group_1.257.1008788313
    +DATA/racdb/datafile/users.259.1008788145
    +DATA/racdb/datafile/undotbs1.258.1008788143
    +DATA/racdb/datafile/sysaux.257.1008788141
    +DATA/racdb/datafile/system.256.1008788139
     
     
    提取数据文件:
    amdu 对DATA 磁盘组 进行元数据进行dump 备份 
    amdu -diskstring="/dev/oracleasm/disks/*" -dump DATA -noimage
    [oracle@host01  ]$ amdu -diskstring="/dev/oracleasm/disks/*" -dump DATA -noimage   
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ ll
    total 44
    -rw-r--r-- 1 oracle oinstall 26800 May 21 14:52 DATA.map                 #包含数据分布信息 
    -rw-r--r-- 1 oracle oinstall 12996 May 21 14:52 report.txt               #包括系统信息+amdu命令及使用的参数
    ​
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$    more DATA.map 
    N0001 D0000 R00 A00000000 F00000000 I0 E00000000 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000001 F00000000 I0 E00000000 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000002 F00000001 I0 E00000000 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000003 F00000002 I0 E00000000 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000004 F00000003 I0 E00000006 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000005 F00000003 I0 E00000011 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000006 F00000003 I0 E00000013 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000007 F00000003 I0 E00000016 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000008 F00000003 I0 E00000018 U00 C00256 S0000 B0000000000  
    N0001 D0000 R00 A00000009 F00000003 I0 E00000026 U00 C00256 S0000 B0000000000  
    ~~~~~~~~~~~~~~
     
    A 和 F 例说明:
    A00000009    表于AU 009
    F00000003    表示本行与第003 文件呈怕ASM文件相关
    ​
    通过控制文件,或者 asmcmd find --type  datafile  + "*"  查看需要导出的数据文件
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ asmcmd find --type datafile  + "*"     
    +DATA/RACDB/DATAFILE/SYSAUX.257.1008788141
    +DATA/RACDB/DATAFILE/SYSTEM.256.1008788139
    +DATA/RACDB/DATAFILE/UNDOTBS1.258.1008788143
    +DATA/RACDB/DATAFILE/UNDOTBS2.264.1008788475
    +DATA/RACDB/DATAFILE/USERS.259.1008788145
    ​
    这里我们提取256 号system 表空间
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ amdu -diskstring="/dev/oracleasm/disks/*" -extract  DATA.256 -output system.256 
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ ls -lrt system.256 
    -rw-r--r-- 1 oracle oinstall 744497152 May 21 15:37 system.256
    ​
    #然后把在启到mount 把文件指向新路径
    alter database rename <datafile 1> to < newly extracte location>
    #
    ​
    查看256号所使用的AU
    ​
    [oracle@host01 ]$  grep F00000256 DATA.map  
    N0001 D0000 R00 A00000257 F00000256 I1 E00000002 U00 C00003 S0000 B0000000000  
    N0007 D0001 R00 A00000254 F00000256 I1 E00000000 U00 C00003 S0000 B0000000000  
    N0008 D0002 R00 A00000255 F00000256 I1 E00000001 U00 C00003 S0000 B0000000000
    ​
    ​
    D0000 , D0001 , D0002  分别指向了ASMDISK1 第257个AU ,ASMDISK2 第254个AU, ASMDISK3  第255个AU
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ asmcmd lsdsk -G data
    Path
    /dev/oracleasm/disks/ASMDISK1
    /dev/oracleasm/disks/ASMDISK2
    /dev/oracleasm/disks/ASMDISK3
    /dev/oracleasm/disks/ASMDISK4
    ​
    我们可以通过 kfed 查看盖AU里的内容 
    kfed read /dev/oracleasm/disks/ASMDISK1 aun=257 | more 
    ​
    [oracle@host01 amdu_2019_05_21_14_52_03]$ kfed read /dev/oracleasm/disks/ASMDISK1 aun=8 | more 
    kfbh.hard:                          130 ; 0x001: 0x82
    kfbh.type:                           12 ; 0x002: KFBTYP_INDIRECT
    kfbh.datfmt:                          1 ; 0x003: 0x01
    kfbh.block.blk:              2147483648 ; 0x004: blk=0 (indirect)
    kfbh.block.obj:                     256 ; 0x008: file=256
    kfbh.check:                  2971568074 ; 0x00c: 0xb11e87ca
    kfbh.fcn.base:                     1285 ; 0x010: 0x00000505
    kfbh.fcn.wrap:                        0 ; 0x014: 0x00000000
    kfbh.spare1:                          0 ; 0x018: 0x00000000
    kfbh.spare2:                          0 ; 0x01c: 0x00000000
    kffixb.dxsn:                         30 ; 0x000: 0x0000001e
    kffixb.xtntblk:                     480 ; 0x004: 0x01e0
    kffixb.dXrs:                         18 ; 0x006: SCHE=0x1 NUMB=0x2
    kffixb.ub1spare:                      0 ; 0x007: 0x00
    kffixb.ub4spare:                      0 ; 0x008: 0x00000000
    kffixe[0].xptr.au:                  255 ; 0x00c: 0x000000ff
    kffixe[0].xptr.disk:                  1 ; 0x010: 0x0001
    kffixe[0].xptr.flags:                 0 ; 0x012: L=0 E=0 D=0 S=0
    kffixe[0].xptr.chk:                 212 ; 0x013: 0xd4
    kffixe[1].xptr.au:                  258 ; 0x014: 0x00000102
    kffixe[1].xptr.disk:                  0 ; 0x018: 0x0000
    kffixe[1].xptr.flags:                 0 ; 0x01a: L=0 E=0 D=0 
    ~~~~~~~~~~~~~~~~
    ​
    使用kfed获取特定的AU:
    $ kfed read  /dev/oracleasm/disks/ASMDISK1 aunum=257  blknum=0 text=disk1_dd.txt
    注意:从块0开始查看。添加的磁盘的条目可能位于不同的块中
    
    
       注: amdu 提取的,可能是有损坏的或者是已破坏的文件,这取决于文件本生是否已损坏
     
     
  • 相关阅读:
    Java 字符串,byte[],16进制的字符串互转
    Java中char的字节数
    有向图 获取回路转
    java字符串分割处理split及特殊符号 转
    java如何直接跳出外层循环 标签
    求有向图中两点间所有路径
    五周突破N1 第五周第三单元
    5周突破N1 惯用句 1
    5周N1 300P
    5周突破N
  • 原文地址:https://www.cnblogs.com/cqdba/p/126452bc6449303d4e9451cee77c9c4e.html
Copyright © 2011-2022 走看看