Oracle ASM 的redundancy與failgroup

531968912發表於2017-10-18

redundancy與failgroup

 

1.關於redundancy 與fail group官方說明

 

 

REDUNDANCYClause

The REDUNDANCY clause lets you specify theredundancy level of the disk group.

  • NORMAL REDUNDANCY requires the existence of at least two failure groups (see the FAILGROUP clause that follows). Oracle ASM provides redundancy for all files in the disk group according to the attributes specified in the disk group templates. NORMAL REDUNDANCY disk groups can tolerate the loss of one group. Refer to ALTER DISKGROUP ... diskgroup_template_clauses for more information on disk group templates.

NORMAL REDUNDANCY is the default if you omitthe REDUNDANCY clause.Therefore, if you omit this clause, you must create at least two failuregroups, or the create operation will fail.

  • HIGH REDUNDANCY requires the existence of at least three failure groups. Oracle ASM fixes mirroring at 3-way mirroring, with each extent getting two mirrored copies. HIGH REDUNDANCY disk groups can tolerate the loss of two failure groups.
  • EXTERNAL REDUNDANCY indicates that Oracle ASM does not provide any redundancy for the disk group. The disks within the disk group must provide redundancy (for example, using a storage array), or you must be willing to tolerate loss of the disk group if a disk fails (for example, in a test environment). You cannot specify the FAILGROUP clause if you specify EXTERNAL REDUNDANCY.

FAILGROUPClause

·        Use this clause to specify a name for one or more failuregroups. If you omit this clause, and you have specified NORMAL or HIGH REDUNDANCY, then Oracle Database automatically adds each disk in thedisk group to its own failure group. The implicit name of the failure groupis the same as the operating system independent disk name (see ).

·        You cannot specify this clause if you are creating an EXTERNAL REDUNDANCY disk group.

 

2.說明

         一直在使用ASM,這2個概念也是經常用到,但有時有些混亂,搞不清楚它們之間的關係。今天透過實驗來理一下思路。

redundancy

指的是diskgroup的failgroup的冗餘級別(注意並不是disk的冗餘),冗餘透過failgroup實現。

Normal: 至少要2個failgroup。

Diskgroup的可用大小:如果是2個或3個failgroup組,則是(單個failgroup的大小)-(mirror消耗/fiailgroup數)的大小。如果是4個,則是上面的結果的2倍。

 

High:       至少要3個failgroup。

Diskgroup的可用大小:如果是3個或小於6個failgroup組,則是(單個failgroup的大小)-(mirror消耗/fiailgroup數)的大小。如果是6個,則是上面的結果的2倍。

 

 

External :          ASM級不使用冗餘。Diskgroup的可用大小等於所有disk的和。

 

在external可以指定failgroup嗎?

·        Youcannot specify this clause if you are creating an EXTERNAL REDUNDANCY disk group.

failgroup:

上面normal和high時要用到,也可以不明確寫,不指定時,每1個disk當成1個failgroup。

 

3.相關檢視說明:

V$asm_diskgroup檢視中部分欄位說明

GROUP_NUMBER NAME            TOTAL_MBREQUIRED_MIRROR_FREE_MB    FREE_MBUSABLE_FILE_MB ALLOCATION_UNIT_SIZE

------------ ------------- --------------------------------- ---------- -------------- --------------------

 

Total_MB就是diskgroup裡所有的disk的空間總和,和mirror沒有任何關係
Free_MB是diskgroup裡所有的disk的free空間總和,和mirror也沒有任何關係
REQUIRED_MIRROR_FREE_MB考慮了mirorr,是指為了使diskgroup能在一個或多個磁碟損壞後能夠restore冗餘(redundancy),磁碟組中應該保留的剩餘空間.

USABLE_FILE_MB:當前實際可以用的空間,此大小是映象完後的大小再減去已經使用的大小。

 

TOTAL_MB NUMBER Total capacity of the diskgroup (in megabytes) 
FREE_MB NUMBER Unused capacity of the disk group (in megabytes) 
REQUIRED_MIRROR_FREE_MB NUMBER Amount of space that is required to be availablein a given disk group in order to restore redundancy after one or more diskfailures. The amount of space displayed in this column takes mirroring effectsinto account. 
USABLE_FILE_MB NUMBER Amount of free space that can be safely utilized takingmirroring into account, and yet be able to restore redundancy after a diskfailure 

 

4.實驗測試:

