ASM磁盘超过disk_repair_time导致磁盘状态为forcing
oracle asm磁盘在实际工作中,由于一些原因,可能会不可访问,有时造成磁盘组直接dismount,数据库重启,有时磁盘组状态没影响,还是mount。那么到底磁盘出现什么状况?会造成磁盘组dismount?在什么情况下磁盘组状态无影响?下面就做一些简单的验证。
fast mirror resync
说到上面这些,那不得不说asm的特性fast mirror resync。因为它和asm磁盘的状态息息相关。
当一个ASM磁盘不可用时,ASM会把它从磁盘组里移除吗?要看情况,通常取决于ASM版本和磁盘组的冗余级别。因为一个external冗余的磁盘组会直接被dismount,所以主要关注normal和high冗余磁盘组的情况。 ASM 10g版本,磁盘会被直接drop。从11gR1,一个磁盘不可用时会先被offline,此时disk repair计时器开始介入,如果计时器达到磁盘组DISK_REPAIR_TIME 属性值时,这个磁盘会从所属的磁盘组中drop掉。如果这个磁盘在计时器过期前恢复可用,那么它的状态会变回online,不会被drop。但是ASM是如何发现磁盘恢复可用又有什么机制将它恢复online呢?
啥叫 fast mirror resync
11g introduces new Scalability and Performance improvements for ASM, this is the case of ASM Fast Disk Resync Feature which quickly resynchronizes ASM disks within a disk group after transient disk path failures as long as the disk drive media is not corrupted. Any failures that render a failure group temporarily unavailable are considered transient failures. Disk path malfunctions, such as cable disconnections, host bus adapter or controller failures, or disk power supply interruptions, can cause transient failures. The duration of a fast mirror resync depends on the duration of the outage. The duration of a resynchronization is typically much shorter than the amount of time required to completely rebuild an entire ASM disk group.
–11g 为 ASM 引入了新的可扩展性和性能改进,这就是 ASM 快速磁盘重新同步功能的情况,只要磁盘驱动器介质没有损坏,它就会在瞬时磁盘路径故障后快速重新同步磁盘组中的 ASM 磁盘。任何导致故障组暂时不可用的故障都被视为暂时故障。磁盘路径故障,例如电缆断开、主机总线适配器或控制器故障,或者磁盘电源中断,都可能导致瞬时故障。快速镜像重新同步的持续时间取决于中断的持续时间。重新同步的持续时间通常比完全重建整个 ASM 磁盘组所需的时间短得多。当一个磁盘离线时,oracle 引擎不会平衡其他磁盘,而是跟踪在中断期间修改的分配单元。故障磁盘中存在的内容由其他磁盘跟踪,对故障磁盘内容所做的任何修改实际上都是在其他可用磁盘中进行的。一旦磁盘恢复并且online,属于该磁盘并在此期间被修改的数据将再次重新同步。这避免了繁重的rebalance。
为什么出现 fast mirror resync
在ASM 10G时,ASM会立即Drop变成不可用的磁盘。这会触发一个尝试恢复数据冗余的重平衡操作。一旦重平衡过程完成,数据冗余度会恢复,同时磁盘会被移除出磁盘组。一旦磁盘不可用的故障被解决,可以通过alter diskgroup命令将磁盘重新添加回磁盘组。 例如:alter diskgroup DATA add disk ‘name’; 这又会再次触发一个重平衡操作,一旦重平衡过程完成,磁盘会恢复成为磁盘组成员。
在oracle 10g ASM 中,如果发生磁盘故障(光纤故障,控制器故障,HBA卡故障或其它故障造成ASM磁盘无法访问)时,ASM实例自动将该故障磁盘drop掉。
磁盘组冗余模式为Normal或High的环境,当ASM磁盘被drop后,触发ASM磁盘组的重平衡动作,保证被drop的磁盘上涉及的extent的再次冗余。在ASM重平衡非常消耗时间和磁盘IO操作。在某些场景需要短暂offline某些磁盘时,触操drop操作,那么会触发重平衡,添加回来的时候再次触发重平衡,这种情形非常不友好。而且在重平衡的因此,在11g版本,提供了ASM快速磁盘同步特性(ASM Fast Mirror Resync)。
ASM fast disk resync significantly reduces the time required to resynchronize a transient failure of a disk. When a disk goes offline following a transient failure, ASM tracks the extents that are modified during the outage. When the transient failure is repaired, ASM can quickly resynchronize only the ASM disk extents that have been affected during the outage
–ASM 快速磁盘重新同步显着减少了重新同步磁盘瞬时故障所需的时间。当磁盘因暂时性故障而脱机时,ASM 会跟踪在中断期间修改的区。当暂时性故障修复后,ASM 可以快速重新同步仅在中断期间受到影响的 ASM 磁盘区。.
1)短暂磁盘故障,避免rebalance耗时和耗资源的过程
2)省时省资源
fast mirror resync使用场景
磁盘临时短暂故障,例如电缆断开、主机总线适配器或控制器故障,或者磁盘电源中断,都可能导致瞬时故障。
磁盘短暂故障恢复后,磁盘online,不用rebalance,直接从其他正常盘读取故障时的修改,应用到故障盘上面。
disk repair time是给计划性offline磁盘使用的,不是给磁盘损坏用的
fast mirror resync必须条件
- This feature requires that the redundancy level for the disk should be set to NORMAL or HIGH.
- compatible.asm & compatible.rdbms = 11.1.0.0.0 or higher --磁盘组COMPATIBLE参数影响到磁盘组的格式,元数据,AU等
- You need to set DISK_REPAIR_TIME parameter, which gives the time it takes for the disk to get repaired. The default time for this is set to 3.6 hours.
不可用场景
the disk drive media is not corrupted
如果是磁盘自身故障(DG冗余模式为Norma/High),这个磁盘必须drop,添加磁盘后,oracle会自动rebalance。如果冗余模式为external,磁盘出故障时,磁盘组会离线,要通过备份来恢复数据库。Exadata冗余度至少为Normal,是通过在ASM级别中mirror,所以等cell节点任何一个节点down机,不影响数据库的正常使用。
测试场景
构建测试环境:
创建磁盘组
SQL> create diskgroup testdg normal redundancy disk '/dev/asm_arch01','/dev/asm_arch02','/dev/asm_arch03' ATTRIBUTE 'compatible.asm'='11.2';
Diskgroup created.
SQL> select GROUP_NUMBER,DISK_NUMBER,name,path,STATE,HEADER_STATUS,MODE_STATUS,FREE_MB,TOTAL_MB,FAILGROUP from v$asm_disk where GROUP_NUMBER !=1;
GROUP_NUMBER DISK_NUMBER NAME PATH STATE HEADER_STATU MODE_ST FREE_MB TOTAL_MB FAILGROUP
------------ ----------- ------------------------------ -------------------- -------- ------------ ------- ---------- ---------- ------------------------------
2 0 TESTDG_0000 /dev/asm_arch01 NORMAL MEMBER ONLINE 3019 3072 TESTDG_0000
2 2 TESTDG_0002 /dev/asm_arch03 NORMAL MEMBER ONLINE 1995 2048 TESTDG_0002
2 1 TESTDG_0001 /dev/asm_arch02 NORMAL MEMBER ONLINE 1995 2048 TESTDG_0001
创建表空间,灌入数据:
SQL> create tablespace test datafile '+testdg' size 500m;
Tablespace created.
SQL> create table test tablespace test as select * from dba_objects;
Table created.
SQL> insert into test select * from test;
18334 rows created.
SQL> /
36668 rows created.
SQL> /
73336 rows created.
SQL> insert into test select * from test;
146672 rows created.
SQL> /
293344 rows created.
SQL> /
586688 rows created.
SQL> commit;
Commit complete.
SQL> select sum(bytes)/1024/1024 from dba_segments where segment_name='TEST';
SUM(BYTES)/1024/1024
--------------------
128
开启fast mirror resync
1)开启该功能需要针对磁盘组设置disk_repair_time的值。默认是3.6h
为了测试,设置disk_repair_time为5分钟,m代表分钟,h代表小时,如果不输单位,默认是小时
2)compatible.asm & compatible.rdbms = 11.1.0.0.0 or higher
[grid@11gasm ~]$ asmcmd lsattr -G testdg -ml
Group_Name Name Value RO Sys
TESTDG access_control.enable