ASM未正常启动,使用dd找回数据文件

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:ASM未正常启动,使用dd找回数据文件

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

本篇主要测试在ASM未启动状态下,如何找出找出文件文件对应的AU,并且通过dd还原出数据文件
参考文档:ASM的文件管理深入解析(内含开源的ASM文件挖掘研究版程序)
模拟测试数据

SQL> alter database datafile '+XIFENFEI/xff/datafile/xifenfei.268.781905429' resize 50M ;
Database altered.
SQL> alter database datafile '+XIFENFEI/xff/datafile/xifenfei.268.781905429' autoextend off;
Database altered.
SQL> select GROUP_NUMBER from V$ASM_DISKGROUP where NAME like '%XIFENFEI%';
GROUP_NUMBER
------------
           2
SQL> select DISK_NUMBER,path from v$asm_disk where GROUP_NUMBER=2;
DISK_NUMBER PATH
----------- ---------------------------------------------
          1 /dev/oracleasm/disks/VOL4
          0 /dev/oracleasm/disks/VOL3
SQL> create table t_xifenfei tablespace xifenfei
  2  as
  3  select  * from dba_objects;
Table created.
SQL> select count(*)  from t_xifenfei;
  COUNT(*)
----------
     74537

kfed找出相关AU映射

------------------------------------------------------------------------------
1号文件的第一个AU(0号盘2号AU)中,只能保存1至255号文件的。
从256号文件开始,AU的分布信息保存在1号文件第二个AU中,也就是(1号盘,64号AU)。
其中第一个块(0号块),对应256号文件。1号块对应257号文件,等等,依此类推。
------------------------------------------------------------------------------
[grid@rac1 disks]$  kfed read /dev/oracleasm/disks/VOL3 aun=2 blkn=1|more
kfffde[0].xptr.au:                    2 ; 0x4a0: 0x00000002
kfffde[0].xptr.disk:                  0 ; 0x4a4: 0x0000
kfffde[0].xptr.flags:                 0 ; 0x4a6: L=0 E=0 D=0 S=0
kfffde[0].xptr.chk:                  40 ; 0x4a7: 0x28
kfffde[1].xptr.au:                   64 ; 0x4a8: 0x00000040
kfffde[1].xptr.disk:                  1 ; 0x4ac: 0x0001
kfffde[1].xptr.flags:                 0 ; 0x4ae: L=0 E=0 D=0 S=0
kfffde[1].xptr.chk:                 107 ; 0x4af: 0x6b
kfffde[2].xptr.au:           4294967295 ; 0x4b0: 0xffffffff
kfffde[2].xptr.disk:              65535 ; 0x4b4: 0xffff
kfffde[2].xptr.flags:                 0 ; 0x4b6: L=0 E=0 D=0 S=0
kfffde[2].xptr.chk:                  42 ; 0x4b7: 0x2a
[grid@rac1 disks]$  kfed read /dev/oracleasm/disks/VOL4 aun=64 blkn=12|more
kfffde[0].xptr.au:                  681 ; 0x4a0: 0x000002a9
kfffde[0].xptr.disk:                  0 ; 0x4a4: 0x0000
kfffde[0].xptr.flags:                 0 ; 0x4a6: L=0 E=0 D=0 S=0
kfffde[0].xptr.chk:                 129 ; 0x4a7: 0x81
kfffde[1].xptr.au:                 1092 ; 0x4a8: 0x00000444
kfffde[1].xptr.disk:                  1 ; 0x4ac: 0x0001
kfffde[1].xptr.flags:                 0 ; 0x4ae: L=0 E=0 D=0 S=0
kfffde[1].xptr.chk:                 107 ; 0x4af: 0x6b
kfffde[2].xptr.au:                 1093 ; 0x4b0: 0x00000445
kfffde[2].xptr.disk:                  1 ; 0x4b4: 0x0001
kfffde[2].xptr.flags:                 0 ; 0x4b6: L=0 E=0 D=0 S=0
kfffde[2].xptr.chk:                 106 ; 0x4b7: 0x6a
kfffde[3].xptr.au:                  682 ; 0x4b8: 0x000002aa
kfffde[3].xptr.disk:                  0 ; 0x4bc: 0x0000
kfffde[3].xptr.flags:                 0 ; 0x4be: L=0 E=0 D=0 S=0
kfffde[3].xptr.chk:                 130 ; 0x4bf: 0x82
kfffde[4].xptr.au:                 1094 ; 0x4c0: 0x00000446
kfffde[4].xptr.disk:                  1 ; 0x4c4: 0x0001
kfffde[4].xptr.flags:                 0 ; 0x4c6: L=0 E=0 D=0 S=0
kfffde[4].xptr.chk:                 105 ; 0x4c7: 0x69
kfffde[5].xptr.au:                 1095 ; 0x4c8: 0x00000447
kfffde[5].xptr.disk:                  1 ; 0x4cc: 0x0001
kfffde[5].xptr.flags:                 0 ; 0x4ce: L=0 E=0 D=0 S=0
kfffde[5].xptr.chk:                 104 ; 0x4cf: 0x68
kfffde[6].xptr.au:                  683 ; 0x4d0: 0x000002ab
kfffde[6].xptr.disk:                  0 ; 0x4d4: 0x0000
kfffde[6].xptr.flags:                 0 ; 0x4d6: L=0 E=0 D=0 S=0
kfffde[6].xptr.chk:                 131 ; 0x4d7: 0x83
kfffde[7].xptr.au:                 1096 ; 0x4d8: 0x00000448
kfffde[7].xptr.disk:                  1 ; 0x4dc: 0x0001
kfffde[7].xptr.flags:                 0 ; 0x4de: L=0 E=0 D=0 S=0
kfffde[7].xptr.chk:                 103 ; 0x4df: 0x67
kfffde[8].xptr.au:                  684 ; 0x4e0: 0x000002ac
kfffde[8].xptr.disk:                  0 ; 0x4e4: 0x0000
kfffde[8].xptr.flags:                 0 ; 0x4e6: L=0 E=0 D=0 S=0
kfffde[8].xptr.chk:                 132 ; 0x4e7: 0x84
kfffde[9].xptr.au:                 1097 ; 0x4e8: 0x00000449
kfffde[9].xptr.disk:                  1 ; 0x4ec: 0x0001
kfffde[9].xptr.flags:                 0 ; 0x4ee: L=0 E=0 D=0 S=0
kfffde[9].xptr.chk:                 102 ; 0x4ef: 0x66
kfffde[10].xptr.au:                1098 ; 0x4f0: 0x0000044a
kfffde[10].xptr.disk:                 1 ; 0x4f4: 0x0001
kfffde[10].xptr.flags:                0 ; 0x4f6: L=0 E=0 D=0 S=0
kfffde[10].xptr.chk:                101 ; 0x4f7: 0x65
kfffde[11].xptr.au:                 685 ; 0x4f8: 0x000002ad
kfffde[11].xptr.disk:                 0 ; 0x4fc: 0x0000
kfffde[11].xptr.flags:                0 ; 0x4fe: L=0 E=0 D=0 S=0
kfffde[11].xptr.chk:                133 ; 0x4ff: 0x85
kfffde[12].xptr.au:                1099 ; 0x500: 0x0000044b
kfffde[12].xptr.disk:                 1 ; 0x504: 0x0001
kfffde[12].xptr.flags:                0 ; 0x506: L=0 E=0 D=0 S=0
kfffde[12].xptr.chk:                100 ; 0x507: 0x64
kfffde[13].xptr.au:                 686 ; 0x508: 0x000002ae
kfffde[13].xptr.disk:                 0 ; 0x50c: 0x0000
kfffde[13].xptr.flags:                0 ; 0x50e: L=0 E=0 D=0 S=0
kfffde[13].xptr.chk:                134 ; 0x50f: 0x86
kfffde[14].xptr.au:                1100 ; 0x510: 0x0000044c
kfffde[14].xptr.disk:                 1 ; 0x514: 0x0001
kfffde[14].xptr.flags:                0 ; 0x516: L=0 E=0 D=0 S=0
kfffde[14].xptr.chk:                 99 ; 0x517: 0x63
kfffde[15].xptr.au:                1101 ; 0x518: 0x0000044d
kfffde[15].xptr.disk:                 1 ; 0x51c: 0x0001
kfffde[15].xptr.flags:                0 ; 0x51e: L=0 E=0 D=0 S=0
kfffde[15].xptr.chk:                 98 ; 0x51f: 0x62
kfffde[16].xptr.au:                 687 ; 0x520: 0x000002af
kfffde[16].xptr.disk:                 0 ; 0x524: 0x0000
kfffde[16].xptr.flags:                0 ; 0x526: L=0 E=0 D=0 S=0
kfffde[16].xptr.chk:                135 ; 0x527: 0x87
kfffde[17].xptr.au:                1102 ; 0x528: 0x0000044e
kfffde[17].xptr.disk:                 1 ; 0x52c: 0x0001
kfffde[17].xptr.flags:                0 ; 0x52e: L=0 E=0 D=0 S=0
kfffde[17].xptr.chk:                 97 ; 0x52f: 0x61
kfffde[18].xptr.au:                1103 ; 0x530: 0x0000044f
kfffde[18].xptr.disk:                 1 ; 0x534: 0x0001
kfffde[18].xptr.flags:                0 ; 0x536: L=0 E=0 D=0 S=0
kfffde[18].xptr.chk:                 96 ; 0x537: 0x60
kfffde[19].xptr.au:                 688 ; 0x538: 0x000002b0
kfffde[19].xptr.disk:                 0 ; 0x53c: 0x0000
kfffde[19].xptr.flags:                0 ; 0x53e: L=0 E=0 D=0 S=0
kfffde[19].xptr.chk:                152 ; 0x53f: 0x98
kfffde[20].xptr.au:                1104 ; 0x540: 0x00000450
kfffde[20].xptr.disk:                 1 ; 0x544: 0x0001
kfffde[20].xptr.flags:                0 ; 0x546: L=0 E=0 D=0 S=0
kfffde[20].xptr.chk:                127 ; 0x547: 0x7f
kfffde[21].xptr.au:                 689 ; 0x548: 0x000002b1
kfffde[21].xptr.disk:                 0 ; 0x54c: 0x0000
kfffde[21].xptr.flags:                0 ; 0x54e: L=0 E=0 D=0 S=0
kfffde[21].xptr.chk:                153 ; 0x54f: 0x99
kfffde[22].xptr.au:                1105 ; 0x550: 0x00000451
kfffde[22].xptr.disk:                 1 ; 0x554: 0x0001
kfffde[22].xptr.flags:                0 ; 0x556: L=0 E=0 D=0 S=0
kfffde[22].xptr.chk:                126 ; 0x557: 0x7e
kfffde[23].xptr.au:                1106 ; 0x558: 0x00000452
kfffde[23].xptr.disk:                 1 ; 0x55c: 0x0001
kfffde[23].xptr.flags:                0 ; 0x55e: L=0 E=0 D=0 S=0
kfffde[23].xptr.chk:                125 ; 0x55f: 0x7d
kfffde[24].xptr.au:                 690 ; 0x560: 0x000002b2
kfffde[24].xptr.disk:                 0 ; 0x564: 0x0000
kfffde[24].xptr.flags:                0 ; 0x566: L=0 E=0 D=0 S=0
kfffde[24].xptr.chk:                154 ; 0x567: 0x9a
kfffde[25].xptr.au:                1107 ; 0x568: 0x00000453
kfffde[25].xptr.disk:                 1 ; 0x56c: 0x0001
kfffde[25].xptr.flags:                0 ; 0x56e: L=0 E=0 D=0 S=0
kfffde[25].xptr.chk:                124 ; 0x56f: 0x7c
kfffde[26].xptr.au:                 691 ; 0x570: 0x000002b3
kfffde[26].xptr.disk:                 0 ; 0x574: 0x0000
kfffde[26].xptr.flags:                0 ; 0x576: L=0 E=0 D=0 S=0
kfffde[26].xptr.chk:                155 ; 0x577: 0x9b
kfffde[27].xptr.au:                1108 ; 0x578: 0x00000454
kfffde[27].xptr.disk:                 1 ; 0x57c: 0x0001
kfffde[27].xptr.flags:                0 ; 0x57e: L=0 E=0 D=0 S=0
kfffde[27].xptr.chk:                123 ; 0x57f: 0x7b
kfffde[28].xptr.au:                1109 ; 0x580: 0x00000455
kfffde[28].xptr.disk:                 1 ; 0x584: 0x0001
kfffde[28].xptr.flags:                0 ; 0x586: L=0 E=0 D=0 S=0
kfffde[28].xptr.chk:                122 ; 0x587: 0x7a
kfffde[29].xptr.au:                 692 ; 0x588: 0x000002b4
kfffde[29].xptr.disk:                 0 ; 0x58c: 0x0000
kfffde[29].xptr.flags:                0 ; 0x58e: L=0 E=0 D=0 S=0
kfffde[29].xptr.chk:                156 ; 0x58f: 0x9c
kfffde[30].xptr.au:                1110 ; 0x590: 0x00000456
kfffde[30].xptr.disk:                 1 ; 0x594: 0x0001
kfffde[30].xptr.flags:                0 ; 0x596: L=0 E=0 D=0 S=0
kfffde[30].xptr.chk:                121 ; 0x597: 0x79
kfffde[31].xptr.au:                1111 ; 0x598: 0x00000457
kfffde[31].xptr.disk:                 1 ; 0x59c: 0x0001
kfffde[31].xptr.flags:                0 ; 0x59e: L=0 E=0 D=0 S=0
kfffde[31].xptr.chk:                120 ; 0x59f: 0x78
kfffde[32].xptr.au:                 693 ; 0x5a0: 0x000002b5
kfffde[32].xptr.disk:                 0 ; 0x5a4: 0x0000
kfffde[32].xptr.flags:                0 ; 0x5a6: L=0 E=0 D=0 S=0
kfffde[32].xptr.chk:                157 ; 0x5a7: 0x9d
kfffde[33].xptr.au:                1112 ; 0x5a8: 0x00000458
kfffde[33].xptr.disk:                 1 ; 0x5ac: 0x0001
kfffde[33].xptr.flags:                0 ; 0x5ae: L=0 E=0 D=0 S=0
kfffde[33].xptr.chk:                119 ; 0x5af: 0x77
kfffde[34].xptr.au:                 694 ; 0x5b0: 0x000002b6
kfffde[34].xptr.disk:                 0 ; 0x5b4: 0x0000
kfffde[34].xptr.flags:                0 ; 0x5b6: L=0 E=0 D=0 S=0
kfffde[34].xptr.chk:                158 ; 0x5b7: 0x9e
kfffde[35].xptr.au:                1113 ; 0x5b8: 0x00000459
kfffde[35].xptr.disk:                 1 ; 0x5bc: 0x0001
kfffde[35].xptr.flags:                0 ; 0x5be: L=0 E=0 D=0 S=0
kfffde[35].xptr.chk:                118 ; 0x5bf: 0x76
kfffde[36].xptr.au:                1114 ; 0x5c0: 0x0000045a
kfffde[36].xptr.disk:                 1 ; 0x5c4: 0x0001
kfffde[36].xptr.flags:                0 ; 0x5c6: L=0 E=0 D=0 S=0
kfffde[36].xptr.chk:                117 ; 0x5c7: 0x75
kfffde[37].xptr.au:                 695 ; 0x5c8: 0x000002b7
kfffde[37].xptr.disk:                 0 ; 0x5cc: 0x0000
kfffde[37].xptr.flags:                0 ; 0x5ce: L=0 E=0 D=0 S=0
kfffde[37].xptr.chk:                159 ; 0x5cf: 0x9f
kfffde[38].xptr.au:                1115 ; 0x5d0: 0x0000045b
kfffde[38].xptr.disk:                 1 ; 0x5d4: 0x0001
kfffde[38].xptr.flags:                0 ; 0x5d6: L=0 E=0 D=0 S=0
kfffde[38].xptr.chk:                116 ; 0x5d7: 0x74
kfffde[39].xptr.au:                1116 ; 0x5d8: 0x0000045c
kfffde[39].xptr.disk:                 1 ; 0x5dc: 0x0001
kfffde[39].xptr.flags:                0 ; 0x5de: L=0 E=0 D=0 S=0
kfffde[39].xptr.chk:                115 ; 0x5df: 0x73
kfffde[40].xptr.au:                 696 ; 0x5e0: 0x000002b8
kfffde[40].xptr.disk:                 0 ; 0x5e4: 0x0000
kfffde[40].xptr.flags:                0 ; 0x5e6: L=0 E=0 D=0 S=0
kfffde[40].xptr.chk:                144 ; 0x5e7: 0x90
kfffde[41].xptr.au:                1117 ; 0x5e8: 0x0000045d
kfffde[41].xptr.disk:                 1 ; 0x5ec: 0x0001
kfffde[41].xptr.flags:                0 ; 0x5ee: L=0 E=0 D=0 S=0
kfffde[41].xptr.chk:                114 ; 0x5ef: 0x72
kfffde[42].xptr.au:                 697 ; 0x5f0: 0x000002b9
kfffde[42].xptr.disk:                 0 ; 0x5f4: 0x0000
kfffde[42].xptr.flags:                0 ; 0x5f6: L=0 E=0 D=0 S=0
kfffde[42].xptr.chk:                145 ; 0x5f7: 0x91
kfffde[43].xptr.au:                1118 ; 0x5f8: 0x0000045e
kfffde[43].xptr.disk:                 1 ; 0x5fc: 0x0001
kfffde[43].xptr.flags:                0 ; 0x5fe: L=0 E=0 D=0 S=0
kfffde[43].xptr.chk:                113 ; 0x5ff: 0x71
kfffde[44].xptr.au:                1119 ; 0x600: 0x0000045f
kfffde[44].xptr.disk:                 1 ; 0x604: 0x0001
kfffde[44].xptr.flags:                0 ; 0x606: L=0 E=0 D=0 S=0
kfffde[44].xptr.chk:                112 ; 0x607: 0x70
kfffde[45].xptr.au:                 698 ; 0x608: 0x000002ba
kfffde[45].xptr.disk:                 0 ; 0x60c: 0x0000
kfffde[45].xptr.flags:                0 ; 0x60e: L=0 E=0 D=0 S=0
kfffde[45].xptr.chk:                146 ; 0x60f: 0x92
kfffde[46].xptr.au:                1120 ; 0x610: 0x00000460
kfffde[46].xptr.disk:                 1 ; 0x614: 0x0001
kfffde[46].xptr.flags:                0 ; 0x616: L=0 E=0 D=0 S=0
kfffde[46].xptr.chk:                 79 ; 0x617: 0x4f
kfffde[47].xptr.au:                 699 ; 0x618: 0x000002bb
kfffde[47].xptr.disk:                 0 ; 0x61c: 0x0000
kfffde[47].xptr.flags:                0 ; 0x61e: L=0 E=0 D=0 S=0
kfffde[47].xptr.chk:                147 ; 0x61f: 0x93
kfffde[48].xptr.au:                1121 ; 0x620: 0x00000461
kfffde[48].xptr.disk:                 1 ; 0x624: 0x0001
kfffde[48].xptr.flags:                0 ; 0x626: L=0 E=0 D=0 S=0
kfffde[48].xptr.chk:                 78 ; 0x627: 0x4e
kfffde[49].xptr.au:                1122 ; 0x628: 0x00000462
kfffde[49].xptr.disk:                 1 ; 0x62c: 0x0001
kfffde[49].xptr.flags:                0 ; 0x62e: L=0 E=0 D=0 S=0
kfffde[49].xptr.chk:                 77 ; 0x62f: 0x4d
kfffde[50].xptr.au:                 700 ; 0x630: 0x000002bc
kfffde[50].xptr.disk:                 0 ; 0x634: 0x0000
kfffde[50].xptr.flags:                0 ; 0x636: L=0 E=0 D=0 S=0
kfffde[50].xptr.chk:                148 ; 0x637: 0x94
--到此截止
kfffde[51].xptr.au:          4294967295 ; 0x638: 0xffffffff
kfffde[51].xptr.disk:             65535 ; 0x63c: 0xffff
kfffde[51].xptr.flags:                0 ; 0x63e: L=0 E=0 D=0 S=0
kfffde[51].xptr.chk:                 42 ; 0x63f: 0x2a

