ITPub博客

如何理解ASM里FAILGROUP的概念

原创 IT综合 作者:warehouse 时间:2011-02-06 23:40:13 0 删除 编辑

FAILGROUP在asm里是一个非常重要的概念,oracle在doc上又交待的似乎不够清楚。

下面这篇文章是小V的总结,大家也可以参考:

http://www.itpub.net/viewthread.php?tid=1348104&extra=&highlight=failgroup&page=1

[@more@]

SQL> select group_number,name,type from v$asm_diskgroup;

GROUP_NUMBER NAME TYPE
------------ ---------- ------------
1 DG1 NORMAL
2 DG2 EXTERN

SQL> select group_number,disk_number,total_mb,free_mb,name,failgroup from v$asm_disk order by group_number,disk_number,failgroup;

GROUP_NUMBER DISK_NUMBER TOTAL_MB FREE_MB NAME FAILGROUP
------------ ----------- ---------- ---------- ---------- ----------
1 0 1024 560 DG1_0000 DG1_0001
1 1 1024 558 DG1_0001 DG1_0001
1 2 2048 1120 DG1_0002 DG1_0002
2 0 1024 42 DG2_0000 DG2_0000

SQL>
--======================
SQL> select file_name,bytes from dba_data_FILES;

FILE_NAME BYTES
--------------------------------------------- ----------
+DG1/asmdb/datafile/test/system01.dbf 314572800
+DG1/asmdb/datafile/undotbs1.263.741435561 209715200
+DG1/asmdb/datafile/sysaux.264.741435571 125829120
+DG1/asmdb/datafile/users.266.741435583 5242880
+DG1/asmdb/datafile/test.dbf 10485760

SQL>
--===============================
以表空间users对应的文件+DG1/asmdb/datafile/users.266.741435583为
例子来看asm file在disk上的data分布以及failgroup的作用和意义
--===============================
SQL> select group_kffxp,xnum_kffxp,lxn_kffxp,disk_kffxp,failgroup
2 from x$kffxp x,v$asm_disk d
3 where number_kffxp=266 and group_kffxp=1
4 and d.disk_number=x.disk_kffxp
5 and d.group_number=x.group_kffxp
6 ;

GROUP_KFFXP XNUM_KFFXP LXN_KFFXP DISK_KFFXP FAILGROUP
----------- ---------- ---------- ---------- ----------
1 0 1 2 DG1_0002
1 3 0 2 DG1_0002
1 4 1 2 DG1_0002
1 2 0 2 DG1_0002
1 5 1 2 DG1_0002
1 1 1 2 DG1_0002
1 1 0 1 DG1_0001
1 3 1 1 DG1_0001
1 4 0 1 DG1_0001
1 2 1 0 DG1_0001
1 0 0 0 DG1_0001
1 5 0 0 DG1_0001

已选择12行。

SQL>
--=======================================
x$kffxp全部字段可以参考https://twiki.cern.ch/twiki/bin/view/PDBService/ASM_Internals
x$kffxp里面的字段XNUM_KFFXP是组成asm file的au(allocate unit)的编号
LXN_KFFXP表示asm file对应的data copy的编号,0表示primary,1表示mirror
DISK_KFFXP表示disk number
从上面的查询我们可以清楚的看到au是在2个FAILGROUP:DG1_0001和DG1_0002上各自
分配了6个,其实每个asm file的file header占用1个au,这样由于diskgroup dg1是
normal方式,因此其实metadata使用了2m的空间,剩下10m正好对应的是文件
+DG1/asmdb/datafile/users.266.741435583 的大小,文件本身是5m,由于做了mirror,所以
是10m,但是这10m是平均分布在2个FAILGROUP里,不管这个FAILGROUP里包含了多少块disk,只要
1个FAILGROUP是好用的,那么db就可以正常使用,所以其实FAILGROUP是au和disk之间的逻辑概念
--=======================================
SQL> create diskgroup dg3 external redundancy failgroup fg1 disk 'g:asmdiskdisk5' name disk5;
create diskgroup dg3 external redundancy failgroup fg1 disk 'g:asmdiskdisk5' name disk5
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15067: command or option incompatible with diskgroup redundancy


