Oracle AMDU- ASM Metadata Dump Utility

eric0435發表於2017-01-05

ASM Metadata Dump Utility,即ASM後設資料匯出工具,它的簡寫amdu更被人所熟知,常被Oracle技術支援人員和Oracle開發人員用來診斷和解決ASM故障。它能輸出ASM的後設資料資訊並且從ASM磁碟組中抽取後設資料和資料檔案。 amdu工具不依賴於ASM例項或者ASM磁碟組的狀態,所以它能在ASM例項關閉和磁碟組未掛載的情況下正常使用,它甚至能在ASM磁碟出現故障或者不可見的場景下使用。

使用amdu從mounted磁碟組中抽取控制檔案
在接下來的第一個例子中,我們將以一個處於mount狀態的磁碟組為例,使用amdu提取資料庫jyrac的一個控制檔案。透過asmcmd的find命令結合--type引數,指定查詢檔案型別為controlfile的檔案,以下輸出列出了所有找到的控制檔案的位置

[grid@jyrac1 ~]$  asmcmd find --type controlfile + "*"
+DATADG/JYRAC/CONTROLFILE/current.257.930412709

以上輸出我們可以知道,在DATADG磁碟組存放了JYRAC資料庫控制檔案的一個副本。這裡以提取DATA磁碟組的current.257.930412709控制檔案為例。首先我們看下DATA磁碟組有哪些磁碟:

[grid@jyrac1 ~]$ asmcmd lsdsk -G DATADG
Path
/dev/raw/raw10
/dev/raw/raw11
/dev/raw/raw3
/dev/raw/raw4

DATADG磁碟組共有四塊磁碟/dev/raw/raw10,/dev/raw/raw11,/dev/raw/raw3和/dev/raw/raw4,如果名字都是以ORCL為字首,那麼磁碟是ASMLIB磁碟。嚴格意義上,並不需要知道具體的磁碟名,只需要查詢ASM_DISKSTRING引數值所定義的目錄即可。我們接著用amdu工具將控制檔案從DATA磁碟組提取到檔案系統上:

[grid@jyrac1 ~]$ amdu -diskstring="/dev/raw/*" -extract DATADG.257 -output control.257 -noreport -nodir
AMDU-00204: Disk N0003 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0003: '/dev/raw/raw11'
AMDU-00204: Disk N0009 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0009: '/dev/raw/raw4'
AMDU-00204: Disk N0008 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0008: '/dev/raw/raw3'


[grid@jyrac1 ~]$ ls -lrt control.257 
-rw-r--r-- 1 grid oinstall 18595840 Jan  5 16:03 control.257

此命令相關引數的含義如下:
diskstring: 使用磁碟的全路徑或者是ASM_DISKSTRING引數值
extract: 磁碟組名.ASM檔案序號
output:提取的輸出檔案(當前目錄下)
noreport:不輸出amdu的執行過程
nodir:不建立dump目錄

使用amdu從dismounted磁碟組中抽取資料檔案
上例中從一個已掛載的磁碟組上提取控制檔案的過程簡單明瞭。但在實際工作中,可能有客戶提出要求從一個未掛載的磁碟組中提取一個重要資料檔案,同時並不知道資料檔名,也沒有備份。以下是一個具體的例子,演示了整個操作和分析過程。本例的目標是使用amdu工具從一個不能被掛載的DATA磁碟組中提取一個資料檔案,檔名字中包含NSA。這首先意味著在這裡sqlplus和asmcmd工具都不能使用。首先使用amdu工具對DATA磁碟組做一份後設資料的完整dump。

[grid@jyrac1 ~]$  amdu -dump DATADG -noimage
amdu_2017_01_05_16_09_47/
AMDU-00204: Disk N0003 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0003: '/dev/raw/raw11'
AMDU-00204: Disk N0009 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0009: '/dev/raw/raw4'
AMDU-00204: Disk N0008 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0008: '/dev/raw/raw3'