dd操作

[grid@rac1 disks]$ dd if=/dev/oracleasm/disks/VOL3 bs=1024k count=1 skip=681 seek=0 of=/tmp/xifenfei01.dbf
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0924808 seconds, 11.3 MB/s
[grid@rac1 disks]$ dd if=/dev/oracleasm/disks/VOL4 bs=1024k count=1 skip=1092 seek=1 of=/tmp/xifenfei01.dbf
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.051765 seconds, 20.3 MB/s
[grid@rac1 disks]$ dd if=/dev/oracleasm/disks/VOL4 bs=1024k count=1 skip=1093 seek=2 of=/tmp/xifenfei01.dbf
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0695681 seconds, 15.1 MB/s
[grid@rac1 disks]$ dd if=/dev/oracleasm/disks/VOL3 bs=1024k count=1 skip=682 seek=3 of=/tmp/xifenfei01.dbf
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0516708 seconds, 20.3 MB/s
…………类此处理…………
[grid@rac1 disks]$ dd if=/dev/oracleasm/disks/VOL4 bs=1024k count=1 skip=1122 seek=49 of=/tmp/xifenfei01.dbf
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0699421 seconds, 15.0 MB/s
[grid@rac1 disks]$ dd if=/dev/oracleasm/disks/VOL3 bs=1024k count=1 skip=700 seek=50 of=/tmp/xifenfei01.dbf
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0650649 seconds, 16.1 MB/s