SQL> create diskgroup dg3 external redundancy disk 'g:asmdiskdisk5' name disk5;

Diskgroup created.

SQL> create diskgroup dg4 normal redundancy failgroup fg1 disk 'g:asmdiskdisk6' name disk6;
create diskgroup dg4 normal redundancy failgroup fg1 disk 'g:asmdiskdisk6' name disk6
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15072: command requires at least 2 failure groups, discovered only 1


SQL> create diskgroup dg4 normal redundancy failgroup fg1 disk 'g:asmdiskdisk6' name disk6 failgroup fg2 disk 'g:asmdiskdisk7' name disk7;

Diskgroup created.

SQL> select group_number,failgroup from v$asm_disk;

GROUP_NUMBER FAILGROUP
------------ ----------
0
1 DG1_0002
1 DG1_0001
2 DG2_0000
1 DG1_0001
3 DISK5
4 FG1
4 FG2

8 rows selected.

SQL>
SQL> alter diskgroup dg3 add failgroup disk5 disk 'G:asmdiskDISK8' name disk8;
alter diskgroup dg3 add failgroup disk5 disk 'G:asmdiskDISK8' name disk8
*
ERROR at line 1:
ORA-15067: command or option incompatible with diskgroup redundancy


SQL> alter diskgroup dg3 add disk 'G:asmdiskDISK8' name disk8;

Diskgroup altered.

SQL>
SQL> select group_number,failgroup from v$asm_disk order by group_number;

GROUP_NUMBER FAILGROUP
------------ ----------
1 DG1_0002
1 DG1_0001
1 DG1_0001
2 DG2_0000
3 DISK8
3 DISK5
4 FG1
4 FG2

8 rows selected.

SQL>
--==========================
SQL> create tablespace test1 datafile '+dg3/test1.dbf' size 5m;

表空间已创建。

SQL>
--==========================
ASMCMD> pwd
+dg3
ASMCMD> ls
ASMDB/
test1.dbf
ASMCMD> ls -l test1.dbf
Type Redund Striped Time Sys Name
N test1.dbf => +DG3/ASMDB/DATAFILE/TEST1.256.742432737
ASMCMD>
--==================================
SQL> select group_kffxp,xnum_kffxp,lxn_kffxp,disk_kffxp,failgroup
2 from x$kffxp x,v$asm_disk d
3 where number_kffxp=256 and group_kffxp=3
4 and d.disk_number=x.disk_kffxp
5 and d.group_number=x.group_kffxp
6 ;

GROUP_KFFXP XNUM_KFFXP LXN_KFFXP DISK_KFFXP FAILGROUP
----------- ---------- ---------- ---------- ----------
3 0 0 0 DISK5
3 2 0 0 DISK5
3 4 0 0 DISK5
3 3 0 1 DISK8
3 5 0 1 DISK8
3 1 0 1 DISK8

6 rows selected.

SQL>
--===================================
oracle要求
A normal redundancy disk group must contain at least two failure groups.
A high redundancy disk group must contain at least three failure groups.
external redundancy在语法上不支持或者说不提供failgroup,但是事实上oracle内部
还是给每一个disk分配了1个failgroup,只不过external redundancy这种方式的diskgroup
里不管有多少块disk,也不管有多少个failgroup(最终当然是1个disk oracle给对应了一个
failgroup),只要一个failgroup包含的disk出现问题,最终使用该diskgroup的db都会出现问题,
因为该failgroup里包含的disk上的data没有任何mirror。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/19602/viewspace-1045623/,如需转载,请注明出处,否则将追究法律责任。

上一篇: EM和动态ip
请登录后发表评论 登录
全部评论

注册时间:2007-12-07

  • 博文量
    715
  • 访问量
    5058952