Where is the backup of ASM disk header block? –补充
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
Kamus在他的博客提到,从Oracle 10.2.0.5开始,ASM磁盘已经开始自动将头块进行备份,
备份块的位置在第2个AU的倒数第2个块上(对于默认1M的AU来说,是第510个块),如果
头块损坏,可以用kfed repair命令来修复。详见链接地址:Where is the backup of ASM disk header block?
他这里说明了1m和8m的情况,我将au size分别为2m,4m,16m,32m,64m进行了补充。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
SQL> SELECT 2 name group_name 3 , sector_size sector_size 4 , block_size block_size 5 , allocation_unit_size allocation_unit_size 6 , state state 7 , type type 8 , total_mb total_mb 9 , (total_mb - free_mb) used_mb 10 , ROUND((1- (free_mb / total_mb))*100, 2) pct_used 11 FROM 12 v$asm_diskgroup 13 ORDER BY 14 name 15 / Disk Group Sector Block Allocation Name Size Size Unit Size State Type Total Size (MB) Used Size (MB) Pct. Used -------------------- ------- ------- ------------ ----------- ------ --------------- -------------- --------- DATA1 512 4,096 1,048,576 MOUNTED EXTERN 4,096 2,059 50.27 DATA2 512 4,096 2,097,152 MOUNTED EXTERN 2,048 60 2.93 DATA3 512 4,096 4,194,304 MOUNTED EXTERN 2,048 80 3.91 --------------- -------------- Grand Total: 8,192 2,199 SQL> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
SQL> SELECT 2 a.name disk_group_name 3 , b.path disk_path 4 , b.reads reads 5 , b.writes writes 6 , b.read_errs read_errs 7 , b.write_errs write_errs 8 , b.read_time read_time 9 , b.write_time write_time 10 , b.bytes_read bytes_read 11 , b.bytes_written bytes_written 12 FROM 13 v$asm_diskgroup a JOIN v$asm_disk b USING (group_number) 14 ORDER BY 15 a.name 16 / Read Write Read Write Bytes Bytes Disk Group Name Disk Path Reads Writes Errors Errors Time Time Read Written -------------------- -------------------- ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- DATA1 /dev/sdd 29,418 14,440 0 0 714 226 437,492,736 143,610,880 ******************** ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- 29,418 14,440 0 0 714 226 437,492,736 143,610,880 DATA2 /dev/sdb 80 191 0 0 0 4 331,776 782,336 ******************** ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- 80 191 0 0 0 4 331,776 782,336 DATA3 /dev/sdc 77 131 0 0 0 4 319,488 536,576 ******************** ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- 77 131 0 0 0 4 319,488 536,576 ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- Grand Total: 29,575 14,762 0 0 715 235 438,144,000 144,929,792 |
DATA1:AU size -1m
1 2 3 |
[ora11g@11gR2test ~]$ kfed read /dev/sdd blknum=510|grep kfbh.type kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD [ora11g@11gR2test ~]$ |
DATA2:AU size -2m
1 2 3 4 5 6 |
按照计算,每个1m AU存256个block,那么2M的AU,可以容纳512个block,那么 第一个au block范围是0~511,第2个AU block 范围是512~1023,那么倒数第2个block就是1022. [ora11g@11gR2test ~]$ kfed read /dev/sdb blknum=1022|grep kfbh.type kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD [ora11g@11gR2test ~]$ |
DATA3:AU size -4m
1 2 3 4 5 6 |
以此类推,对于4m大小的au,那么每个au容纳1024个block,第一个AU的block范围为0~1023, 那么第2个AU的block范围是1024~2047.那么倒数第2个block就是2046. [ora11g@11gR2test ~]$ kfed read /dev/sdc blknum=2046|grep kfbh.type kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD [ora11g@11gR2test ~]$ |
下面我把DATA2,DATA3 drop重建为AU size分别为16m,32m的diskgroup。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
SQL> drop diskgroup DATA2; Diskgroup dropped. SQL> drop diskgroup DATA3; Diskgroup dropped. SQL> create diskgroup data2 external redundancy disk '/dev/sdb' ATTRIBUTE 'au_size' = '16M'; Diskgroup created. SQL> create diskgroup data3 external redundancy disk '/dev/sdc' ATTRIBUTE 'au_size' = '32M'; create diskgroup data3 external redundancy disk '/dev/sdc' ATTRIBUTE 'au_size' = '32M' * ERROR at line 1: ORA-15018: diskgroup cannot be created ORA-15239: allocation unit size higher than 16777216 requires RDBMS compatibility 11.1.0.0.0 SQL> create diskgroup data3 external redundancy disk '/dev/sdc' 2 attribute 'compatible.rdbms'='11.2.0.0', 'compatible.asm'='11.2.0.0', 'au_size'='32M'; Diskgroup created. SQL> SQL> SELECT 2 name group_name 3 , sector_size sector_size 4 , block_size block_size 5 , allocation_unit_size allocation_unit_size 6 , state state 7 , type type 8 , total_mb total_mb 9 , (total_mb - free_mb) used_mb 10 , ROUND((1- (free_mb / total_mb))*100, 2) pct_used 11 FROM 12 v$asm_diskgroup 13 ORDER BY 14 name 15 / Disk Group Sector Block Allocation Name Size Size Unit Size State Type Total Size (MB) Used Size (MB) Pct. Used -------------------- ------- ------- ------------ ----------- ------ --------------- -------------- --------- DATA1 512 4,096 1,048,576 MOUNTED EXTERN 4,096 2,059 50.27 DATA2 512 4,096 16,777,216 MOUNTED EXTERN 2,048 160 7.81 DATA3 512 4,096 33,554,432 MOUNTED EXTERN 2,048 352 17.19 --------------- -------------- Grand Total: 8,192 2,571 SQL> |
此时DATA2 磁盘组AU size为16m,DATA3 AU size为32M。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
SQL> SELECT 2 a.name disk_group_name 3 , b.path disk_path 4 , b.reads reads 5 , b.writes writes 6 , b.read_errs read_errs , b.write_errs write_errs 7 8 , b.read_time read_time 9 , b.write_time write_time 10 , b.bytes_read bytes_read 11 , b.bytes_written bytes_written 12 FROM 13 v$asm_diskgroup a JOIN v$asm_disk b USING (group_number) 14 ORDER BY 15 a.name 16 / Read Write Read Write Bytes Bytes Disk Group Name Disk Path Reads Writes Errors Errors Time Time Read Written -------------------- -------------------- ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- DATA1 /dev/sdd 31,853 17,935 0 0 719 236 483,048,448 178,654,720 ******************** ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- 31,853 17,935 0 0 719 236 483,048,448 178,654,720 DATA2 /dev/sdb 63 563 0 0 0 7 262,144 2,306,048 ******************** ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- 63 563 0 0 0 7 262,144 2,306,048 DATA3 /dev/sdc 220 106 0 0 2 4 905,216 434,176 ******************** ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- 220 106 0 0 2 4 905,216 434,176 ------------ ------------ -------- -------- ------------ ------------ ---------------- ---------------- Grand Total: 32,136 18,604 0 0 721 247 484,215,808 181,394,944 SQL> |
DATA2:
根据前面的推论,此时每个AU 可以容纳 4096个block,那么此时第1个AU block 范围
为0~4095,第2个AU block范围就是4095~8191,所以第2个AU 倒数第2个block就是8190.
1 2 3 |
[ora11g@11gR2test ~]$ kfed read /dev/sdb blknum=8190|grep kfbh.type kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD [ora11g@11gR2test ~]$ |
DATA3:
同理,32M的AU 包含8192个block,第2个AU 倒数第2个block为16382.
1 2 3 |
[ora11g@11gR2test ~]$ kfed read /dev/sdc blknum=16382|grep kfbh.type kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD [ora11g@11gR2test ~]$ |
最后再看看11gR2 中最大AU size为64M的情况:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
SQL> create diskgroup data2 external redundancy disk '/dev/sdb' 2 attribute 'compatible.rdbms'='11.2.0.0', 'compatible.asm'='11.2.0.0', 'au_size'='64M'; Diskgroup created. SQL> SELECT 2 name group_name 3 , sector_size sector_size 4 , block_size block_size 5 , allocation_unit_size allocation_unit_size 6 , state state 7 , type type 8 , total_mb total_mb 9 , (total_mb - free_mb) used_mb 10 , ROUND((1- (free_mb / total_mb))*100, 2) pct_used 11 FROM 12 v$asm_diskgroup 13 ORDER BY 14 name 15 / Disk Group Sector Block Allocation Name Size Size Unit Size State Type Total Size (MB) Used Size (MB) Pct. Used -------------------- ------- ------- ------------ ----------- ------ --------------- -------------- --------- DATA1 512 4,096 1,048,576 MOUNTED EXTERN 4,096 2,059 50.27 DATA2 512 4,096 67,108,864 MOUNTED EXTERN 2,048 640 31.25 DATA3 512 4,096 33,554,432 MOUNTED EXTERN 2,048 352 17.19 --------------- -------------- Grand Total: 8,192 3,051 SQL> |
此是AU size为64m的情况下,第2个au 倒数第2个block为32766。
1 2 3 |
[ora11g@11gR2test ~]$ kfed read /dev/sdb blknum=32766|grep kfbh.type kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD [ora11g@11gR2test ~]$ |
验证了kamus的观点,对于10.2.0.5.0以及以后版本,asm disk header自动存储的位置是第2个au的倒数第2个block。
不管au size是多少,位置都是一样的。
One Response to “Where is the backup of ASM disk header block? –补充”
谢谢你的补充 😀
Leave a Reply
You must be logged in to post a comment.