修改所有者

[root@rac1 ~]#  chown oracle.oinstall /tmp/xifenfei01.dbf
[root@rac1 ~]# ll /tmp/xifenfei01.dbf
-rw-r--r-- 1 oracle oinstall 53477376 Apr 30 12:57 /tmp/xifenfei01.dbf

dbv验证数据文件

[oracle@rac1 ~]$ dbv file='+XIFENFEI/xff/datafile/xifenfei.268.781905429' userid=sys/xifenfei
DBVERIFY: Release 11.2.0.3.0 - Production on Mon Apr 30 12:53:32 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
DBVERIFY - Verification starting : FILE = +XIFENFEI/xff/datafile/xifenfei.268.781905429
DBVERIFY - Verification complete
Total Pages Examined         : 6400
Total Pages Processed (Data) : 1066
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 156
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 5178
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 0 (0.0)
[oracle@rac1 ~]$ dbv file='/tmp/xifenfei01.dbf'
DBVERIFY: Release 11.2.0.3.0 - Production on Mon Apr 30 12:53:50 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
DBVERIFY - Verification starting : FILE = /tmp/xifenfei01.dbf
DBVERIFY - Verification complete
Total Pages Examined         : 6400
Total Pages Processed (Data) : 1066
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 156
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 5178
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1039267 (0.1039267)