共有9塊盤用於測試,從/dev/asm-diske到/dev/asm-diskm  。每塊的大小均為1G。

[grid@OEL63 grid]$ sqlplus / as sysasm

col GROUP_NUMBER for 999

col DISK_NUMBER for 999

col NAME for a13

col FAILGROUP for a13

col PATH for a20

set lines 1000

 

SQL> select * from V$version;

Oracle Database 11g Enterprise EditionRelease 11.2.0.3.0 - 64bit Production

PL/SQL Release 11.2.0.3.0 - Production

CORE   11.2.0.3.0      Production

TNS for Linux: Version 11.2.0.3.0 -Production

NLSRTL Version 11.2.0.3.0 - Production

EXTERNAL

 

SQL> create diskgroup data1  external redundancy disk '/dev/asm-diske';

SQL> create diskgroup data2external redundancy disk '/dev/asm-diskf','/dev/asm-diskg';

SQL> create diskgroup data3 external redundancy disk'/dev/asm-diskh','/dev/asm-diski','/dev/asm-diskj';

 

SQL> select group_number,name, TOTAL_MB, REQUIRED_MIRROR_FREE_MB, FREE_MB , USABLE_FILE_MB,ALLOCATION_UNIT_SIZE fromV$asm_diskgroup;


 

SQL> select group_number,disk_number,name,failgroup,create_date,path fromv$asm_disk order by  FAILGROUP;

 疑惑:normal下為何為生成不同的failgroup組名?

 

 

External下不支援failgroup

 

SQL> create diskgroup data2b externalredundancy failgroup fail1 disk '/dev/asm-diskf','/dev/asm-diskg';

create diskgroup data2b external redundancyfailgroup fail1 disk '/dev/asm-diskf','/dev/asm-diskg'

*

ERROR at line 1:

ORA-15018: diskgroup cannot be created

ORA-15067: command or option incompatiblewith diskgroup redundancy

SQL> create diskgroup data2b externalredundancy failgroup fail1 disk '/dev/asm-diskf','/dev/asm-diskg'

 2  failgroup fail2 disk'/dev/asm-diskm','/dev/asm-diskj';

create diskgroup data2b external redundancyfailgroup fail1 disk '/dev/asm-diskf','/dev/asm-diskg'

*

ERROR at line 1:

ORA-15018: diskgroup cannot be created

ORA-15067: command or option incompatiblewith diskgroup redundancy

 

NORMAL

不指明failgroup建立不同的磁碟組

drop diskgroup data1;

drop diskgroup data2;

drop diskgroup data3;

SQL> create diskgroup datan1 normalredundancy disk '/dev/asm-diske','/dev/asm-diskf';

SQL> create diskgroup datan2 normalredundancy

disk '/dev/asm-diskg','/dev/asm-diskh','/dev/asm-diski';

SQL> create diskgroup datan3 normalredundancy

disk '/dev/asm-diskj','/dev/asm-diskk','/dev/asm-diskl','/dev/asm-diskm';

檢視大小

SQL> select group_number,name, TOTAL_MB, REQUIRED_MIRROR_FREE_MB, FREE_MB , USABLE_FILE_MB,ALLOCATION_UNIT_SIZE fromV$asm_diskgroup;

再來看看使用後的變化情況

SQL> create tablespace data3 datafile '+DATAN3/QING/datafile/data301.dbf'size 10m;

SQL> conn tan/tan

SQL> create table test1 tablespace data3as select * from dba_objects;

檢視failgroup

SQL> selectgroup_number,disk_number,name,failgroup,create_date,path

from v$asm_disk order by  FAILGROUP;

不明確寫明failgroup時,將為每 1個磁碟建立1failgroup組。

 

指明failgroup建立不同的磁碟組

SQL> drop tablespace data3 includingcontents and datafiles;

drop diskgroup datan1;

drop diskgroup datan2;

drop diskgroup datan3;

 

SQL> create diskgroup datan1 normalredundancy

   failgroup faildg1 disk '/dev/asm-diske' name fail1

   failgroup faildg2 disk '/dev/asm-diskf' name fail2;

 

SQL> create diskgroup datan2 normalredundancy

   failgroup faildg1 disk '/dev/asm-diskg' namefail1

   failgroup faildg2 disk '/dev/asm-diskh' namefail2

   failgroup faildg3 disk '/dev/asm-diski' namefail3;  

 