[grid@jyrac1 ~]$ cd amdu_2017_01_05_16_09_47/
[grid@jyrac1 amdu_2017_01_05_16_09_47]$ 

[grid@jyrac1 amdu_2017_01_05_16_09_47]$ ls -lrt
total 44
-rw-r--r-- 1 grid oinstall 16222 Jan  5 16:09 report.txt
-rw-r--r-- 1 grid oinstall 27520 Jan  5 16:09 DATADG.map

在本例中amdu建立了dump目錄併產生了兩個檔案。report.txt檔案包含主機、amdu命令及使用的引數、DATADG磁碟組可能的成員磁碟和這些磁碟上的AU資訊。report.txt檔案內容如下:

[grid@jyrac1 amdu_2017_01_05_16_09_47]$ more report.txt 
-*-amdu-*-

******************************* AMDU Settings ********************************
ORACLE_HOME = /u01/app/product/11.2.0/crs
System name:    Linux
Node name:      jyrac1
Release:        2.6.18-164.el5
Version:        #1 SMP Tue Aug 18 15:51:48 EDT 2009
Machine:        x86_64
amdu run:       05-JAN-17 16:09:47
Endianess:      1

--------------------------------- Operations ---------------------------------
       -dump DATADG

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

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

------------------------------- Output Control -------------------------------
    -noimage

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

----------------------------- DISK REPORT N0001 ------------------------------
                Disk Path: /dev/raw/raw1
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: CRSDG
                Disk Name: CRSDG_0000
       Failure Group Name: CRSDG_0000
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/11/22 18:24:35.358000
          Last Mount Time: 2016/12/14 17:02:09.327000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 1
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/11/22 18:24:35.079000
  File 1 Block 1 location: AU 2
              OCR Present: YES

----------------------------- DISK REPORT N0002 ------------------------------
                Disk Path: /dev/raw/raw10
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: DATADG
                Disk Name: DATADG_0000
       Failure Group Name: DATADG_0000
              Disk Number: 3
            Header Status: 3
       Disk Creation Time: 2016/12/12 15:36:39.090000
          Last Mount Time: 2017/01/03 11:54:18.454000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/12 15:36:38.488000
  File 1 Block 1 location: AU 0
              OCR Present: NO

----------------------------- DISK REPORT N0003 ------------------------------
                Disk Path: /dev/raw/raw11
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: DATADG
                Disk Name: DATADG_0001
       Failure Group Name: DATADG_0001
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/12/12 15:36:39.090000
          Last Mount Time: 2016/12/14 17:02:10.127000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/12 15:36:38.488000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0004 ------------------------------
                Disk Path: /dev/raw/raw12
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: USD
                Disk Name: USD_0001
       Failure Group Name: USD_0001
              Disk Number: 1
            Header Status: 3
       Disk Creation Time: 2016/12/30 14:58:59.434000
          Last Mount Time: 2017/01/03 09:57:50.397000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/30 14:58:59.213000
  File 1 Block 1 location: AU 1344
              OCR Present: NO

