sitemap

RSS地图

收藏本站

设为首页

Oracle研究中心

当前位置:Oracle研究中心 > 运维DBA >

【学习笔记】Oracle ASM头坏header block自动备份修复步骤笔记

时间:2016-12-01 22:41   来源:Oracle研究中心   作者:网络   点击:

天萃荷净 Oracle研究中心学习笔记:分享一篇关于Oracle数据库ASM磁盘管理的文章,详细介绍从Oracle 10.2.0.5开始,ASM磁盘已经开始自动将头块进行备份,备份块的位置在第2个AU的倒数第2个块上。

本站文章除注明转载外,均为本站原创: 转载自love wife & love life —Roger 的Oracle技术博客
本文链接地址: Where is the backup of ASM disk header block –补充

从Oracle 10.2.0.5开始,ASM磁盘已经开始自动将头块进行备份,备份块的位置在第2个AU的倒数第2个块上(对于默认1M的AU来说,是第510个块),如果头块损坏,可以用kfed repair命令来修复。

他这里说明了1m和8m的情况,我将au size分别为2m,4m,16m,32m,64m进行了补充

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>   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
********************                      ------------ ------------ -------- -------Oracleо- ------------ ------------ ---------------- ----------------
                                                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

[ora11g@11gR2test ~]$ kfed read /dev/sdd blknum=510|grep kfbh.type
kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD
[ora11g@11gR2test ~]$
DATA2:AU size -2m

按照计算,每个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

以此类推,对于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。

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>   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



此时DATA2 磁盘组AU size为16m,DATA3 AU size为32M。

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.

[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.

[ora11g@11gR2test ~]$ kfed read /dev/sdc blknum=16382|grep kfbh.type
kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD
[ora11g@11gR2test ~]$
最后再看看11gR2 中最大AU size为64M的情况:

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


此是AU size为64m的情况下,第2个au 倒数第2个block为32766。

[ora11g@11gR2test ~]$ kfed read /dev/sdb blknum=32766|grep kfbh.type
kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD

验证了kamus的观点,对于10.2.0.5.0以及以后版本,asm disk header自动存储的位置是第2个au的倒数第2个block。

不管au size是多少,位置都是一样的。

--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之【学习笔记】Oracle ASM头坏header block自动备份修复步骤笔记

本文由大师惜分飞原创分享,网址:http://www.oracleplus.net/arch/1355.html

Oracle研究中心

关键词:

Oracle ASM kfed repair修复笔记

backup of ASM disk header block

Oracle ASM磁盘头自动备份原理

Oracle ASM header block kfed repair