SQL> create diskgroup datan3 normalredundancy

    failgroup fail1 disk '/dev/asm-diskm','/dev/asm-diskj'

failgroup fail2disk '/dev/asm-diskk','/dev/asm-diskl';

 

drop前做一次查詢,查詢結果在後面一起列出。

drop diskgroup datan1;

drop diskgroup datan2;

drop diskgroup datan3;

 

SQL> create diskgroup datan4 normalredundancy

   failgroup faildg1 disk '/dev/asm-diskg' namefail1

   failgroup faildg2 disk '/dev/asm-diskh' namefail2

   failgroup faildg3 disk '/dev/asm-diski' namefail3

failgroup faildg4 disk '/dev/asm-diske' name fail4;  

 

檢視failgroup

SQL> selectgroup_number,disk_number,name,failgroup,create_date,path

from v$asm_disk order by  group_number;

檢視大小

SQL> select group_number,name, TOTAL_MB, REQUIRED_MIRROR_FREE_MB, FREE_MB , USABLE_FILE_MB,ALLOCATION_UNIT_SIZE fromV$asm_diskgroup;

Normal redundancy得至少2個fail group

 

SQL> create diskgroup data1 normalredundancy disk '/dev/asm-diske';

 create diskgroup data3 normal redundancy disk'/dev/asm-diske'

*

ERROR at line 1:

ORA-15018: diskgroup cannot be created

ORA-15072: command requires at least 2regular failure groups, discovered only 1

 

HIGH

drop diskgroup datan4;

SQL> create diskgroup datah1 highredundancy

   failgroup faildg1 disk '/dev/asm-diske' name fail1

failgroupfaildg2 disk '/dev/asm-diskf' name fail2

   failgroup faildg3 disk '/dev/asm-diskg' name fail3;

SQL> create diskgroup datah2 highredundancy

   failgroup faildg1 disk '/dev/asm-diskh' name failh21

failgroupfaildg2 disk '/dev/asm-diski' name failh22

   failgroup faildg3 disk '/dev/asm-diskj' name failh23

failgroup faildg4disk '/dev/asm-diskk' name failh24;

 

drop前做一次查詢,查詢結果在後面一起列出。

 

drop diskgroup datah1;

drop diskgroup datah2;

SQL> create diskgroup datah3 highredundancy

failgroup faildg1 disk '/dev/asm-diske'name fail1

failgroup faildg2 disk '/dev/asm-diskf'name fail2

failgroup faildg3 disk '/dev/asm-diskg'name fail3

failgroup faildg4 disk '/dev/asm-diskh'name fail4

failgroup faildg5 disk '/dev/asm-diski'name fail5;

 

drop diskgroup datah3;

SQL> create diskgroup datah4high redundancy

failgroup faildg1 disk'/dev/asm-diske' name fail1

failgroup faildg2 disk'/dev/asm-diskf' name fail2

failgroup faildg3 disk'/dev/asm-diskg' name fail3

failgroup faildg4 disk'/dev/asm-diskh' name fail4

failgroup faildg5 disk'/dev/asm-diski' name fail5

failgroup faildg6 disk'/dev/asm-diskj' name fail6;

 

drop diskgroup datah4;

create diskgroup datah5 highredundancy

failgroup fail1 disk'/dev/asm-diskm','/dev/asm-diskj'

failgroup fail2 disk'/dev/asm-diskk','/dev/asm-diskl'

failgroup fail3 disk'/dev/asm-diske','/dev/asm-diskf';

 

drop diskgroup datah5;

create diskgroup datah6 high redundancy

failgroup fail1 disk '/dev/asm-diskm','/dev/asm-diskj','/dev/asm-diskg'

failgroup fail2 disk '/dev/asm-diskk','/dev/asm-diskl','/dev/asm-diskh'

failgroup fail3 disk '/dev/asm-diske','/dev/asm-diskf','/dev/asm-diski';

 

檢視failgroup

SQL> selectgroup_number,disk_number,name,failgroup,create_date,path

from v$asm_disk order by  group_number,failgroup;


 

檢視大小

SQL> select group_number,name, TOTAL_MB, REQUIRED_MIRROR_FREE_MB, FREE_MB , USABLE_FILE_MB,ALLOCATION_UNIT_SIZE fromV$asm_diskgroup;


 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25462274/viewspace-2146102/,如需轉載,請註明出處,否則將追究法律責任。

相關文章