----------------------------- DISK REPORT N0005 ------------------------------
                Disk Path: /dev/raw/raw13
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: TESTDG
                Disk Name: TESTDG_0004
       Failure Group Name: TESTDG_0004
              Disk Number: 4
            Header Status: 4
       Disk Creation Time: 2016/12/28 16:04:46.242000
          Last Mount Time: 2016/12/28 16:04:57.102000
    Compatibility Version: 0x0a100000(10010000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/28 16:04:45.574000
  File 1 Block 1 location: AU 0
              OCR Present: NO

----------------------------- DISK REPORT N0006 ------------------------------
                Disk Path: /dev/raw/raw14
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: TESTDG
                Disk Name: TESTDG_0005
       Failure Group Name: TESTDG_0005
              Disk Number: 5
            Header Status: 4
       Disk Creation Time: 2016/12/28 16:04:46.242000
          Last Mount Time: 2016/12/28 16:04:57.102000
    Compatibility Version: 0x0a100000(10010000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/28 16:04:45.574000
  File 1 Block 1 location: AU 0
              OCR Present: NO

----------------------------- DISK REPORT N0007 ------------------------------
                Disk Path: /dev/raw/raw2
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: ARCHDG
                Disk Name: ARCHDG_0000
       Failure Group Name: ARCHDG_0000
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/11/22 19:18:27.892000
          Last Mount Time: 2016/12/14 17:02:08.754000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/11/22 19:18:27.619000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0008 ------------------------------
                Disk Path: /dev/raw/raw3
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: DATADG
                Disk Name: DATADG_0002
       Failure Group Name: DATADG_0002
              Disk Number: 2
            Header Status: 3
       Disk Creation Time: 2016/12/12 15:36:39.090000
          Last Mount Time: 2016/12/14 17:02:10.127000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/12 15:36:38.488000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0009 ------------------------------
                Disk Path: /dev/raw/raw4
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: DATADG
                Disk Name: DATADG_0003
       Failure Group Name: DATADG_0003
              Disk Number: 1
            Header Status: 3
       Disk Creation Time: 2016/12/12 15:36:39.090000
          Last Mount Time: 2016/12/14 17:02:10.127000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/12 15:36:38.488000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0010 ------------------------------
                Disk Path: /dev/raw/raw5
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: ACFS
                Disk Name: ACFS_0000
       Failure Group Name: ACFS_0000
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/12/30 09:09:30.242000
          Last Mount Time: 2016/12/30 09:09:41.395000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/30 09:09:29.830000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0011 ------------------------------
                Disk Path: /dev/raw/raw6
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: ACFS
                Disk Name: ACFS_0001
       Failure Group Name: ACFS_0001
              Disk Number: 1
            Header Status: 3
       Disk Creation Time: 2016/12/30 09:09:30.242000
          Last Mount Time: 2016/12/30 09:09:41.395000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/30 09:09:29.830000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0012 ------------------------------
                Disk Path: /dev/raw/raw7
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: USD
                Disk Name: USD_0000
       Failure Group Name: USD_0000
              Disk Number: 0
            Header Status: 3
       Disk Creation Time: 2016/12/30 14:58:59.434000
          Last Mount Time: 2016/12/30 14:59:10.816000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/12/30 14:58:59.213000
  File 1 Block 1 location: AU 2
              OCR Present: NO

----------------------------- DISK REPORT N0013 ------------------------------
                Disk Path: /dev/raw/raw8
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: CRSDG
                Disk Name: CRSDG_0001
       Failure Group Name: CRSDG_0001
              Disk Number: 1
            Header Status: 3
       Disk Creation Time: 2016/11/22 18:24:35.358000
          Last Mount Time: 2016/12/14 17:02:09.327000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 1
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/11/22 18:24:35.079000
  File 1 Block 1 location: AU 0
              OCR Present: NO

----------------------------- DISK REPORT N0014 ------------------------------
                Disk Path: /dev/raw/raw9
           Unique Disk ID: 
               Disk Label: 
     Physical Sector Size: 512 bytes
                Disk Size: 5120 megabytes
               Group Name: ARCHDG
                Disk Name: ARCHDG_0001
       Failure Group Name: ARCHDG_0001
              Disk Number: 1
            Header Status: 3
       Disk Creation Time: 2016/11/22 19:18:27.892000
          Last Mount Time: 2016/12/14 17:02:08.754000
    Compatibility Version: 0x0b200000(11020000)
         Disk Sector Size: 512 bytes
         Disk size in AUs: 5120 AUs
         Group Redundancy: 2
      Metadata Block Size: 4096 bytes
                  AU Size: 1048576 bytes
                   Stride: 113792 AUs
      Group Creation Time: 2016/11/22 19:18:27.619000
  File 1 Block 1 location: AU 2
              OCR Present: NO

***************** Slept for 6 seconds waiting for heartbeats *****************

************************* SCANNING DISKGROUP DATADG **************************
            Creation Time: 2016/12/12 15:36:38.488000
         Disks Discovered: 4
               Redundancy: 2
                  AU Size: 1048576 bytes
      Metadata Block Size: 4096 bytes
     Physical Sector Size: 512 bytes
          Metadata Stride: 113792 AU
   Duplicate Disk Numbers: 0


---------------------------- SCANNING DISK N0003 -----------------------------
Disk N0003: '/dev/raw/raw11'
AMDU-00204: Disk N0003 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0003: '/dev/raw/raw11'
** HEARTBEAT DETECTED **
           Allocated AU's: 1737
                Free AU's: 3383
       AU's read for dump: 83
       Block images saved: 19712
        Map lines written: 83
          Heartbeats seen: 1
  Corrupt metadata blocks: 0
        Corrupt AT blocks: 0


---------------------------- SCANNING DISK N0009 -----------------------------
Disk N0009: '/dev/raw/raw4'
AMDU-00204: Disk N0009 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0009: '/dev/raw/raw4'
** HEARTBEAT DETECTED **
           Allocated AU's: 1734
                Free AU's: 3386
       AU's read for dump: 85
       Block images saved: 20488
        Map lines written: 85
          Heartbeats seen: 1
  Corrupt metadata blocks: 0
        Corrupt AT blocks: 0


---------------------------- SCANNING DISK N0008 -----------------------------
Disk N0008: '/dev/raw/raw3'
AMDU-00204: Disk N0008 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0008: '/dev/raw/raw3'
** HEARTBEAT DETECTED **
           Allocated AU's: 1733
                Free AU's: 3387
       AU's read for dump: 89
       Block images saved: 21256
        Map lines written: 89
          Heartbeats seen: 1
  Corrupt metadata blocks: 0
        Corrupt AT blocks: 0


---------------------------- SCANNING DISK N0002 -----------------------------
Disk N0002: '/dev/raw/raw10'
           Allocated AU's: 1740
                Free AU's: 3380
       AU's read for dump: 87
       Block images saved: 20487
        Map lines written: 87
          Heartbeats seen: 0
  Corrupt metadata blocks: 0
        Corrupt AT blocks: 0


------------------------ SUMMARY FOR DISKGROUP DATADG ------------------------
           Allocated AU's: 6944
                Free AU's: 13536
       AU's read for dump: 344
       Block images saved: 81943
        Map lines written: 344
          Heartbeats seen: 3
  Corrupt metadata blocks: 0
        Corrupt AT blocks: 0


******************************* END OF REPORT ********************************


[grid@jyrac1 amdu_2017_01_05_16_09_47]$ more DATADG.map
...
N0008 D0002 R00 A00000069 F00000003 I0 E00000241 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000070 F00000003 I0 E00000244 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000071 F00000003 I0 E00000248 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000072 F00000003 I0 E00000249 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000073 F00000004 I0 E00000012 U00 C00000 S0000 B0000000000  
N0008 D0002 R00 A00000074 F00000004 I0 E00000017 U00 C00000 S0000 B0000000000  
N0008 D0002 R00 A00000075 F00000004 I0 E00000019 U00 C00000 S0000 B0000000000  
N0008 D0002 R00 A00000076 F00000004 I0 E00000022 U00 C00000 S0000 B0000000000  
N0008 D0002 R00 A00000077 F00000001 I0 E00000004 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000094 F00000257 I1 E00000002 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000111 F00000258 I1 E00000001 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000641 F00000259 I1 E00000000 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001022 F00000260 I1 E00000001 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001197 F00000261 I1 E00000002 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001272 F00000262 I1 E00000000 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001328 F00000264 I1 E00000000 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001356 F00000265 I1 E00000001 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001380 F00000266 I1 E00000000 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001453 F00000270 I1 E00000000 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00001707 F00000012 I0 E00000001 U00 C00256 S0000 B0000000000  
...

上面感覺有價值的內容是A和F起始的兩列。比如,A00000094代表本行是關於AU 94. F00000257代表本行與序號257的ASM檔案相關。重新回到查詢NSA資料檔案的目標。ASM序號6的後設資料檔案是alias別名目錄,這是查詢目標的起點。透過DATADG.map檔案,能找到序號6的ASM後設資料檔案的所有AU。

[grid@jyrac1 amdu_2017_01_05_16_09_47]$  grep F00000006 DATADG.map
N0009 D0001 R00 A00000036 F00000006 I0 E00000002 U00 C00256 S0000 B0000000000  
N0008 D0002 R00 A00000038 F00000006 I0 E00000000 U00 C00256 S0000 B0000000000  
N0002 D0003 R00 A00000037 F00000006 I0 E00000001 U00 C00256 S0000 B0000000000  

透過查詢定位到與該後設資料檔案相關的AU記錄有三行。同時別名目錄後設資料檔案存放在磁碟1(D0001)的AU 36(A00000036),磁碟2(D0002)的AU 38(A00000038)和磁碟3(D0003)的AU 37(A00000037)。 從前面report.txt的記錄中知道,磁碟1指的是'/dev/raw/raw4'並且它的AU大小是1MB。透過kfed工具來檢視alias目錄檔案。

[grid@jyrac1 amdu_2017_01_05_16_09_47]$ kfed read /dev/raw/raw4 aun=36 | more
kfbh.endian:                          1 ; 0x000: 0x01
kfbh.hard:                          130 ; 0x001: 0x82
kfbh.type:                           11 ; 0x002: KFBTYP_ALIASDIR
kfbh.datfmt:                          1 ; 0x003: 0x01
kfbh.block.blk:                       0 ; 0x004: blk=0
kfbh.block.obj:                       6 ; 0x008: file=6
kfbh.check:                  2235498606 ; 0x00c: 0x853f006e
kfbh.fcn.base:                     3565 ; 0x010: 0x00000ded
kfbh.fcn.wrap:                        0 ; 0x014: 0x00000000
kfbh.spare1:                          0 ; 0x018: 0x00000000
kfbh.spare2:                          0 ; 0x01c: 0x00000000
kffdnd.bnode.incarn:                  1 ; 0x000: A=1 NUMM=0x0
kffdnd.bnode.frlist.number:  4294967295 ; 0x004: 0xffffffff
kffdnd.bnode.frlist.incarn:           0 ; 0x008: A=0 NUMM=0x0
kffdnd.overfl.number:        4294967295 ; 0x00c: 0xffffffff
kffdnd.overfl.incarn:                 0 ; 0x010: A=0 NUMM=0x0
kffdnd.parent.number:                 0 ; 0x014: 0x00000000
kffdnd.parent.incarn:                 1 ; 0x018: A=1 NUMM=0x0
kffdnd.fstblk.number:                 0 ; 0x01c: 0x00000000
kffdnd.fstblk.incarn:                 1 ; 0x020: A=1 NUMM=0x0
kfade[0].entry.incarn:                1 ; 0x024: A=1 NUMM=0x0
kfade[0].entry.hash:         2990280982 ; 0x028: 0xb23c1116
kfade[0].entry.refer.number:          1 ; 0x02c: 0x00000001
kfade[0].entry.refer.incarn:          1 ; 0x030: A=1 NUMM=0x0
kfade[0].name:                    JYRAC ; 0x034: length=5
kfade[0].fnum:               4294967295 ; 0x064: 0xffffffff
kfade[0].finc:               4294967295 ; 0x068: 0xffffffff
kfade[0].flags:                       8 ; 0x06c: U=0 S=0 S=0 U=1 F=0
kfade[0].ub1spare:                    0 ; 0x06d: 0x00
kfade[0].ub2spare:                    0 ; 0x06e: 0x0000
kfade[1].entry.incarn:                1 ; 0x070: A=1 NUMM=0x0
kfade[1].entry.hash:         3585957073 ; 0x074: 0xd5bd5cd1
kfade[1].entry.refer.number:          9 ; 0x078: 0x00000009
kfade[1].entry.refer.incarn:          1 ; 0x07c: A=1 NUMM=0x0
kfade[1].name:               DB_UNKNOWN ; 0x080: length=10
kfade[1].fnum:               4294967295 ; 0x0b0: 0xffffffff
kfade[1].finc:               4294967295 ; 0x0b4: 0xffffffff
kfade[1].flags:                       4 ; 0x0b8: U=0 S=0 S=1 U=0 F=0
kfade[1].ub1spare:                    0 ; 0x0b9: 0x00
kfade[1].ub2spare:                    0 ; 0x0ba: 0x0000
kfade[2].entry.incarn:                3 ; 0x0bc: A=1 NUMM=0x1
kfade[2].entry.hash:         1585230659 ; 0x0c0: 0x5e7cb343
kfade[2].entry.refer.number: 4294967295 ; 0x0c4: 0xffffffff
kfade[2].entry.refer.incarn:          0 ; 0x0c8: A=0 NUMM=0x0
...

kfed的輸出資訊中kfbh.type驗證了這是一個alias目錄檔案。下一步查詢名字包含SYS的資料檔案

[grid@jyrac1 amdu_2017_01_05_16_09_47]$ vi getfilename.sh

for (( i=0; i<256; i++ ))
do
kfed read /dev/raw/raw4 aun=36 blkn=$i | grep -1 SYS
done

[grid@jyrac1 amdu_2017_01_05_16_09_47]$ chmod 777 getfilename.sh 
[grid@jyrac1 amdu_2017_01_05_16_09_47]$ ./getfilename.sh 
kfade[0].entry.refer.incarn:          0 ; 0x030: A=0 NUMM=0x0
kfade[0].name:                   SYSAUX ; 0x034: length=6
kfade[0].fnum:                      258 ; 0x064: 0x00000102
--
kfade[1].entry.refer.incarn:          0 ; 0x07c: A=0 NUMM=0x0
kfade[1].name:                   SYSTEM ; 0x080: length=6
kfade[1].fnum:                      259 ; 0x0b0: 0x00000103

名字包含SYS的資料檔案是SYSTEM,SYSAUX,它們的ASM檔案序號是258,259.接下來可以進一步提取資料檔案

[grid@jyrac1 amdu_2017_01_05_16_09_47]$ amdu -diskstring="/dev/raw/*" -extract DATADG.258 -output SYSAUX.258 -noreport -nodir
AMDU-00204: Disk N0003 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0003: '/dev/raw/raw11'
AMDU-00204: Disk N0009 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0009: '/dev/raw/raw4'
AMDU-00204: Disk N0008 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0008: '/dev/raw/raw3'
[grid@jyrac1 amdu_2017_01_05_16_09_47]$ amdu -diskstring="/dev/raw/*" -extract DATADG.259 -output SYSTEM.259 -noreport -nodir
AMDU-00204: Disk N0003 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0003: '/dev/raw/raw11'
AMDU-00204: Disk N0009 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0009: '/dev/raw/raw4'
AMDU-00204: Disk N0008 is in currently mounted diskgroup DATADG
AMDU-00201: Disk N0008: '/dev/raw/raw3'
[grid@jyrac1 amdu_2017_01_05_16_09_47]$ ls -lrt SYS*
-rw-r--r-- 1 grid oinstall 1625300992 Jan  5 16:44 SYSAUX.258
-rw-r--r-- 1 grid oinstall  796925952 Jan  5 16:46 SYSTEM.259

提取其它資料檔案的操作與提取system,sysaux資料檔案類似,如果能提取到資料庫控制檔案,system和sysaux系統表空間及其它資料檔案,就可以用這些檔案來開啟資料庫。還可能把這個檔案“遷移”到別的資料庫。需要注意是amdu提取的可能是有損壞或者是已破壞的檔案,這取決於檔案本身是否有損壞。對於那些由於元資訊損壞或者丟失兒導致的不能唄mount的磁碟組,也有可能資料檔案是好的,這樣情況下同樣可以使用amdu來抽取到完好的資料檔案。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2131969/,如需轉載,請註明出處,否則將追究法律責任。

相關文章