oracle asm 磁盘头数据以及备份与恢复基础篇(二)
2017-03-03 16:41
423 查看
今天是2014-03-11,对于Oracle asm的元数据分为固定源数据和逻辑源数据,固定源数据一般占用磁盘的前两个au,其中内容包括disk
header 、allocation table(AT)、free space table(FST)、(partnership status table(PST),逻辑源数据是存在asm 文件中包括的一些信息:
一:工具使用:
查看磁盘元数据通常考虑使用kfed工具,但是该工具和bbed类似,需要自动编译才可使用:
编译生成工具:
[sql] view
plain copy
[root@oracle-one ~]# su - grid
-bash-4.1$ cd /ginf/grid/product/11.2.0/grid_1/rdbms/
-bash-4.1$ cd lib
-bash-4.1$ make -f ins_rdbms.mk ikfed
Linking KFED utility (kfed)
rm -f /ginf/grid/product/11.2.0/grid_1/rdbms/lib/kfed
gcc -o /ginf/grid/product/11.2.0/grid_1/rdbms/lib/kfed -m64 -z noexecstack -L/ginf/grid/product/11.2.0/grid_1/rdbms/lib/ -L/ginf/grid/product/11.2.0/grid_1/lib/ -L/ginf/grid/product/11.2.0/grid_1/lib/stubs/ /ginf/grid/product/11.2.0/grid_1/lib/s0main.o /ginf/grid/product/11.2.0/grid_1/rdbms/lib/sskfeded.o /ginf/grid/product/11.2.0/grid_1/rdbms/lib/skfedpt.o -ldbtools11 -lcommon11 -lcell11 -lskgxp11 -lhasgen11 -lskgxn2 -lnnz11 -lzt11 -lxml11 -locr11 -locrb11 -locrutl11 -lhasgen11 -lskgxn2 -lnnz11 -lzt11 -lxml11 -lasmclnt11 -lclntsh `cat /ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /
4000
ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnnz11 -lzt11 -lztkg11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lmm -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /ginf/grid/product/11.2.0/grid_1/lib/sysliblist` -Wl,-rpath,/ginf/grid/product/11.2.0/grid_1/lib -lm `cat /ginf/grid/product/11.2.0/grid_1/lib/sysliblist` -ldl -lm -L/ginf/grid/product/11.2.0/grid_1/lib
test ! -f /ginf/grid/product/11.2.0/grid_1/bin/kfed ||\
mv -f /ginf/grid/product/11.2.0/grid_1/bin/kfed /ginf/grid/product/11.2.0/grid_1/bin/kfedO
mv /ginf/grid/product/11.2.0/grid_1/rdbms/lib/kfed /ginf/grid/product/11.2.0/grid_1/bin/kfed
chmod 751 /ginf/grid/product/11.2.0/grid_1/bin/kfed
-bash-4.1$
-bash-4.1$ kfed -help
as/mlib ASM Library [asmlib='lib']
aun/um AU number to examine or update [AUNUM=number]
aus/z Allocation Unit size in bytes [AUSZ=number]
blkn/um Block number to examine or update [BLKNUM=number]
blks/z Metadata block size in bytes [BLKSZ=number]
ch/ksum Update checksum before each write [CHKSUM=YES/NO]
cn/t Count of AUs to process [CNT=number]
de/v ASM device to examine or update [DEV=string]
dm/pall Don't suppress repeated lines when dumping corrupt blocks [DMPALL=YES/NO]
o/p KFED operation type [OP=READ/WRITE/MERGE/REPAIR/NEW/FORM/FIND/STRUCT]
p/rovnm Name for provisioning purposes [PROVNM=string]
s/eek AU number to seek to [SEEK=number]
te/xt File name for translated block text [TEXT=string]
ty/pe ASM metadata block type number [TYPE=number]
-bash-4.1$ which kfed
/ginf/grid/product/11.2.0/grid_1/bin/kfed
通过help可以看出,kfed工具operation type有 read,write,dumping ,repare,new,from ,find,struct功能。
二、查看源数据:
asm 磁盘有个磁盘头(disk header)占用磁盘的第一个au的第一个block。查看如下:
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=0 blkn=0|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: blk=0
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 2360755735 ; 0x00c: 0x8cb64617
kfbh.fcn.base: 55762 ; 0x010: 0x0000d9d2
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKASMDISK2 ; 0x000: length=16
kfdhdb.driver.reserved[0]: 1145918273 ; 0x008: 0x444d5341
kfdhdb.driver.reserved[1]: 843797321 ; 0x00c: 0x324b5349
kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000
kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000
kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000
kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000
kfdhdb.compat: 186646528 ; 0x020: 0x0b200000
kfdhdb.dsknum: 1 ; 0x024: 0x0001
kfdhdb.grptyp: 2 ; 0x026: KFDGTP_NORMAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: DATAGROUP1_0001 ; 0x028: length=15
kfdhdb.grpname: DATAGROUP1 ; 0x048: length=10
kfdhdb.fgname: DATAGROUP1_0001 ; 0x068: length=15
kfdhdb.capname: ; 0x088: length=0
kfdhdb.crestmp.hi: 32993346 ; 0x0a8: HOUR=0x2 DAYS=0x2 MNTH=0xc YEAR=0x7dd
kfdhdb.crestmp.lo: 71610368 ; 0x0ac: USEC=0x0 MSEC=0x12c SECS=0x4 MINS=0x1
kfdhdb.mntstmp.hi: 33000821 ; 0x0b0: HOUR=0x15 DAYS=0xb MNTH=0x3 YEAR=0x7de
kfdhdb.mntstmp.lo: 3170037760 ; 0x0b4: USEC=0x0 MSEC=0xbc SECS=0xf MINS=0x2f
kfdhdb.secsize: 512 ; 0x0b8: 0x0200
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000
kfdhdb.mfact: 113792 ; 0x0c0: 0x0001bc80
kfdhdb.dsksize: 4094 ; 0x0c4: 0x00000ffe
kfdhdb.pmcnt: 2 ; 0x0c8: 0x00000002
kfdhdb.fstlocn: 1 ; 0x0cc: 0x00000001
kfdhdb.altlocn: 2 ; 0x0d0: 0x00000002
kfdhdb.f1b1locn: 2 ; 0x0d4: 0x00000002
kfdhdb.redomirrors[0]: 2 ; 0x0d8: 0x0002
kfdhdb.redomirrors[1]: 1 ; 0x0da: 0x0001
kfdhdb.redomirrors[2]: 3 ; 0x0dc: 0x0003
kfdhdb.redomirrors[3]: 65535 ; 0x0de: 0xffff
kfdhdb.dbcompat: 168820736 ; 0x0e0: 0x0a100000
kfdhdb.grpstmp.hi: 32993346 ; 0x0e4: HOUR=0x2 DAYS=0x2 MNTH=0xc YEAR=0x7dd
kfdhdb.grpstmp.lo: 70603776 ; 0x0e8: USEC=0x0 MSEC=0x155 SECS=0x3 MINS=0x1
kfdhdb.vfstart: 0 ; 0x0ec: 0x00000000
kfdhdb.vfend: 0 ; 0x0f0: 0x00000000
kfdhdb.spfile: 0 ; 0x0f4: 0x00000000
kfdhdb.spfflg: 0 ; 0x0f8: 0x00000000
kfdhdb.ub4spare[0]: 0 ; 0x0fc: 0x00000000
kfdhdb.ub4spare[1]: 0 ; 0x100: 0x00000000
kfdhdb.ub4spare[2]: 0 ; 0x104: 0x00000000
kfdhdb.ub4spare[3]: 0 ; 0x108: 0x00000000
kfdhdb.ub4spare[4]: 0 ; 0x10c: 0x00000000
kfdhdb.ub4spare[5]: 0 ; 0x110: 0x00000000
kfdhdb.ub4spare[6]: 0 ; 0x114: 0x00000000
kfdhdb.ub4spare[7]: 0 ; 0x118: 0x00000000
kfdhdb.ub4spare[8]: 0 ; 0x11c: 0x00000000
kfdhdb.ub4spare[9]: 0 ; 0x120: 0x00000000
kfdhdb.ub4spare[10]: 0 ; 0x124: 0x00000000
kfdhdb.ub4spare[11]: 0 ; 0x128: 0x00000000
kfdhdb.ub4spare[12]: 0 ; 0x12c: 0x00000000
kfdhdb.ub4spare[13]: 0 ; 0x130: 0x00000000
kfdhdb.ub4spare[14]: 0 ; 0x134: 0x00000000
kfdhdb.ub4spare[15]: 0 ; 0x138: 0x00000000
kfdhdb.ub4spare[16]: 0 ; 0x13c: 0x00000000
kfdhdb.ub4spare[17]: 0 ; 0x140: 0x00000000
kfdhdb.ub4spare[18]: 0 ; 0x144: 0x00000000
kfdhdb.ub4spare[19]: 0 ; 0x148: 0x00000000
kfdhdb.ub4spare[20]: 0 ; 0x14c: 0x00000000
kfdhdb.ub4spare[21]: 0 ; 0x150: 0x00000000
kfdhdb.ub4spare[22]: 0 ; 0x154: 0x00000000
kfdhdb.ub4spare[23]: 0 ; 0x158: 0x00000000
kfdhdb.ub4spare[24]: 0 ; 0x15c: 0x00000000
kfdhdb.ub4spare[25]: 0 ; 0x160: 0x00000000
kfdhdb.ub4spare[26]: 0 ; 0x164: 0x00000000
kfdhdb.ub4spare[27]: 0 ; 0x168: 0x00000000
kfdhdb.ub4spare[28]: 0 ; 0x16c: 0x00000000
kfdhdb.ub4spare[29]: 0 ; 0x170: 0x00000000
kfdhdb.ub4spare[30]: 0 ; 0x174: 0x00000000
kfdhdb.ub4spare[31]: 0 ; 0x178: 0x00000000
kfdhdb.ub4spare[32]: 0 ; 0x17c: 0x00000000
kfdhdb.ub4spare[33]: 0 ; 0x180: 0x00000000
kfdhdb.ub4spare[34]: 0 ; 0x184: 0x00000000
kfdhdb.ub4spare[35]: 0 ; 0x188: 0x00000000
kfdhdb.ub4spare[36]: 0 ; 0x18c: 0x00000000
kfdhdb.ub4spare[37]: 0 ; 0x190: 0x00000000
kfdhdb.ub4spare[38]: 0 ; 0x194: 0x00000000
kfdhdb.ub4spare[39]: 0 ; 0x198: 0x00000000
kfdhdb.ub4spare[40]: 0 ; 0x19c: 0x00000000
kfdhdb.ub4spare[41]: 0 ; 0x1a0: 0x00000000
kfdhdb.ub4spare[42]: 0 ; 0x1a4: 0x00000000
kfdhdb.ub4spare[43]: 0 ; 0x1a8: 0x00000000
kfdhdb.ub4spare[44]: 0 ; 0x1ac: 0x00000000
kfdhdb.ub4spare[45]: 0 ; 0x1b0: 0x00000000
kfdhdb.ub4spare[46]: 0 ; 0x1b4: 0x00000000
kfdhdb.ub4spare[47]: 0 ; 0x1b8: 0x00000000
kfdhdb.ub4spare[48]: 0 ; 0x1bc: 0x00000000
kfdhdb.ub4spare[49]: 0 ; 0x1c0: 0x00000000
kfdhdb.ub4spare[50]: 0 ; 0x1c4: 0x00000000
kfdhdb.ub4spare[51]: 0 ; 0x1c8: 0x00000000
kfdhdb.ub4spare[52]: 0 ; 0x1cc: 0x00000000
kfdhdb.ub4spare[53]: 0 ; 0x1d0: 0x00000000
kfdhdb.acdb.aba.seq: 0 ; 0x1d4: 0x00000000
kfdhdb.acdb.aba.blk: 0 ; 0x1d8: 0x00000000
kfdhdb.acdb.ents: 0 ; 0x1dc: 0x0000
kfdhdb.acdb.ub2spare: 0 ; 0x1de: 0x0000
-bash-4.1$
从上面可以获得很多有意思的信息如:
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD(磁盘头)
kfdhdb.dskname: DATAGROUP1_0001 ; 0x028: length=15(磁盘名称啊)
kfdhdb.grpname: DATAGROUP1 ; 0x048: length=10(磁盘组名称啊)
kfdhdb.fgname: DATAGROUP1_0001 ; 0x068: length=15(故障组名称啊)
kfdhdb.secsize: 512 ; 0x0b8: 0x0200(扇区大小啊)
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000(块4k啊)
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000(au 1M啊)
。。。。。
disk header之后就是分配表如已经分配的au空闲的au(fst)。
查看第二个块,就是fst
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=0 blkn=1|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
<span style="color:#ff0000;">kfbh.type: 2 ; 0x002: KFBTYP_FREESPC
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 1 ; 0x004: blk=1
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 2189325159 ; 0x00c: 0x827e7367
kfbh.fcn.base: 57496 ; 0x010: 0x0000e098
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdfsb.aunum: 0 ; 0x000: 0x00000000
kfdfsb.max: 254 ; 0x004: 0x00fe
kfdfsb.cnt: 10 ; 0x006: 0x000a
kfdfsb.bound: 0 ; 0x008: 0x0000
kfdfsb.flag: 1 ; 0x00a: B=1
kfdfsb.ub1spare: 0 ; 0x00b: 0x00
kfdfsb.spare[0]: 0 ; 0x00c: 0x00000000
kfdfsb.spare[1]: 0 ; 0x010: 0x00000000
kfdfsb.spare[2]: 0 ; 0x014: 0x00000000
kfdfse[0].fse: 0 ; 0x018: FREE=0x0 FRAG=0x0
kfdfse[1].fse: 0 ; 0x019: FREE=0x0 FRAG=0x0
kfdfse[2].fse: 0 ; 0x01a: FREE=0x0 FRAG=0x0
kfdfse[3].fse: 119 ; 0x01b: FREE=0x7 FRAG=0x7
kfdfse[4].fse: 119 ; 0x01c: FREE=0x7 FRAG=0x7
kfdfse[5].fse: 119 ; 0x01d: FREE=0x7 FRAG=0x7
kfdfse[6].fse: 119 ; 0x01e: FREE=0x7 FRAG=0x7
kfdfse[7].fse: 119 ; 0x01f: FREE=0x7 FRAG=0x7
kfdfse[8].fse: 119 ; 0x020: FREE=0x7 FRAG=0x7
kfdfse[9].fse: 102 ; 0x021: FREE=0x6 FRAG=0x6
kfdfse[10].fse: 0 ; 0x022: FREE=0x0 FRAG=0x0
kfdfse[11].fse: 0 ; 0x023: FREE=0x0 FRAG=0x0
kfdfse[12].fse: 0 ; 0x024: FREE=0x0 FRAG=0x0
kfdfse[13].fse: 0 ; 0x025: FREE=0x0 FRAG=0x0
kfdfse[14].fse: 0 ; 0x026: FREE=0x0 FRAG=0x0
kfdfse[15].fse: 0 ; 0x027: FREE=0x0 FRAG=0x0
kfdfse[16].fse: 0 ; 0x028: FREE=0x0 FRAG=0x0
。。。
第三个块开始就是分配的allocation table(at)
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=0 blkn=2|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
<span style="color:#ff0000;">kfbh.type: 3 ; 0x002: KFBTYP_ALLOCTBL
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 2 ; 0x004: blk=2
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 2183618975 ; 0x00c: 0x8227619f
kfbh.fcn.base: 57496 ; 0x010: 0x0000e098
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdatb.aunum: 0 ; 0x000: 0x00000000
kfdatb.shrink: 448 ; 0x004: 0x01c0
kfdatb.ub2pad: 0 ; 0x006: 0x0000
kfdatb.auinfo[0].link.next: 8 ; 0x008: 0x0008
kfdatb.auinfo[0].link.prev: 8 ; 0x00a: 0x0008
kfdatb.auinfo[1].link.next: 12 ; 0x00c: 0x000c
kfdatb.auinfo[1].link.prev: 12 ; 0x00e: 0x000c
kfdatb.auinfo[2].link.next: 16 ; 0x010: 0x0010
kfdatb.auinfo[2].link.prev: 16 ; 0x012: 0x0010
kfdatb.auinfo[3].link.next: 20 ; 0x014: 0x0014
kfdatb.auinfo[3].link.prev: 20 ; 0x016: 0x0014
kfdatb.auinfo[4].link.next: 24 ; 0x018: 0x0018
kfdatb.auinfo[4].link.prev: 24 ; 0x01a: 0x0018
kfdatb.auinfo[5].link.next: 28 ; 0x01c: 0x001c
kfdatb.auinfo[5].link.prev: 28 ; 0x01e: 0x001c
kfdatb.auinfo[6].link.next: 32 ; 0x020: 0x0020
kfdatb.auinfo[6].link.prev: 32 ; 0x022: 0x0020
kfdatb.spare: 0 ; 0x024: 0x00000000
kfdate[0].discriminator: 1 ; 0x028: 0x00000001
kfdate[0].allo.lo: 0 ; 0x028: XNUM=0x0
kfdate[0].allo.hi: 8388608 ; 0x02c: V=1 I=0 H=0 FNUM=0x0
kfdate[1].discriminator: 1 ; 0x030: 0x00000001
kfdate[1].allo.lo: 0 ; 0x030: XNUM=0x0
kfdate[1].allo.hi: 8388608 ; 0x034: V=1 I=0 H=0 FNUM=0x0
kfdate[2].discriminator: 1 ; 0x038: 0x00000001
kfdate[2].allo.lo: 1 ; 0x038: XNUM=0x1
kfdate[2].allo.hi: 8388609 ; 0x03c: V=1 I=0 H=0 FNUM=0x1
kfdate[3].discriminator: 1 ; 0x040: 0x00000001
kfdate[3].allo.lo: 0 ; 0x040: XNUM=0x0
kfdate[3].allo.hi: 8388610 ; 0x044: V=1 I=0 H=0 FNUM=0x2
kfdate[4].discriminator: 1 ; 0x048: 0x00000001
kfdate[4].allo.lo: 2 ; 0x048: XNUM=0x2
kfdate[4].allo.hi: 8388611 ; 0x04c: V=1 I=0 H=0 FNUM=0x3
kfdate[5].discriminator: 1 ; 0x050: 0x00000001
--More--
at是记录磁盘分配au的情况,fst是记录未分配au的情况,另外还有pst是记录磁盘成员之间的伙伴关系,另外还有保存磁盘心跳的信息,避免被不同集群挂载。
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=1 blkn=0|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
<span style="color:#ff0000;">kfbh.type: 17 ; 0x002: KFBTYP_PST_META
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 256 ; 0x004: blk=256
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 3833865074 ; 0x00c: 0xe4842372
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdpHdrPairBv1.first.super.time.hi:33000821 ; 0x000: HOUR=0x15 DAYS=0xb MNTH=0x3 YEAR=0x7de
kfdpHdrPairBv1.first.super.time.lo:1833184256 ; 0x004: USEC=0x0 MSEC=0x10b SECS=0x14 MINS=0x1b
kfdpHdrPairBv1.first.super.last: 32 ; 0x008: 0x00000020
kfdpHdrPairBv1.first.super.next: 32 ; 0x00c: 0x00000020
kfdpHdrPairBv1.first.super.copyCnt: 3 ; 0x010: 0x03
kfdpHdrPairBv1.first.super.version: 1 ; 0x011: 0x01
kfdpHdrPairBv1.first.super.ub2spare: 0 ; 0x012: 0x0000
kfdpHdrPairBv1.first.super.incarn: 4 ; 0x014: 0x00000004
kfdpHdrPairBv1.first.super.copy[0]: 1 ; 0x018: 0x0001
kfdpHdrPairBv1.first.super.copy[1]: 2 ; 0x01a: 0x0002
kfdpHdrPairBv1.first.super.copy[2]: 3 ; 0x01c: 0x0003
kfdpHdrPairBv1.first.super.copy[3]: 0 ; 0x01e: 0x0000
kfdpHdrPairBv1.first.super.copy[4]: 0 ; 0x020: 0x0000
kfdpHdrPairBv1.first.super.dtaSz: 4 ; 0x022: 0x0004
kfdpHdrPairBv1.first.asmCompat:186646528 ; 0x024: 0x0b200000
kfdpHdrPairBv1.first.newCopy[0]: 0 ; 0x028: 0x0000
kfdpHdrPairBv1.first.newCopy[1]: 0 ; 0x02a: 0x0000
kfdpHdrPairBv1.first.newCopy[2]: 0 ; 0x02c: 0x0000
kfdpHdrPairBv1.first.newCopy[3]: 0 ; 0x02e: 0x0000
kfdpHdrPairBv1.first.newCopy[4]: 0 ; 0x030: 0x0000
kfdpHdrPairBv1.first.newCopyCnt: 0 ; 0x032: 0x00
kfdpHdrPairBv1.first.contType: 1 ; 0x033: 0x01
kfdpHdrPairBv1.first.spare0: 0 ; 0x034: 0x00000000
kfdpHdrPairBv1.first.ppat[0]: 0 ; 0x038: 0x0000
kfdpHdrPairBv1.first.ppat[1]: 0 ; 0x03a: 0x0000
kfdpHdrPairBv1.first.ppat[2]: 0 ; 0x03c: 0x0000
kfdpHdrPairBv1.first.ppat[3]: 0 ; 0x03e: 0x0000
kfdpHdrPairBv1.first.ppatsz: 0 ; 0x040: 0x00
kfdpHdrPairBv1.first.spare1: 0 ; 0x041: 0x00
kfdpHdrPairBv1.first.spare2: 0 ; 0x042: 0x0000
kfdpHdrPairBv1.first.spares[0]: 0 ; 0x044: 0x00000000
kfdpHdrPairBv1.first.spares[1]: 0 ; 0x048: 0x00000000
kfdpHdrPairBv1.first.spares[2]: 0 ; 0x04c: 0x00000000
kfdpHdrPairBv1.first.spares[3]: 0 ; 0x050: 0x00000000
。。。。
第二个au的最后一个块,1024/4=255+1(因取0故丢1),恰恰存在了磁盘心态,避免了脑裂方式一种补偿。
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=1 blkn=255|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 19 ; 0x002: <span style="color:#ff0000;">KFBTYP_HBEAT
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 511 ; 0x004: blk=511
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 1571693689 ; 0x00c: 0x5dae2479
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
<span style="color:#ff0000;">kfdpHbeatB</span>.instance: 1 ; 0x000: 0x00000001
kfdpHbeatB.ts.hi: 33000823 ; 0x004: HOUR=0x17 DAYS=0xb MNTH=0x3 YEAR=0x7de
kfdpHbeatB.ts.lo: 2141339648 ; 0x008: USEC=0x0 MSEC=0x90 SECS=0x3a MINS=0x1f
<span style="color:#ff0000;">kfdpHbeatB</span>.rnd[0]: 1286604410 ; 0x00c: 0x4cb0067a
k<span style="color:#ff0000;">fdpHbeatB</span>.rnd[1]: 735447844 ; 0x010: 0x2bd60b24
kfdpHbeatB.rnd[2]: 3112551355 ; 0x014: 0xb985c3bb
kfdpHbeatB.rnd[3]: 2131469333 ; 0x018: 0x7f0ba415
-bash-4.1$
既然磁盘的磁头源数据这么重要,那么在11G开始就有了md_backup和md_restore对元数据进行备份和恢复的方式:
eg:
-bash-4.1$ asmcmd -p
ASMCMD [+] > help md_backup
md_backup
The md_backup command creates a backup file containing metadata
for one or more disk groups.
Volume and Oracle Automatic Storage Management Cluster File System
(Oracle ACFS) file system information is not backed up.
md_backup backup_file [-G diskgroup [,diskgroup,...]]
The options for the md_backup command are described below.
backup_file - Specifies the backup file in which you want to
store the metadata.
-G diskgroup - Specifies the disk group name of the disk group
that must be backed up
By default all the mounted disk groups are included in the backup file,
which is saved in the current working directory.
The first example shows the use of the backup command when you run it
without the disk group option. This example backs up all of the mounted
disk groups and creates the backup image in the current working
directory. The second example creates a backup of disk group DATA and
FRA. The backup that this example creates is saved in the
/tmp/dgbackup20090716 file.
ASMCMD [+] > md_backup /tmp/dgbackup20090716
ASMCMD [+] > md_backup /tmp/dgbackup20090716 -G DATA,FRA
Disk group metadata to be backed up: DATA
Disk group metadata to be backed up: FRA
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/TEMPFILE
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/PARAMETERFILE
Current alias directory path: ASM
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ORCL
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/ARCHIVELOG/2009_07_13
Current alias directory path: ORCL/BACKUPSET/2009_07_14
Current alias directory path: ORCL/ARCHIVELOG/2009_07_14
Current alias directory path: ORCL
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/ARCHIVELOG
Current alias directory path: ORCL/BACKUPSET
Current alias directory path: ORCL/ONLINELOG
查看帮助已经写了非常的详细,例子也有,现在就开始对元数据进行备份:
首先备份全部磁盘组元数据:
eg:
[sql] view
plain copy
ASMCMD [+] > md_backup /tmp/dgback_rhys
Disk group metadata to be backed up: DATAGROUP1
Disk group metadata to be backed up: DATAGROUP2
Disk group metadata to be backed up: DATAGROUP3
Current alias directory path: RHYS/ARCHIVELOG/2014_03_05
Current alias directory path: RHYS/ARCHIVELOG
Current alias directory path: RHYS/AUTOBACKUP/2014_01_13
Current alias directory path: RHYS
Current alias directory path: DUMMY/PARAMETERFILE
Current alias directory path: RHYS/FLASHBACK
Current alias directory path: ASM
Current alias directory path: RHYS/AUTOBACKUP/2013_12_12
Current alias directory path: RHYS/ARCHIVELOG/2014_03_10
Current alias directory path: RHYS/TEMPFILE
Current alias directory path: RHYS/CONTROLFILE
Current alias directory path: RHYS/ARCHIVELOG/2014_02_24
Current alias directory path: RHYS/ARCHIVELOG/2014_03_06
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: RHYS/ARCHIVELOG/2014_03_11
Current alias directory path: RHYS/AUTOBACKUP
Current alias directory path: RHYS/ARCHIVELOG/2014_02_23
Current alias directory path: RHYS/DATAFILE
Current alias directory path: DUMMY
Current alias directory path: RHYS/ARCHIVELOG/2014_02_25
Current alias directory path: RHYS/ONLINELOG
如果需要备份指定磁盘组的元数据需要使用-G参数:
eg:
[sql] view
plain copy
ASMCMD [+] > md_backup /tmp/datagroup1_metadata_bak -G datagroup1
Disk group metadata to be backed up: DATAGROUP1
Current alias directory path: RHYS/ARCHIVELOG/2014_03_05
Current alias directory path: RHYS/ARCHIVELOG
Current alias directory path: RHYS/AUTOBACKUP/2014_01_13
Current alias directory path: RHYS
Current alias directory path: DUMMY/PARAMETERFILE
Current alias directory path: RHYS/FLASHBACK
Current alias directory path: ASM
Current alias directory path: RHYS/AUTOBACKUP/2013_12_12
Current alias directory path: RHYS/ARCHIVELOG/2014_03_10
Current alias directory path: RHYS/TEMPFILE
Current alias directory path: RHYS/CONTROLFILE
Current alias directory path: RHYS/ARCHIVELOG/2014_02_24
Current alias directory path: RHYS/ARCHIVELOG/2014_03_06
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: RHYS/AUTOBACKUP
Current alias directory path: RHYS/ARCHIVELOG/2014_03_11
Current alias directory path: RHYS/ARCHIVELOG/2014_02_23
Current alias directory path: RHYS/DATAFILE
Current alias directory path: DUMMY
Current alias directory path: RHYS/ARCHIVELOG/2014_02_25
Current alias directory path: RHYS/ONLINELOG
ASMCMD [+] > exit
-bash-4.1$ cd /tmp
-bash-4.1$ ls -l
total 168
-rw-r--r-- 1 grid oinstall 20825 Mar 11 22:52 datagroup1_metadata_bak
-rw-r--r-- 1 grid oinstall 43275 Mar 11 22:51 dgback_rhys
drwx------ 2 root root 4096 Feb 10 16:17 keyring-2K68nK
drwx------ 2 grid oinstall 4096 Mar 10 22:24 keyring-A0oM7y
drwx------ 2 root root 4096 Feb 8 15:45 keyring-KWIBiM
drwx------ 2 root root 4096 Feb 10 16:08 keyring-sNYqVr
drwx------ 2 oracle oinstall 4096 Mar 10 22:24 keyring-SRn3Bp
drwx------ 2 root root 16384 Dec 2 00:19 lost+found
-rw-r--r-- 1 grid oinstall 43275 Mar 11 22:47 oracledgbackup
drwx------ 2 root root 4096 Feb 10 16:17 pulse-LeoMkmUKAZsW
drwx------ 2 gdm gdm 4096 Mar 10 21:08 pulse-meUziInFt6tt
drwx------ 2 grid oinstall 4096 Mar 10 22:26 pulse-tToPdZjzVK1H
drwx------ 2 grid oinstall 4096 Mar 10 21:08 virtual-grid.pJx8gu
drwx------ 2 oracle oinstall 4096 Mar 10 20:38 virtual-oracle.vdM37e
查看备份的元数据,其实就是磁盘组、磁盘名啊、路径啊等信息
eg:
[html] view
plain copy
-bash-4.1$ more datagroup1_metadata_bak <
6178e
/span>
@diskgroup_set = (
{
'ATTRINFO' => {
'_._DIRVERSION' => '11.2.0.0.0',
'COMPATIBLE.ASM' => '11.2.0.0.0',
'COMPATIBLE.RDBMS' => '11.2.0.0.0'
},
'DISKSINFO' => {
'DATAGROUP1_0003' => {
'DATAGROUP1_0003' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0003',
'NAME' => 'DATAGROUP1_0003',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK4'
}
},
'DATAGROUP1_0001' => {
'DATAGROUP1_0001' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0001',
'NAME' => 'DATAGROUP1_0001',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK2'
}
},
'DATAGROUP1_0002' => {
'DATAGROUP1_0002' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0002',
'NAME' => 'DATAGROUP1_0002',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK3'
}
},
'DATAGROUP1_0000' => {
'DATAGROUP1_0000' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0000',
'NAME' => 'DATAGROUP1_0000',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK1'
}
}
},
'DGINFO' => {
'DGTORESTORE' => 0,
'DGCOMPAT' => '11.2.0.0.0',
'DGNAME' => 'DATAGROUP1',
'DGDBCOMPAT' => '11.2.0.0.0',
'DGTYPE' => 'NORMAL',
'DGAUSZ' => '1048576'
},
'ALIASINFO' => {
'11' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'ASM/ASMPARAMETERFILE',
'REFERENCE_INDEX' => '16777322'
},
'7' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/TEMPFILE',
'REFERENCE_INDEX' => '16777852'
},
'2' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 0,
'ALIASNAME' => 'DUMMY',
'REFERENCE_INDEX' => '16777534'
},
'17' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_10',
'REFERENCE_INDEX' => '16778064'
},
'1' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 0,
'ALIASNAME' => 'RHYS',
'REFERENCE_INDEX' => '16777375'
},
'18' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_11',
'REFERENCE_INDEX' => '16778117'
},
'0' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 0,
'ALIASNAME' => 'ASM',
'REFERENCE_INDEX' => '16777269'
},
'16' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_06',
'REFERENCE_INDEX' => '16778753'
},
'13' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_02_24',
'REFERENCE_INDEX' => '16778912'
},
'6' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/ONLINELOG',
'REFERENCE_INDEX' => '16777481'
},
'3' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'DUMMY/PARAMETERFILE',
'REFERENCE_INDEX' => '16777587'
},
'9' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/AUTOBACKUP',
'REFERENCE_INDEX' => '16777799'
},
'12' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_02_23',
'REFERENCE_INDEX' => '16778965'
},
'20' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/AUTOBACKUP/2014_01_13',
'REFERENCE_INDEX' => '16778435'
},
'15' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_05',
'REFERENCE_INDEX' => '16778806'
},
'14' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_02_25',
'REFERENCE_INDEX' => '16778859'
},
'8' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/ARCHIVELOG',
'REFERENCE_INDEX' => '16778700'
},
'4' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/CONTROLFILE',
'REFERENCE_INDEX' => '16777640'
},
'10' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/FLASHBACK',
'REFERENCE_INDEX' => '16778594'
},
'19' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/AUTOBACKUP/2013_12_12',
'REFERENCE_INDEX' => '16777905'
},
'5' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/DATAFILE',
'REFERENCE_INDEX' => '16777428'
}
},
'TEMPLATEINFO' => {
'11' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'AUTOBACKUP',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'7' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'PARAMETERFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'2' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'ARCHIVELOG',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'1' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'OCRFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'0' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'DATAFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'16' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'ONLINELOG',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'13' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'CHANGETRACKING',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'6' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'ASMPARAMETERFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'3' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'FLASHFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'9' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'BACKUPSET',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'12' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'XTRANSPORT',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'15' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'DATAGUARDCONFIG',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'14' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'FLASHBACK',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'8' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'TEMPFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'4' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'FINE',
'TEMPNAME' => 'CONTROLFILE',
'REDUNDANCY' => 'HIGH',
'SYSTEM' => 'Y'
},
'10' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'XTRANSPORT BACKUPSET',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'5' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'DUMPSET',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
}
}
}
);
-bash-4.1$
删除磁盘组datagroup2 ,然后进行恢复:(此恢复仅仅是对应磁盘组来说的,而不是对应里面的数据,数据的恢复需要使用rman还原哦!——)
eg:
首先看一下md_restore帮助:
ASMCMD [+] > help md_restore
md_restore
This command restores a disk group metadata backup.
md_restore backup_file [--silent][--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]'][-S sql_script_file] [-G 'diskgroup [,diskgroup...]']
The options for the md_restore command are described below.
backup_file - Reads the metadata information from
backup_file.
--silent - Ignore errors. Normally, if md_restore
encounters an error, it will stop.
Specifying this flag ignores any errors.
--full - Specifies to create a disk group and restore
metadata.
--nodg - Specifies to restore metadata only.
--newdg -o old_diskgroup:new_diskgroup - Specifies to create a disk
group with a different name when restoring
metadata. The -o option is required
with --newdg.
-S sql_script_file - Write SQL commands to the specified SQL
script file instead of executing the commands.
-G diskgroup - Select the disk groups to be restored.
If no disk groups are defined, then all
disk groups will be restored.
The first example restores the disk group DATA from the backup script
and creates a copy. The second example takes an existing disk group
DATA and restores its metadata. The third example restores disk group
DATA completely but the new disk group that is created is called DATA2.
The fourth example restores from the backup file after applying the
overrides defined in the override.sql script file
ASMCMD [+] > md_restore --full -G data --silent /tmp/dgbackup20090714
ASMCMD [+] > md_restore --nodg -G data --silent /tmp/dgbackup20090714
ASMCMD [+] > md_restore --newdg -o 'data:data2' --silent /tmp/dgbackup20090714
ASMCMD [+] > md_restore -S override.sql --silent /tmp/dgbackup20090714
开始恢复:
eg:
[sql] view
plain copy
ASMCMD [+] > md_restore --full -G datagroup1 --silent /tmp/datagroup1_metadata_bak
Current Diskgroup metadata being restored: DATAGROUP1
ASMCMD-9352: CREATE DISKGROUP failed
ORA-15018: diskgroup cannot be created
ORA-15030: diskgroup name "DATAGROUP1" is in use by another diskgroup (DBD ERROR: OCIStmtExecute)
ASMCMD [+] > host;
提示磁盘组不能在线,删掉在做
[sql] view
plain copy
-bash-4.1$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.4.0 Production on Tue Mar 11 23:03:29 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Automatic Storage Management option
SQL> select group_number,name,state,type from v$asm_diskgroup order by 1;
GROUP_NUMBER NAME STATE TYPE
------------ ------------------------------ ----------- ------
1 DATAGROUP1 MOUNTED NORMAL
2 DATAGROUP2 MOUNTED NORMAL
3 DATAGROUP3 MOUNTED NORMAL
SQL> drop diskgroup datagroup2 including contents;
Diskgroup dropped.
SQL> exit
恢复datagroup2:
eg:
[sql] view
plain copy
ASMCMD [+] > md_restore --full -G datagroup2 /tmp/dgback_rhys
Current Diskgroup metadata being restored: DATAGROUP2
Diskgroup DATAGROUP2 created!
System template FLASHBACK modified!
System template PARAMETERFILE modified!
System template ARCHIVELOG modified!
System template ONLINELOG modified!
System template DATAFILE modified!
System template BACKUPSET modified!
System template XTRANSPORT modified!
System template ASMPARAMETERFILE modified!
System template FLASHFILE modified!
System template OCRFILE modified!
System template CHANGETRACKING modified!
System template XTRANSPORT BACKUPSET modified!
System template AUTOBACKUP modified!
System template TEMPFILE modified!
System template CONTROLFILE modified!
System template DATAGUARDCONFIG modified!
System template DUMPSET modified!
ASMCMD [+] > lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED NORMAL N 512 4096 1048576 16376 9758 4094 2832 0 N DATAGROUP1/
MOUNTED NORMAL N 512 4096 1048576 8188 8086 0 4043 0 N DATAGROUP2/
MOUNTED NORMAL N 512 4096 1048576 4076 3966 1019 1473 0 N DATAGROUP3/
ASMCMD [+] >
可以将恢复过程生成一个脚本而不是执行恢复需要使用-S参数
eg:
[sql] view
plain copy
ASMCMD [+] > md_restore --full -G datagroup2 -S res_datagroup2.sql /tmp/dgback_rhys
Current Diskgroup metadata being restored: DATAGROUP2
ASMCMD [+] > exit
-bash-4.1$ more res_datagroup2.sql
create diskgroup DATAGROUP2 NORMAL redundancy failgroup FG2 disk '/dev/oracleasm/disks/ASMDISK6' name DATAGROUP2_0002 size 4094M failgroup DATAGROUP2_0001 disk '/dev/o
racleasm/disks/ASMDISK5' name DATAGROUP2_0001 size 4094M ;
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "FLASHBACK" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "PARAMETERFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "ARCHIVELOG" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "ONLINELOG" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "DATAFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "BACKUPSET" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "XTRANSPORT" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "ASMPARAMETERFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "FLASHFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "OCRFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "CHANGETRACKING" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "XTRANSPORT BACKUPSET" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "AUTOBACKUP" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "TEMPFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "CONTROLFILE" attributes (HIGH FINE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "DATAGUARDCONFIG" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "DUMPSET" attributes (MIRROR COARSE);
可见元数据的恢复就是一些create 命令啊,alter命令啊。
that‘s all!
header 、allocation table(AT)、free space table(FST)、(partnership status table(PST),逻辑源数据是存在asm 文件中包括的一些信息:
一:工具使用:
查看磁盘元数据通常考虑使用kfed工具,但是该工具和bbed类似,需要自动编译才可使用:
编译生成工具:
[sql] view
plain copy
[root@oracle-one ~]# su - grid
-bash-4.1$ cd /ginf/grid/product/11.2.0/grid_1/rdbms/
-bash-4.1$ cd lib
-bash-4.1$ make -f ins_rdbms.mk ikfed
Linking KFED utility (kfed)
rm -f /ginf/grid/product/11.2.0/grid_1/rdbms/lib/kfed
gcc -o /ginf/grid/product/11.2.0/grid_1/rdbms/lib/kfed -m64 -z noexecstack -L/ginf/grid/product/11.2.0/grid_1/rdbms/lib/ -L/ginf/grid/product/11.2.0/grid_1/lib/ -L/ginf/grid/product/11.2.0/grid_1/lib/stubs/ /ginf/grid/product/11.2.0/grid_1/lib/s0main.o /ginf/grid/product/11.2.0/grid_1/rdbms/lib/sskfeded.o /ginf/grid/product/11.2.0/grid_1/rdbms/lib/skfedpt.o -ldbtools11 -lcommon11 -lcell11 -lskgxp11 -lhasgen11 -lskgxn2 -lnnz11 -lzt11 -lxml11 -locr11 -locrb11 -locrutl11 -lhasgen11 -lskgxn2 -lnnz11 -lzt11 -lxml11 -lasmclnt11 -lclntsh `cat /ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /
4000
ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnnz11 -lzt11 -lztkg11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lmm -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /ginf/grid/product/11.2.0/grid_1/lib/ldflags` -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lnnetd11 -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /ginf/grid/product/11.2.0/grid_1/lib/sysliblist` -Wl,-rpath,/ginf/grid/product/11.2.0/grid_1/lib -lm `cat /ginf/grid/product/11.2.0/grid_1/lib/sysliblist` -ldl -lm -L/ginf/grid/product/11.2.0/grid_1/lib
test ! -f /ginf/grid/product/11.2.0/grid_1/bin/kfed ||\
mv -f /ginf/grid/product/11.2.0/grid_1/bin/kfed /ginf/grid/product/11.2.0/grid_1/bin/kfedO
mv /ginf/grid/product/11.2.0/grid_1/rdbms/lib/kfed /ginf/grid/product/11.2.0/grid_1/bin/kfed
chmod 751 /ginf/grid/product/11.2.0/grid_1/bin/kfed
-bash-4.1$
-bash-4.1$ kfed -help
as/mlib ASM Library [asmlib='lib']
aun/um AU number to examine or update [AUNUM=number]
aus/z Allocation Unit size in bytes [AUSZ=number]
blkn/um Block number to examine or update [BLKNUM=number]
blks/z Metadata block size in bytes [BLKSZ=number]
ch/ksum Update checksum before each write [CHKSUM=YES/NO]
cn/t Count of AUs to process [CNT=number]
de/v ASM device to examine or update [DEV=string]
dm/pall Don't suppress repeated lines when dumping corrupt blocks [DMPALL=YES/NO]
o/p KFED operation type [OP=READ/WRITE/MERGE/REPAIR/NEW/FORM/FIND/STRUCT]
p/rovnm Name for provisioning purposes [PROVNM=string]
s/eek AU number to seek to [SEEK=number]
te/xt File name for translated block text [TEXT=string]
ty/pe ASM metadata block type number [TYPE=number]
-bash-4.1$ which kfed
/ginf/grid/product/11.2.0/grid_1/bin/kfed
通过help可以看出,kfed工具operation type有 read,write,dumping ,repare,new,from ,find,struct功能。
二、查看源数据:
asm 磁盘有个磁盘头(disk header)占用磁盘的第一个au的第一个block。查看如下:
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=0 blkn=0|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: blk=0
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 2360755735 ; 0x00c: 0x8cb64617
kfbh.fcn.base: 55762 ; 0x010: 0x0000d9d2
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKASMDISK2 ; 0x000: length=16
kfdhdb.driver.reserved[0]: 1145918273 ; 0x008: 0x444d5341
kfdhdb.driver.reserved[1]: 843797321 ; 0x00c: 0x324b5349
kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000
kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000
kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000
kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000
kfdhdb.compat: 186646528 ; 0x020: 0x0b200000
kfdhdb.dsknum: 1 ; 0x024: 0x0001
kfdhdb.grptyp: 2 ; 0x026: KFDGTP_NORMAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: DATAGROUP1_0001 ; 0x028: length=15
kfdhdb.grpname: DATAGROUP1 ; 0x048: length=10
kfdhdb.fgname: DATAGROUP1_0001 ; 0x068: length=15
kfdhdb.capname: ; 0x088: length=0
kfdhdb.crestmp.hi: 32993346 ; 0x0a8: HOUR=0x2 DAYS=0x2 MNTH=0xc YEAR=0x7dd
kfdhdb.crestmp.lo: 71610368 ; 0x0ac: USEC=0x0 MSEC=0x12c SECS=0x4 MINS=0x1
kfdhdb.mntstmp.hi: 33000821 ; 0x0b0: HOUR=0x15 DAYS=0xb MNTH=0x3 YEAR=0x7de
kfdhdb.mntstmp.lo: 3170037760 ; 0x0b4: USEC=0x0 MSEC=0xbc SECS=0xf MINS=0x2f
kfdhdb.secsize: 512 ; 0x0b8: 0x0200
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000
kfdhdb.mfact: 113792 ; 0x0c0: 0x0001bc80
kfdhdb.dsksize: 4094 ; 0x0c4: 0x00000ffe
kfdhdb.pmcnt: 2 ; 0x0c8: 0x00000002
kfdhdb.fstlocn: 1 ; 0x0cc: 0x00000001
kfdhdb.altlocn: 2 ; 0x0d0: 0x00000002
kfdhdb.f1b1locn: 2 ; 0x0d4: 0x00000002
kfdhdb.redomirrors[0]: 2 ; 0x0d8: 0x0002
kfdhdb.redomirrors[1]: 1 ; 0x0da: 0x0001
kfdhdb.redomirrors[2]: 3 ; 0x0dc: 0x0003
kfdhdb.redomirrors[3]: 65535 ; 0x0de: 0xffff
kfdhdb.dbcompat: 168820736 ; 0x0e0: 0x0a100000
kfdhdb.grpstmp.hi: 32993346 ; 0x0e4: HOUR=0x2 DAYS=0x2 MNTH=0xc YEAR=0x7dd
kfdhdb.grpstmp.lo: 70603776 ; 0x0e8: USEC=0x0 MSEC=0x155 SECS=0x3 MINS=0x1
kfdhdb.vfstart: 0 ; 0x0ec: 0x00000000
kfdhdb.vfend: 0 ; 0x0f0: 0x00000000
kfdhdb.spfile: 0 ; 0x0f4: 0x00000000
kfdhdb.spfflg: 0 ; 0x0f8: 0x00000000
kfdhdb.ub4spare[0]: 0 ; 0x0fc: 0x00000000
kfdhdb.ub4spare[1]: 0 ; 0x100: 0x00000000
kfdhdb.ub4spare[2]: 0 ; 0x104: 0x00000000
kfdhdb.ub4spare[3]: 0 ; 0x108: 0x00000000
kfdhdb.ub4spare[4]: 0 ; 0x10c: 0x00000000
kfdhdb.ub4spare[5]: 0 ; 0x110: 0x00000000
kfdhdb.ub4spare[6]: 0 ; 0x114: 0x00000000
kfdhdb.ub4spare[7]: 0 ; 0x118: 0x00000000
kfdhdb.ub4spare[8]: 0 ; 0x11c: 0x00000000
kfdhdb.ub4spare[9]: 0 ; 0x120: 0x00000000
kfdhdb.ub4spare[10]: 0 ; 0x124: 0x00000000
kfdhdb.ub4spare[11]: 0 ; 0x128: 0x00000000
kfdhdb.ub4spare[12]: 0 ; 0x12c: 0x00000000
kfdhdb.ub4spare[13]: 0 ; 0x130: 0x00000000
kfdhdb.ub4spare[14]: 0 ; 0x134: 0x00000000
kfdhdb.ub4spare[15]: 0 ; 0x138: 0x00000000
kfdhdb.ub4spare[16]: 0 ; 0x13c: 0x00000000
kfdhdb.ub4spare[17]: 0 ; 0x140: 0x00000000
kfdhdb.ub4spare[18]: 0 ; 0x144: 0x00000000
kfdhdb.ub4spare[19]: 0 ; 0x148: 0x00000000
kfdhdb.ub4spare[20]: 0 ; 0x14c: 0x00000000
kfdhdb.ub4spare[21]: 0 ; 0x150: 0x00000000
kfdhdb.ub4spare[22]: 0 ; 0x154: 0x00000000
kfdhdb.ub4spare[23]: 0 ; 0x158: 0x00000000
kfdhdb.ub4spare[24]: 0 ; 0x15c: 0x00000000
kfdhdb.ub4spare[25]: 0 ; 0x160: 0x00000000
kfdhdb.ub4spare[26]: 0 ; 0x164: 0x00000000
kfdhdb.ub4spare[27]: 0 ; 0x168: 0x00000000
kfdhdb.ub4spare[28]: 0 ; 0x16c: 0x00000000
kfdhdb.ub4spare[29]: 0 ; 0x170: 0x00000000
kfdhdb.ub4spare[30]: 0 ; 0x174: 0x00000000
kfdhdb.ub4spare[31]: 0 ; 0x178: 0x00000000
kfdhdb.ub4spare[32]: 0 ; 0x17c: 0x00000000
kfdhdb.ub4spare[33]: 0 ; 0x180: 0x00000000
kfdhdb.ub4spare[34]: 0 ; 0x184: 0x00000000
kfdhdb.ub4spare[35]: 0 ; 0x188: 0x00000000
kfdhdb.ub4spare[36]: 0 ; 0x18c: 0x00000000
kfdhdb.ub4spare[37]: 0 ; 0x190: 0x00000000
kfdhdb.ub4spare[38]: 0 ; 0x194: 0x00000000
kfdhdb.ub4spare[39]: 0 ; 0x198: 0x00000000
kfdhdb.ub4spare[40]: 0 ; 0x19c: 0x00000000
kfdhdb.ub4spare[41]: 0 ; 0x1a0: 0x00000000
kfdhdb.ub4spare[42]: 0 ; 0x1a4: 0x00000000
kfdhdb.ub4spare[43]: 0 ; 0x1a8: 0x00000000
kfdhdb.ub4spare[44]: 0 ; 0x1ac: 0x00000000
kfdhdb.ub4spare[45]: 0 ; 0x1b0: 0x00000000
kfdhdb.ub4spare[46]: 0 ; 0x1b4: 0x00000000
kfdhdb.ub4spare[47]: 0 ; 0x1b8: 0x00000000
kfdhdb.ub4spare[48]: 0 ; 0x1bc: 0x00000000
kfdhdb.ub4spare[49]: 0 ; 0x1c0: 0x00000000
kfdhdb.ub4spare[50]: 0 ; 0x1c4: 0x00000000
kfdhdb.ub4spare[51]: 0 ; 0x1c8: 0x00000000
kfdhdb.ub4spare[52]: 0 ; 0x1cc: 0x00000000
kfdhdb.ub4spare[53]: 0 ; 0x1d0: 0x00000000
kfdhdb.acdb.aba.seq: 0 ; 0x1d4: 0x00000000
kfdhdb.acdb.aba.blk: 0 ; 0x1d8: 0x00000000
kfdhdb.acdb.ents: 0 ; 0x1dc: 0x0000
kfdhdb.acdb.ub2spare: 0 ; 0x1de: 0x0000
-bash-4.1$
从上面可以获得很多有意思的信息如:
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD(磁盘头)
kfdhdb.dskname: DATAGROUP1_0001 ; 0x028: length=15(磁盘名称啊)
kfdhdb.grpname: DATAGROUP1 ; 0x048: length=10(磁盘组名称啊)
kfdhdb.fgname: DATAGROUP1_0001 ; 0x068: length=15(故障组名称啊)
kfdhdb.secsize: 512 ; 0x0b8: 0x0200(扇区大小啊)
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000(块4k啊)
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000(au 1M啊)
。。。。。
disk header之后就是分配表如已经分配的au空闲的au(fst)。
查看第二个块,就是fst
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=0 blkn=1|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
<span style="color:#ff0000;">kfbh.type: 2 ; 0x002: KFBTYP_FREESPC
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 1 ; 0x004: blk=1
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 2189325159 ; 0x00c: 0x827e7367
kfbh.fcn.base: 57496 ; 0x010: 0x0000e098
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdfsb.aunum: 0 ; 0x000: 0x00000000
kfdfsb.max: 254 ; 0x004: 0x00fe
kfdfsb.cnt: 10 ; 0x006: 0x000a
kfdfsb.bound: 0 ; 0x008: 0x0000
kfdfsb.flag: 1 ; 0x00a: B=1
kfdfsb.ub1spare: 0 ; 0x00b: 0x00
kfdfsb.spare[0]: 0 ; 0x00c: 0x00000000
kfdfsb.spare[1]: 0 ; 0x010: 0x00000000
kfdfsb.spare[2]: 0 ; 0x014: 0x00000000
kfdfse[0].fse: 0 ; 0x018: FREE=0x0 FRAG=0x0
kfdfse[1].fse: 0 ; 0x019: FREE=0x0 FRAG=0x0
kfdfse[2].fse: 0 ; 0x01a: FREE=0x0 FRAG=0x0
kfdfse[3].fse: 119 ; 0x01b: FREE=0x7 FRAG=0x7
kfdfse[4].fse: 119 ; 0x01c: FREE=0x7 FRAG=0x7
kfdfse[5].fse: 119 ; 0x01d: FREE=0x7 FRAG=0x7
kfdfse[6].fse: 119 ; 0x01e: FREE=0x7 FRAG=0x7
kfdfse[7].fse: 119 ; 0x01f: FREE=0x7 FRAG=0x7
kfdfse[8].fse: 119 ; 0x020: FREE=0x7 FRAG=0x7
kfdfse[9].fse: 102 ; 0x021: FREE=0x6 FRAG=0x6
kfdfse[10].fse: 0 ; 0x022: FREE=0x0 FRAG=0x0
kfdfse[11].fse: 0 ; 0x023: FREE=0x0 FRAG=0x0
kfdfse[12].fse: 0 ; 0x024: FREE=0x0 FRAG=0x0
kfdfse[13].fse: 0 ; 0x025: FREE=0x0 FRAG=0x0
kfdfse[14].fse: 0 ; 0x026: FREE=0x0 FRAG=0x0
kfdfse[15].fse: 0 ; 0x027: FREE=0x0 FRAG=0x0
kfdfse[16].fse: 0 ; 0x028: FREE=0x0 FRAG=0x0
。。。
第三个块开始就是分配的allocation table(at)
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=0 blkn=2|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
<span style="color:#ff0000;">kfbh.type: 3 ; 0x002: KFBTYP_ALLOCTBL
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 2 ; 0x004: blk=2
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 2183618975 ; 0x00c: 0x8227619f
kfbh.fcn.base: 57496 ; 0x010: 0x0000e098
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdatb.aunum: 0 ; 0x000: 0x00000000
kfdatb.shrink: 448 ; 0x004: 0x01c0
kfdatb.ub2pad: 0 ; 0x006: 0x0000
kfdatb.auinfo[0].link.next: 8 ; 0x008: 0x0008
kfdatb.auinfo[0].link.prev: 8 ; 0x00a: 0x0008
kfdatb.auinfo[1].link.next: 12 ; 0x00c: 0x000c
kfdatb.auinfo[1].link.prev: 12 ; 0x00e: 0x000c
kfdatb.auinfo[2].link.next: 16 ; 0x010: 0x0010
kfdatb.auinfo[2].link.prev: 16 ; 0x012: 0x0010
kfdatb.auinfo[3].link.next: 20 ; 0x014: 0x0014
kfdatb.auinfo[3].link.prev: 20 ; 0x016: 0x0014
kfdatb.auinfo[4].link.next: 24 ; 0x018: 0x0018
kfdatb.auinfo[4].link.prev: 24 ; 0x01a: 0x0018
kfdatb.auinfo[5].link.next: 28 ; 0x01c: 0x001c
kfdatb.auinfo[5].link.prev: 28 ; 0x01e: 0x001c
kfdatb.auinfo[6].link.next: 32 ; 0x020: 0x0020
kfdatb.auinfo[6].link.prev: 32 ; 0x022: 0x0020
kfdatb.spare: 0 ; 0x024: 0x00000000
kfdate[0].discriminator: 1 ; 0x028: 0x00000001
kfdate[0].allo.lo: 0 ; 0x028: XNUM=0x0
kfdate[0].allo.hi: 8388608 ; 0x02c: V=1 I=0 H=0 FNUM=0x0
kfdate[1].discriminator: 1 ; 0x030: 0x00000001
kfdate[1].allo.lo: 0 ; 0x030: XNUM=0x0
kfdate[1].allo.hi: 8388608 ; 0x034: V=1 I=0 H=0 FNUM=0x0
kfdate[2].discriminator: 1 ; 0x038: 0x00000001
kfdate[2].allo.lo: 1 ; 0x038: XNUM=0x1
kfdate[2].allo.hi: 8388609 ; 0x03c: V=1 I=0 H=0 FNUM=0x1
kfdate[3].discriminator: 1 ; 0x040: 0x00000001
kfdate[3].allo.lo: 0 ; 0x040: XNUM=0x0
kfdate[3].allo.hi: 8388610 ; 0x044: V=1 I=0 H=0 FNUM=0x2
kfdate[4].discriminator: 1 ; 0x048: 0x00000001
kfdate[4].allo.lo: 2 ; 0x048: XNUM=0x2
kfdate[4].allo.hi: 8388611 ; 0x04c: V=1 I=0 H=0 FNUM=0x3
kfdate[5].discriminator: 1 ; 0x050: 0x00000001
--More--
at是记录磁盘分配au的情况,fst是记录未分配au的情况,另外还有pst是记录磁盘成员之间的伙伴关系,另外还有保存磁盘心跳的信息,避免被不同集群挂载。
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=1 blkn=0|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
<span style="color:#ff0000;">kfbh.type: 17 ; 0x002: KFBTYP_PST_META
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 256 ; 0x004: blk=256
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 3833865074 ; 0x00c: 0xe4842372
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdpHdrPairBv1.first.super.time.hi:33000821 ; 0x000: HOUR=0x15 DAYS=0xb MNTH=0x3 YEAR=0x7de
kfdpHdrPairBv1.first.super.time.lo:1833184256 ; 0x004: USEC=0x0 MSEC=0x10b SECS=0x14 MINS=0x1b
kfdpHdrPairBv1.first.super.last: 32 ; 0x008: 0x00000020
kfdpHdrPairBv1.first.super.next: 32 ; 0x00c: 0x00000020
kfdpHdrPairBv1.first.super.copyCnt: 3 ; 0x010: 0x03
kfdpHdrPairBv1.first.super.version: 1 ; 0x011: 0x01
kfdpHdrPairBv1.first.super.ub2spare: 0 ; 0x012: 0x0000
kfdpHdrPairBv1.first.super.incarn: 4 ; 0x014: 0x00000004
kfdpHdrPairBv1.first.super.copy[0]: 1 ; 0x018: 0x0001
kfdpHdrPairBv1.first.super.copy[1]: 2 ; 0x01a: 0x0002
kfdpHdrPairBv1.first.super.copy[2]: 3 ; 0x01c: 0x0003
kfdpHdrPairBv1.first.super.copy[3]: 0 ; 0x01e: 0x0000
kfdpHdrPairBv1.first.super.copy[4]: 0 ; 0x020: 0x0000
kfdpHdrPairBv1.first.super.dtaSz: 4 ; 0x022: 0x0004
kfdpHdrPairBv1.first.asmCompat:186646528 ; 0x024: 0x0b200000
kfdpHdrPairBv1.first.newCopy[0]: 0 ; 0x028: 0x0000
kfdpHdrPairBv1.first.newCopy[1]: 0 ; 0x02a: 0x0000
kfdpHdrPairBv1.first.newCopy[2]: 0 ; 0x02c: 0x0000
kfdpHdrPairBv1.first.newCopy[3]: 0 ; 0x02e: 0x0000
kfdpHdrPairBv1.first.newCopy[4]: 0 ; 0x030: 0x0000
kfdpHdrPairBv1.first.newCopyCnt: 0 ; 0x032: 0x00
kfdpHdrPairBv1.first.contType: 1 ; 0x033: 0x01
kfdpHdrPairBv1.first.spare0: 0 ; 0x034: 0x00000000
kfdpHdrPairBv1.first.ppat[0]: 0 ; 0x038: 0x0000
kfdpHdrPairBv1.first.ppat[1]: 0 ; 0x03a: 0x0000
kfdpHdrPairBv1.first.ppat[2]: 0 ; 0x03c: 0x0000
kfdpHdrPairBv1.first.ppat[3]: 0 ; 0x03e: 0x0000
kfdpHdrPairBv1.first.ppatsz: 0 ; 0x040: 0x00
kfdpHdrPairBv1.first.spare1: 0 ; 0x041: 0x00
kfdpHdrPairBv1.first.spare2: 0 ; 0x042: 0x0000
kfdpHdrPairBv1.first.spares[0]: 0 ; 0x044: 0x00000000
kfdpHdrPairBv1.first.spares[1]: 0 ; 0x048: 0x00000000
kfdpHdrPairBv1.first.spares[2]: 0 ; 0x04c: 0x00000000
kfdpHdrPairBv1.first.spares[3]: 0 ; 0x050: 0x00000000
。。。。
第二个au的最后一个块,1024/4=255+1(因取0故丢1),恰恰存在了磁盘心态,避免了脑裂方式一种补偿。
eg:
[sql] view
plain copy
-bash-4.1$ kfed read /dev/oracleasm/disks/ASMDISK2 aun=1 blkn=255|more
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 19 ; 0x002: <span style="color:#ff0000;">KFBTYP_HBEAT
</span>kfbh.datfmt: 2 ; 0x003: 0x02
kfbh.block.blk: 511 ; 0x004: blk=511
kfbh.block.obj: 2147483649 ; 0x008: disk=1
kfbh.check: 1571693689 ; 0x00c: 0x5dae2479
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
<span style="color:#ff0000;">kfdpHbeatB</span>.instance: 1 ; 0x000: 0x00000001
kfdpHbeatB.ts.hi: 33000823 ; 0x004: HOUR=0x17 DAYS=0xb MNTH=0x3 YEAR=0x7de
kfdpHbeatB.ts.lo: 2141339648 ; 0x008: USEC=0x0 MSEC=0x90 SECS=0x3a MINS=0x1f
<span style="color:#ff0000;">kfdpHbeatB</span>.rnd[0]: 1286604410 ; 0x00c: 0x4cb0067a
k<span style="color:#ff0000;">fdpHbeatB</span>.rnd[1]: 735447844 ; 0x010: 0x2bd60b24
kfdpHbeatB.rnd[2]: 3112551355 ; 0x014: 0xb985c3bb
kfdpHbeatB.rnd[3]: 2131469333 ; 0x018: 0x7f0ba415
-bash-4.1$
既然磁盘的磁头源数据这么重要,那么在11G开始就有了md_backup和md_restore对元数据进行备份和恢复的方式:
eg:
-bash-4.1$ asmcmd -p
ASMCMD [+] > help md_backup
md_backup
The md_backup command creates a backup file containing metadata
for one or more disk groups.
Volume and Oracle Automatic Storage Management Cluster File System
(Oracle ACFS) file system information is not backed up.
md_backup backup_file [-G diskgroup [,diskgroup,...]]
The options for the md_backup command are described below.
backup_file - Specifies the backup file in which you want to
store the metadata.
-G diskgroup - Specifies the disk group name of the disk group
that must be backed up
By default all the mounted disk groups are included in the backup file,
which is saved in the current working directory.
The first example shows the use of the backup command when you run it
without the disk group option. This example backs up all of the mounted
disk groups and creates the backup image in the current working
directory. The second example creates a backup of disk group DATA and
FRA. The backup that this example creates is saved in the
/tmp/dgbackup20090716 file.
ASMCMD [+] > md_backup /tmp/dgbackup20090716
ASMCMD [+] > md_backup /tmp/dgbackup20090716 -G DATA,FRA
Disk group metadata to be backed up: DATA
Disk group metadata to be backed up: FRA
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/TEMPFILE
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/PARAMETERFILE
Current alias directory path: ASM
Current alias directory path: ORCL/ONLINELOG
Current alias directory path: ORCL
Current alias directory path: ORCL/CONTROLFILE
Current alias directory path: ORCL/ARCHIVELOG/2009_07_13
Current alias directory path: ORCL/BACKUPSET/2009_07_14
Current alias directory path: ORCL/ARCHIVELOG/2009_07_14
Current alias directory path: ORCL
Current alias directory path: ORCL/DATAFILE
Current alias directory path: ORCL/ARCHIVELOG
Current alias directory path: ORCL/BACKUPSET
Current alias directory path: ORCL/ONLINELOG
查看帮助已经写了非常的详细,例子也有,现在就开始对元数据进行备份:
首先备份全部磁盘组元数据:
eg:
[sql] view
plain copy
ASMCMD [+] > md_backup /tmp/dgback_rhys
Disk group metadata to be backed up: DATAGROUP1
Disk group metadata to be backed up: DATAGROUP2
Disk group metadata to be backed up: DATAGROUP3
Current alias directory path: RHYS/ARCHIVELOG/2014_03_05
Current alias directory path: RHYS/ARCHIVELOG
Current alias directory path: RHYS/AUTOBACKUP/2014_01_13
Current alias directory path: RHYS
Current alias directory path: DUMMY/PARAMETERFILE
Current alias directory path: RHYS/FLASHBACK
Current alias directory path: ASM
Current alias directory path: RHYS/AUTOBACKUP/2013_12_12
Current alias directory path: RHYS/ARCHIVELOG/2014_03_10
Current alias directory path: RHYS/TEMPFILE
Current alias directory path: RHYS/CONTROLFILE
Current alias directory path: RHYS/ARCHIVELOG/2014_02_24
Current alias directory path: RHYS/ARCHIVELOG/2014_03_06
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: RHYS/ARCHIVELOG/2014_03_11
Current alias directory path: RHYS/AUTOBACKUP
Current alias directory path: RHYS/ARCHIVELOG/2014_02_23
Current alias directory path: RHYS/DATAFILE
Current alias directory path: DUMMY
Current alias directory path: RHYS/ARCHIVELOG/2014_02_25
Current alias directory path: RHYS/ONLINELOG
如果需要备份指定磁盘组的元数据需要使用-G参数:
eg:
[sql] view
plain copy
ASMCMD [+] > md_backup /tmp/datagroup1_metadata_bak -G datagroup1
Disk group metadata to be backed up: DATAGROUP1
Current alias directory path: RHYS/ARCHIVELOG/2014_03_05
Current alias directory path: RHYS/ARCHIVELOG
Current alias directory path: RHYS/AUTOBACKUP/2014_01_13
Current alias directory path: RHYS
Current alias directory path: DUMMY/PARAMETERFILE
Current alias directory path: RHYS/FLASHBACK
Current alias directory path: ASM
Current alias directory path: RHYS/AUTOBACKUP/2013_12_12
Current alias directory path: RHYS/ARCHIVELOG/2014_03_10
Current alias directory path: RHYS/TEMPFILE
Current alias directory path: RHYS/CONTROLFILE
Current alias directory path: RHYS/ARCHIVELOG/2014_02_24
Current alias directory path: RHYS/ARCHIVELOG/2014_03_06
Current alias directory path: ASM/ASMPARAMETERFILE
Current alias directory path: RHYS/AUTOBACKUP
Current alias directory path: RHYS/ARCHIVELOG/2014_03_11
Current alias directory path: RHYS/ARCHIVELOG/2014_02_23
Current alias directory path: RHYS/DATAFILE
Current alias directory path: DUMMY
Current alias directory path: RHYS/ARCHIVELOG/2014_02_25
Current alias directory path: RHYS/ONLINELOG
ASMCMD [+] > exit
-bash-4.1$ cd /tmp
-bash-4.1$ ls -l
total 168
-rw-r--r-- 1 grid oinstall 20825 Mar 11 22:52 datagroup1_metadata_bak
-rw-r--r-- 1 grid oinstall 43275 Mar 11 22:51 dgback_rhys
drwx------ 2 root root 4096 Feb 10 16:17 keyring-2K68nK
drwx------ 2 grid oinstall 4096 Mar 10 22:24 keyring-A0oM7y
drwx------ 2 root root 4096 Feb 8 15:45 keyring-KWIBiM
drwx------ 2 root root 4096 Feb 10 16:08 keyring-sNYqVr
drwx------ 2 oracle oinstall 4096 Mar 10 22:24 keyring-SRn3Bp
drwx------ 2 root root 16384 Dec 2 00:19 lost+found
-rw-r--r-- 1 grid oinstall 43275 Mar 11 22:47 oracledgbackup
drwx------ 2 root root 4096 Feb 10 16:17 pulse-LeoMkmUKAZsW
drwx------ 2 gdm gdm 4096 Mar 10 21:08 pulse-meUziInFt6tt
drwx------ 2 grid oinstall 4096 Mar 10 22:26 pulse-tToPdZjzVK1H
drwx------ 2 grid oinstall 4096 Mar 10 21:08 virtual-grid.pJx8gu
drwx------ 2 oracle oinstall 4096 Mar 10 20:38 virtual-oracle.vdM37e
查看备份的元数据,其实就是磁盘组、磁盘名啊、路径啊等信息
eg:
[html] view
plain copy
-bash-4.1$ more datagroup1_metadata_bak <
6178e
/span>
@diskgroup_set = (
{
'ATTRINFO' => {
'_._DIRVERSION' => '11.2.0.0.0',
'COMPATIBLE.ASM' => '11.2.0.0.0',
'COMPATIBLE.RDBMS' => '11.2.0.0.0'
},
'DISKSINFO' => {
'DATAGROUP1_0003' => {
'DATAGROUP1_0003' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0003',
'NAME' => 'DATAGROUP1_0003',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK4'
}
},
'DATAGROUP1_0001' => {
'DATAGROUP1_0001' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0001',
'NAME' => 'DATAGROUP1_0001',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK2'
}
},
'DATAGROUP1_0002' => {
'DATAGROUP1_0002' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0002',
'NAME' => 'DATAGROUP1_0002',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK3'
}
},
'DATAGROUP1_0000' => {
'DATAGROUP1_0000' => {
'TOTAL_MB' => '4094',
'FAILGROUP' => 'DATAGROUP1_0000',
'NAME' => 'DATAGROUP1_0000',
'DGNAME' => 'DATAGROUP1',
'PATH' => '/dev/oracleasm/disks/ASMDISK1'
}
}
},
'DGINFO' => {
'DGTORESTORE' => 0,
'DGCOMPAT' => '11.2.0.0.0',
'DGNAME' => 'DATAGROUP1',
'DGDBCOMPAT' => '11.2.0.0.0',
'DGTYPE' => 'NORMAL',
'DGAUSZ' => '1048576'
},
'ALIASINFO' => {
'11' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'ASM/ASMPARAMETERFILE',
'REFERENCE_INDEX' => '16777322'
},
'7' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/TEMPFILE',
'REFERENCE_INDEX' => '16777852'
},
'2' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 0,
'ALIASNAME' => 'DUMMY',
'REFERENCE_INDEX' => '16777534'
},
'17' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_10',
'REFERENCE_INDEX' => '16778064'
},
'1' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 0,
'ALIASNAME' => 'RHYS',
'REFERENCE_INDEX' => '16777375'
},
'18' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_11',
'REFERENCE_INDEX' => '16778117'
},
'0' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 0,
'ALIASNAME' => 'ASM',
'REFERENCE_INDEX' => '16777269'
},
'16' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_06',
'REFERENCE_INDEX' => '16778753'
},
'13' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_02_24',
'REFERENCE_INDEX' => '16778912'
},
'6' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/ONLINELOG',
'REFERENCE_INDEX' => '16777481'
},
'3' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'DUMMY/PARAMETERFILE',
'REFERENCE_INDEX' => '16777587'
},
'9' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/AUTOBACKUP',
'REFERENCE_INDEX' => '16777799'
},
'12' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_02_23',
'REFERENCE_INDEX' => '16778965'
},
'20' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/AUTOBACKUP/2014_01_13',
'REFERENCE_INDEX' => '16778435'
},
'15' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_03_05',
'REFERENCE_INDEX' => '16778806'
},
'14' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/ARCHIVELOG/2014_02_25',
'REFERENCE_INDEX' => '16778859'
},
'8' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/ARCHIVELOG',
'REFERENCE_INDEX' => '16778700'
},
'4' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/CONTROLFILE',
'REFERENCE_INDEX' => '16777640'
},
'10' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/FLASHBACK',
'REFERENCE_INDEX' => '16778594'
},
'19' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 2,
'ALIASNAME' => 'RHYS/AUTOBACKUP/2013_12_12',
'REFERENCE_INDEX' => '16777905'
},
'5' => {
'DGNAME' => 'DATAGROUP1',
'LEVEL' => 1,
'ALIASNAME' => 'RHYS/DATAFILE',
'REFERENCE_INDEX' => '16777428'
}
},
'TEMPLATEINFO' => {
'11' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'AUTOBACKUP',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'7' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'PARAMETERFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'2' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'ARCHIVELOG',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'1' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'OCRFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'0' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'DATAFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'16' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'ONLINELOG',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'13' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'CHANGETRACKING',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'6' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'ASMPARAMETERFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'3' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'FLASHFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'9' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'BACKUPSET',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'12' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'XTRANSPORT',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'15' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'DATAGUARDCONFIG',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'14' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'FLASHBACK',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'8' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'TEMPFILE',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'4' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'FINE',
'TEMPNAME' => 'CONTROLFILE',
'REDUNDANCY' => 'HIGH',
'SYSTEM' => 'Y'
},
'10' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'XTRANSPORT BACKUPSET',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
},
'5' => {
'DGNAME' => 'DATAGROUP1',
'STRIPE' => 'COARSE',
'TEMPNAME' => 'DUMPSET',
'REDUNDANCY' => 'MIRROR',
'SYSTEM' => 'Y'
}
}
}
);
-bash-4.1$
删除磁盘组datagroup2 ,然后进行恢复:(此恢复仅仅是对应磁盘组来说的,而不是对应里面的数据,数据的恢复需要使用rman还原哦!——)
eg:
首先看一下md_restore帮助:
ASMCMD [+] > help md_restore
md_restore
This command restores a disk group metadata backup.
md_restore backup_file [--silent][--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup [,...]'][-S sql_script_file] [-G 'diskgroup [,diskgroup...]']
The options for the md_restore command are described below.
backup_file - Reads the metadata information from
backup_file.
--silent - Ignore errors. Normally, if md_restore
encounters an error, it will stop.
Specifying this flag ignores any errors.
--full - Specifies to create a disk group and restore
metadata.
--nodg - Specifies to restore metadata only.
--newdg -o old_diskgroup:new_diskgroup - Specifies to create a disk
group with a different name when restoring
metadata. The -o option is required
with --newdg.
-S sql_script_file - Write SQL commands to the specified SQL
script file instead of executing the commands.
-G diskgroup - Select the disk groups to be restored.
If no disk groups are defined, then all
disk groups will be restored.
The first example restores the disk group DATA from the backup script
and creates a copy. The second example takes an existing disk group
DATA and restores its metadata. The third example restores disk group
DATA completely but the new disk group that is created is called DATA2.
The fourth example restores from the backup file after applying the
overrides defined in the override.sql script file
ASMCMD [+] > md_restore --full -G data --silent /tmp/dgbackup20090714
ASMCMD [+] > md_restore --nodg -G data --silent /tmp/dgbackup20090714
ASMCMD [+] > md_restore --newdg -o 'data:data2' --silent /tmp/dgbackup20090714
ASMCMD [+] > md_restore -S override.sql --silent /tmp/dgbackup20090714
开始恢复:
eg:
[sql] view
plain copy
ASMCMD [+] > md_restore --full -G datagroup1 --silent /tmp/datagroup1_metadata_bak
Current Diskgroup metadata being restored: DATAGROUP1
ASMCMD-9352: CREATE DISKGROUP failed
ORA-15018: diskgroup cannot be created
ORA-15030: diskgroup name "DATAGROUP1" is in use by another diskgroup (DBD ERROR: OCIStmtExecute)
ASMCMD [+] > host;
提示磁盘组不能在线,删掉在做
[sql] view
plain copy
-bash-4.1$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.4.0 Production on Tue Mar 11 23:03:29 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Automatic Storage Management option
SQL> select group_number,name,state,type from v$asm_diskgroup order by 1;
GROUP_NUMBER NAME STATE TYPE
------------ ------------------------------ ----------- ------
1 DATAGROUP1 MOUNTED NORMAL
2 DATAGROUP2 MOUNTED NORMAL
3 DATAGROUP3 MOUNTED NORMAL
SQL> drop diskgroup datagroup2 including contents;
Diskgroup dropped.
SQL> exit
恢复datagroup2:
eg:
[sql] view
plain copy
ASMCMD [+] > md_restore --full -G datagroup2 /tmp/dgback_rhys
Current Diskgroup metadata being restored: DATAGROUP2
Diskgroup DATAGROUP2 created!
System template FLASHBACK modified!
System template PARAMETERFILE modified!
System template ARCHIVELOG modified!
System template ONLINELOG modified!
System template DATAFILE modified!
System template BACKUPSET modified!
System template XTRANSPORT modified!
System template ASMPARAMETERFILE modified!
System template FLASHFILE modified!
System template OCRFILE modified!
System template CHANGETRACKING modified!
System template XTRANSPORT BACKUPSET modified!
System template AUTOBACKUP modified!
System template TEMPFILE modified!
System template CONTROLFILE modified!
System template DATAGUARDCONFIG modified!
System template DUMPSET modified!
ASMCMD [+] > lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED NORMAL N 512 4096 1048576 16376 9758 4094 2832 0 N DATAGROUP1/
MOUNTED NORMAL N 512 4096 1048576 8188 8086 0 4043 0 N DATAGROUP2/
MOUNTED NORMAL N 512 4096 1048576 4076 3966 1019 1473 0 N DATAGROUP3/
ASMCMD [+] >
可以将恢复过程生成一个脚本而不是执行恢复需要使用-S参数
eg:
[sql] view
plain copy
ASMCMD [+] > md_restore --full -G datagroup2 -S res_datagroup2.sql /tmp/dgback_rhys
Current Diskgroup metadata being restored: DATAGROUP2
ASMCMD [+] > exit
-bash-4.1$ more res_datagroup2.sql
create diskgroup DATAGROUP2 NORMAL redundancy failgroup FG2 disk '/dev/oracleasm/disks/ASMDISK6' name DATAGROUP2_0002 size 4094M failgroup DATAGROUP2_0001 disk '/dev/o
racleasm/disks/ASMDISK5' name DATAGROUP2_0001 size 4094M ;
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "FLASHBACK" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "PARAMETERFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "ARCHIVELOG" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "ONLINELOG" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "DATAFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "BACKUPSET" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "XTRANSPORT" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "ASMPARAMETERFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "FLASHFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "OCRFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "CHANGETRACKING" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "XTRANSPORT BACKUPSET" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "AUTOBACKUP" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "TEMPFILE" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "CONTROLFILE" attributes (HIGH FINE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "DATAGUARDCONFIG" attributes (MIRROR COARSE);
alter diskgroup /*ASMCMD AMBR*/DATAGROUP2 alter template "DUMPSET" attributes (MIRROR COARSE);
可见元数据的恢复就是一些create 命令啊,alter命令啊。
that‘s all!
相关文章推荐
- oracle asm 磁盘头数据以及备份与恢复基础篇(二)
- Oracle 11G Rman备份ASM数据恢复到本地磁盘
- Oracle 11g单实例使用asm,并测试数据文件的迁移到其他磁盘组
- ORACLE ASM中查询表空间使用情况、数据文件路径、裸设备磁盘总大小剩余大小
- 如何查看以及清除Oracle ASM磁盘头部信息 推荐
- oracle中fdisk导致的ASM磁盘数据丢失的解决方法
- 使用rman在oracle ASM磁盘组之间移动数据文件
- oracle中fdisk导致的ASM磁盘数据丢失的解决方法
- [转自Oracle ACE-崔华]如何用AMDU从不能mount的ASM磁盘组中往外抽取数据文件
- AIX/HP UX/LINUX 上ORACLE ASM 添加磁盘
- Oracle - Oracle系统紧急故障处理(数据文件、日志文件以及表空间损坏的处理)
- 磁盘空间不足,在线移动Oracle的数据文件
- Oracle 删除数据后释放数据文件所占磁盘空间
- JAVA数据类型与DB2、Oracle、Sybase以及SQL Server对应关系
- oracle中number数据类型的存储以及最大值问题
- Oracle 中的大对象数据类型blob、clob、nclob的意义以及区别
- ORACLE 11G RAC ASM磁盘的三种冗余模式
- oracle直通车6关于rman备份恢复数据文件,以及创建分区表的实验
- AIX_HP UX_LINUX 上ORACLE ASM 添加磁盘
- Oracle ASM数据库故障数据恢复解决方案