数据库验证数据文件

SQL> alter database datafile '+XIFENFEI/xff/datafile/xifenfei.268.781905429' offline;
Database altered.
SQL> alter database rename file '+XIFENFEI/xff/datafile/xifenfei.268.781905429'
  2  to '/tmp/xifenfei01.dbf';
Database altered.
SQL>  recover datafile '/tmp/xifenfei01.dbf';
Media recovery complete.
SQL> alter database datafile '/tmp/xifenfei01.dbf' online;
Database altered.
SQL> select count(*) from t_xifenfei;
  COUNT(*)
----------
     74537

One thought on “ASM未正常启动,使用dd找回数据文件

  1. 通过查询x$kffxp表,可以得到数据文件和AU在磁盘上的映射关系

    SQL> SELECT disk_kffxp, au_kffxp, xnum_kffxp
      2   FROM x$kffxp
      3     WHERE GROUP_KFFXP=2
      4    AND NUMBER_KFFXP=268;
    DISK_KFFXP   AU_KFFXP XNUM_KFFXP
    ---------- ---------- ----------
             0        681          0
             1       1092          1
             1       1093          2
             0        682          3
             1       1094          4
             1       1095          5
             0        683          6
             1       1096          7
             0        684          8
             1       1097          9
             1       1098         10
             0        685         11
             1       1099         12
             0        686         13
             1       1100         14
             1       1101         15
             0        687         16
             1       1102         17
             1       1103         18
             0        688         19
             1       1104         20
             0        689         21
             1       1105         22
             1       1106         23
             0        690         24
             1       1107         25
             0        691         26
             1       1108         27
             1       1109         28
             0        692         29
             1       1110         30
             1       1111         31
             0        693         32
             1       1112         33
             0        694         34
             1       1113         35
             1       1114         36
             0        695         37
             1       1115         38
             1       1116         39
             0        696         40
             1       1117         41
             0        697         42
             1       1118         43
             1       1119         44
             0        698         45
             1       1120         46
             0        699         47
             1       1121         48
             1       1122         49
             0        700         50
    
  2. 模拟ASM中数据文件大于60M

    SQL> select name from v$datafile where file#=6;
    NAME
    --------------------------------------------------------------------------------
    +XIFENFEI/asm/datafile/xifenfei01.dbf.268.781967893
    SQL> alter database datafile 6 resize 150M;
    Database altered.
    

    kfed查看相关数据

    [grid@rac1 disks]$  kfed read /dev/oracleasm/disks/VOL3 aun=2 blkn=1|more
    kfffde[0].xptr.au:                    2 ; 0x4a0: 0x00000002
    kfffde[0].xptr.disk:                  0 ; 0x4a4: 0x0000
    kfffde[0].xptr.flags:                 0 ; 0x4a6: L=0 E=0 D=0 S=0
    kfffde[0].xptr.chk:                  40 ; 0x4a7: 0x28
    kfffde[1].xptr.au:                   64 ; 0x4a8: 0x00000040
    kfffde[1].xptr.disk:                  1 ; 0x4ac: 0x0001
    kfffde[1].xptr.flags:                 0 ; 0x4ae: L=0 E=0 D=0 S=0
    kfffde[1].xptr.chk:                 107 ; 0x4af: 0x6b
    kfffde[2].xptr.au:           4294967295 ; 0x4b0: 0xffffffff
    kfffde[2].xptr.disk:              65535 ; 0x4b4: 0xffff
    kfffde[2].xptr.flags:                 0 ; 0x4b6: L=0 E=0 D=0 S=0
    kfffde[2].xptr.chk:                  42 ; 0x4b7: 0x2a
    [grid@rac1 disks]$  kfed read /dev/oracleasm/disks/VOL4 aun=64 blkn=12|more
    kfffde[0].xptr.au:                  681 ; 0x4a0: 0x000002a9
    kfffde[0].xptr.disk:                  0 ; 0x4a4: 0x0000
    kfffde[0].xptr.flags:                 0 ; 0x4a6: L=0 E=0 D=0 S=0
    kfffde[0].xptr.chk:                 129 ; 0x4a7: 0x81
    …………省略…………
    kfffde[58].xptr.au:                 703 ; 0x670: 0x000002bf
    kfffde[58].xptr.disk:                 0 ; 0x674: 0x0000
    kfffde[58].xptr.flags:                0 ; 0x676: L=0 E=0 D=0 S=0
    kfffde[58].xptr.chk:                151 ; 0x677: 0x97
    kfffde[59].xptr.au:                1128 ; 0x678: 0x00000468
    kfffde[59].xptr.disk:                 1 ; 0x67c: 0x0001
    kfffde[59].xptr.flags:                0 ; 0x67e: L=0 E=0 D=0 S=0
    kfffde[59].xptr.chk:                 71 ; 0x67f: 0x47
    kfffde[60].xptr.au:                1129 ; 0x680: 0x00000469
    kfffde[60].xptr.disk:                 1 ; 0x684: 0x0001
    kfffde[60].xptr.flags:                0 ; 0x686: L=0 E=0 D=0 S=0
    kfffde[60].xptr.chk:                 70 ; 0x687: 0x46
    kfffde[61].xptr.au:          4294967295 ; 0x688: 0xffffffff
    kfffde[61].xptr.disk:             65535 ; 0x68c: 0xffff
    kfffde[61].xptr.flags:                0 ; 0x68e: L=0 E=0 D=0 S=0
    kfffde[61].xptr.chk:                 42 ; 0x68f: 0x2a
    [grid@rac1 disks]$  kfed read /dev/oracleasm/disks/VOL4 aun=1129 blkn=0|more
    kfbh.endian:                          1 ; 0x000: 0x01
    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:                     268 ; 0x008: file=268  <<--数据文件号
    kfbh.check:                  2682425127 ; 0x00c: 0x9fe28f27
    kfbh.fcn.base:                     3758 ; 0x010: 0x00000eae
    kfbh.fcn.wrap:                        0 ; 0x014: 0x00000000
    kfbh.spare1:                          0 ; 0x018: 0x00000000
    kfbh.spare2:                          0 ; 0x01c: 0x00000000
    kffixb.dxsn:                         60 ; 0x000: 0x0000003c
    kffixb.xtntblk:                      91 ; 0x004: 0x005b
    kffixb.dXrs:                         17 ; 0x006: SCHE=0x1 NUMB=0x1
    kffixb.ub1spare:                      0 ; 0x007: 0x00
    kffixb.ub4spare:                      0 ; 0x008: 0x00000000
    kffixe[0].xptr.au:                  704 ; 0x00c: 0x000002c0
    kffixe[0].xptr.disk:                  0 ; 0x010: 0x0000
    kffixe[0].xptr.flags:                 0 ; 0x012: L=0 E=0 D=0 S=0
    kffixe[0].xptr.chk:                 232 ; 0x013: 0xe8
    ………省略………
    kffixe[89].xptr.au:                 738 ; 0x2d4: 0x000002e2
    kffixe[89].xptr.disk:                 0 ; 0x2d8: 0x0000
    kffixe[89].xptr.flags:                0 ; 0x2da: L=0 E=0 D=0 S=0
    kffixe[89].xptr.chk:                202 ; 0x2db: 0xca
    kffixe[90].xptr.au:                1185 ; 0x2dc: 0x000004a1
    kffixe[90].xptr.disk:                 1 ; 0x2e0: 0x0001
    kffixe[90].xptr.flags:                0 ; 0x2e2: L=0 E=0 D=0 S=0
    kffixe[90].xptr.chk:                142 ; 0x2e3: 0x8e
    kffixe[91].xptr.au:          4294967295 ; 0x2e4: 0xffffffff
    kffixe[91].xptr.disk:             65535 ; 0x2e8: 0xffff
    kffixe[91].xptr.flags:                0 ; 0x2ea: L=0 E=0 D=0 S=0
    kffixe[91].xptr.chk:                 42 ; 0x2eb: 0x2a
    
  3. 这个方法,在ORACLE11g中,AU=4M 好像不行呀,在0号盘2号AU中无法找到AU的分布信息。

发表评论

邮箱地址不会被公开。 必填项已用*标注

7 − 2 =