• Oracle Asm Failgroup测试学习


    一、测试目标

     疑问? 我们都知道Oracle RAC使用ASM管理存储;

     对于ASM磁盘组而言冗余模式有三种,EXTERN、NORMALN、HIGH,那么这三种冗余方式有什么作用呢?

      假设磁盘损坏,能丢失多少块磁盘呢???

     我们在来推断一下这个东西有什么使用场景!ASM磁盘组是否值得多配置存储,配置冗余模式。

    本篇文档,带着这些疑问,进行测试,并进行汇总整理思路,实现自问自答。 本次测试不考虑ocr磁盘组,只测试DATA磁盘组进行思考。

    二、Oracle ASM磁盘组的冗余策略

    EXTERN 磁盘组无冗余,丢失1块磁盘,磁盘组dismount,磁盘组无法对外提供正常的读写;

    NORMAL磁盘组数据写2份,一份主数据,一份备份copy数据,丢失1块磁盘磁盘组正常,最多丢失同一个failgroup组的所有磁盘;

    HIGH 磁盘组数据写3份,一份主数据,另外2份备份copy数据,丢失2块磁盘磁盘组正常,最多丢失两组failgroup组的所有磁盘;

    Oracle ASM磁盘为什么需要配置冗余? 底层操作系统RAID 10,5不香吗?  是否多此一举。  

    正是有着操作系统RAID,因此目前运维驻场的客户这边,绝大部分DATA磁盘组均为extern非冗余!  但是这种场景无法进行机房级别的容灾,整个机房掉电、其它异常导致无法访问! 即使操作系统存储RAID无效果。

    如果使用NORMAL,2份存储,一份存储A机房,另外一份存储B机房,分别属于2个FAILGROUP组,A机房异常,不影响RAC DB的服务!

    三、实验测试

    第一阶段:测试实验DATA1 EXTERN情况下,观察failgroup情况;
    第二阶段:测试实验DATA2 NORMALN情况下,3块磁盘,观察failgroup情况;
    第三阶段:测试实验DATA2 NORMALN情况下,6块磁盘,观察failgroup情况;
    第四阶段:测试实验DATA2 HIGH情况下,6块磁盘,观察failgroup情况;

    第一阶段:测试实验DATA1 EXTERN情况下,观察failgroup情况;

    SQL> select name,type from v$asm_diskgroup;
    NAME											   TYPE
    ------------------------------------------------------------------------------------------ ------------------
    DATA1											   EXTERN 
    
    
    SQL> select group_number,disk_number,state,failgroup,path from v$asm_disk where group_number=2 order by 2;  
    GROUP_NUMBER DISK_NUMBER  STATE		      FAILGROUP 	   PATH
    ------------ ----------- ----------- ------------------------ -------------------- ----------------------------
    	   2	       0     NORMAL		      DATA1_0000	   /dev/oracleasm/disks/ASMDISK10
    	   2	       1     NORMAL		      DATA1_0001	   /dev/oracleasm/disks/ASMDISK11
    	   2	       2     NORMAL		      DATA1_0002	   /dev/oracleasm/disks/ASMDISK12
    	   2	       3     NORMAL		      DATA1_0003	   /dev/oracleasm/disks/ASMDISK7
    	   2	       4     NORMAL		      DATA1_0004	   /dev/oracleasm/disks/ASMDISK8
    	   2	       5     NORMAL		      DATA1_0005	   /dev/oracleasm/disks/ASMDISK9
    	   2	       6     NORMAL		      DATA1_0006	   /dev/oracleasm/disks/ASMDISK13
    
    7 rows selected.
    
    extenal冗余:
    --------ASM是以AU为分配单位,1个AU为1M,这里创建一个大小为14M的表空间,理论上讲应该分配了14个区.
    SQL> create tablespace gao1 datafile '+DATA1' size 14m; 
    SQL> create table gaogaogago(id number(20)) tablespace GAO1;
    SQL> select file_number,name from v$asm_alias where name like 'GAO%';
    FILE_NUMBER NAME
    ----------- --------------------------
    283 GAO1.283.1057142127
    v$asm_alias视图字段解释: Column Name Description NUMBER_KFFXP ASM file number.
    Join with v$asm_file and v$asm_alias COMPOUND_KFFXP File identifier.
    Join with compound_index in v$asm_file INCARN_KFFXP File incarnation id.
    Join with incarnation in v$asm_file XNUM_KFFXP ASM file extent number (mirrored extent pairs have the same extent value) PXN_KFFXP Progressive file extent number GROUP_KFFXP ASM disk group number.
    Join with v$asm_disk and v$asm_diskgroup DISK_KFFXP ASM disk number.
    Join with v$asm_disk AU_KFFXP Relative position of the allocation unit from the beginning of the disk.
    LXN_KFFXP 0->primary extent,1->mirror extent,
    2->2nd mirror copy (high redundancy and metadata)

    DISK_KFFXP:对应v$asm_disk.DISK_NUMBER
    NUMBER_KFFXP:对应v$asm_file.FILE_NUMBER
    XNUM_KFFXP:ASM文件的extent号
    select disk_kffxp disk#, XNUM_KFFXP extent#,
    case lxn_kffxp
    when 0 then 'Primary Copy'
    when 1 then 'Mirrored Copy'
    when 2 then '2nd Mirrored Copy or metadata' else 'Unknown'
    END TYPE
    from x$kffxp
    where number_kffxp=283 order by 2;
    ASM是以AU为分配单位,1个AU为1M,这里创建一个大小为14M的表空间,分配了14个区.由下面结果可已看到一共14个区,都为primary copy,并没有mirror copy,也就是说external是只存一份数据的。

    DISK# EXTENT# TYPE
    ---------- ---------- ------------------
    0 0 Primary Copy
    2 0 Primary Copy
    0 1 Primary Copy
    6 1 Primary Copy
    0 2 Primary Copy
    5 2 Primary Copy
    4 3 Primary Copy
    0 4 Primary Copy
    1 5 Primary Copy
    3 6 Primary Copy
    2 7 Primary Copy
    6 8 Primary Copy
    5 9 Primary Copy
    4 10 Primary Copy
    0 11 Primary Copy
    1 12 Primary Copy
    3 13 Primary Copy
    2 14 Primary Copy

    18 rows selected.


    第二阶段:测试实验DATA2 NORMALN情况下,3块磁盘,观察failgroup情况;

    删除表空间gao1,然后创建表空间gao1,指定ASM磁盘组为+DATA2(NORMAL冗余磁盘组)
    SQL> drop tablespace gao1 including contents and datafiles;
    select group_number,name,TOTAL_MB,free_mb,type from v$asm_diskgroup;
    GROUP_NUMBER NAME                  TOTAL_MB      FREE_MB TYPE
    ------------ ------------------------------ ---------- ---------- ------
           2 DATA1                 17129           53 EXTERN
           3 DATA2                  7341         7005 NORMAL
    
    SQL> select group_number,name,disk_number,failgroup_type,path,failgroup  from v$asm_disk where group_number=3
    GROUP_NUMBER NAME          DISK_NUMBER FAILGROUP_TYPE        PATH                     FAILGROUP
    ------------ -------------------- ----------- --------------------- ---------------------------------------- --------------------
           3 DATA2_0002             2 REGULAR            /dev/oracleasm/disks/ASMDISK6         DATA2_0002
           3 DATA2_0001             1 REGULAR            /dev/oracleasm/disks/ASMDISK5         DATA2_0001
           3 DATA2_0000             0 REGULAR            /dev/oracleasm/disks/ASMDISK4         DATA2_0000
    
    create tablespace GAO1 datafile '+DATA2' size 14m;
    
    select file_number,name from v$asm_alias where name like 'GAO%';
    FILE_NUMBER NAME
    ----------- -------------------------------------------------------------
        257 GAO1.257.1057145865
    grid$sqlplus / as sysdba
    select GROUP_KFFXP,disk_kffxp disk#,
    XNUM_KFFXP extent#,
    case lxn_kffxp
      when 0 then 'Primary Copy'
      when 1 then 'Mirrored Copy'
      when 2 then '2nd Mirrored Copy or metadata'
      else 'Unknown' END TYPE
    from x$kffxp
    where 
    number_kffxp=257
    and GROUP_KFFXP=3
    order by 1,2,3; 
    
    由下图可见,所有的数据都是有两份的:Primary Copy 和Mirrored Copy,然后每个区的数据都是被分散在三个failgroup中的,所以无论哪个failgroup里面的磁盘坏了,都不会丢数据,但是只允许同时损坏同一个failgroup里面的磁盘
    GROUP_KFFXP     DISK#      EXTENT#      TYPE
    ----------- ---------- ---------- ------------------------------
    Failgroup1
          3         0           1              Primary Copy
          3         0           2              Mirrored Copy
          3         0           3              Mirrored Copy
          3         0           4              Primary Copy
          3         0           7              Primary Copy
          3         0           8              Mirrored Copy
          3         0           9              Mirrored Copy
          3         0           10             Primary Copy
          3         0           13             Primary Copy
          3         0           14             Mirrored Copy
    Failgroup2
          3         1           0              Primary Copy
          3         1           3              Primary Copy
          3         1           4              Mirrored Copy
          3         1           5              Mirrored Copy
          3         1           6              Primary Copy
          3         1           9              Primary Copy
          3         1           10             Mirrored Copy
          3         1           11             Mirrored Copy
          3         1           12             Primary Copy
    Failgroup3
          3         2           0              Mirrored Copy
          3         2           1              Mirrored Copy
          3         2           2              Primary Copy
          3         2           5              Primary Copy
          3         2           6              Mirrored Copy
          3         2           7              Mirrored Copy
          3         2           8              Primary Copy
          3         2           11             Primary Copy
          3         2           12             Mirrored Copy
          3         2           13             Mirrored Copy
          3         2           14             Primary Copy
    30 rows selected.
    大家细心对比,可以发现,丢失任何FAILGROUP的2块磁盘都没了,但是DB无异常,在其它两个FAILGROUP都存在记录。


    第三阶段:测试实验DATA2 NORMALN情况下,6块磁盘,观察failgroup情况;

    将DATA1磁盘删除3块,添加至DATA2磁盘组!
    select group_number,disk_number,name,failgroup,total_mb,free_mb,path,mount_status,header_status,mode_status,state from v$asm_disk order by 1,2,3
    GROUP_NUMBER DISK_NUMBER NAME		         FAILGROUP    TOTAL_MB    FREE_MB PATH				   MOUNT_STAT HEADER_STA MODE_STATU STATE
    ------------ ----------- ------------   -------- ---------- ---------- ---------- ----------------------------------- ---------- ---------- ---------- ------------------------
    	   1	       0 ARCH_0000	         ARCH_0000        4016	  1635 /dev/oracleasm/disks/ASMDISK14	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       0 DATA1_0000	         DATA1_0000       2447	    45 /dev/oracleasm/disks/ASMDISK10	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       1 DATA1_0001	         DATA1_0001       2447	    50 /dev/oracleasm/disks/ASMDISK11	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       2 DATA1_0002	         DATA1_0002       2447	    50 /dev/oracleasm/disks/ASMDISK12	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       3 DATA1_0003	         DATA1_0003       2447	    45 /dev/oracleasm/disks/ASMDISK7	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       4 DATA1_0004	         DATA1_0004       2447	    55 /dev/oracleasm/disks/ASMDISK8	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       5 DATA1_0005	         DATA1_0005       2447	    50 /dev/oracleasm/disks/ASMDISK9	   CACHED     MEMBER	 ONLINE     NORMAL
    	   2	       6 DATA1_0006	         DATA1_0006       2447	    51 /dev/oracleasm/disks/ASMDISK13	   CACHED     MEMBER	 ONLINE     NORMAL
    	   3	       0 DATA2_0000	         DATA2_0000       2447	  2335 /dev/oracleasm/disks/ASMDISK4	   CACHED     MEMBER	 ONLINE     NORMAL
    	   3	       1 DATA2_0001	         DATA2_0001       2447	  2336 /dev/oracleasm/disks/ASMDISK5	   CACHED     MEMBER	 ONLINE     NORMAL
    	   3	       2 DATA2_0002	         DATA2_0002       2447	  2334 /dev/oracleasm/disks/ASMDISK6	   CACHED     MEMBER	 ONLINE     NORMAL
    	   5	       0 OCR_0000	         OCR_0000	       2447	  2138 /dev/oracleasm/disks/ASMDISK1	   CACHED     MEMBER	 ONLINE     NORMAL
    	   5	       1 OCR_0001	         OCR_0001	       2447	  2139 /dev/oracleasm/disks/ASMDISK2	   CACHED     MEMBER	 ONLINE     NORMAL
    	   5	       2 OCR_0002	         OCR_0002	       2447	  2138 /dev/oracleasm/disks/ASMDISK3	   CACHED     MEMBER	 ONLINE     NORMAL
    
    14 rows selected.

    删除磁盘失败,提示剩余的空间不满足rebalance,后续手工删除table数据,有用的表move,索引rebuild;后resize 数据文件,回收空间。

    alter diskgroup DATA1 drop disk 'DATA1_0006','DATA1_0005','DATA1_0004' REBALANCE POWER 0;
    ORA-15032: not all alterations performed
    ORA-15250: insufficient diskgroup space for rebalance completion

    SQL> select sum(bytes)/1024/1024/1024,owner from dba_segments group by owner order by 1;
    .280517578 SH
    1.43621826 SYS
    2.13165283 SCOTT
    3.82910156 TEST

    drop user test cascade;
    SQL> select tablespace_name,file_name,bytes/1024/1024/1024,file_id from dba_data_files order by 1,2,3;
    TABLESPACE_NAME FILE_NAME BYTES/1024/1024/1024
    ------------------------------ -------------------------------------------------- -------------------- ----------
    USERS +DATA1/dr2_prod4/datafile/users.258.1057140291 10.7202148 4

    SQL> select name,total_mb,free_mb from v$asm_diskgroup where name='DATA1';

    NAME TOTAL_MB FREE_MB
    ------------------------------ ---------- ----------
    DATA1 17129 346

    alter database datafile '+DATA1/dr2_prod4/datafile/users.258.1057140291' resize 1g;
    ORA-03297: file contains used data beyond requested RESIZE value

    找到block_id 大的,处于file后半段进行处理

    select owner,segment_name,tablespace_name,bytes/1024/1024,EXTENT_ID,FILE_ID,block_id from dba_extents where tablespace_name='USERS' AND FILE_ID=4 order by EXTENT_ID;

    OE SYS_C0011258 USERS .0625 0 4 512
    SCOTT DEPT_BAK USERS .0625 0 4 508144
    SCOTT DEPT1 USERS .0625 0 4 508152

    OE SYS_C0011258 USERS .0625 0 4 512
    SCOTT DEPT_BAK USERS .0625 0 4 508144
    SCOTT DEPT1 USERS .0625 0 4 508152
    GAO TEST USERS .0625 0 4 315984

    alter table SCOTT.DEPT_BAK move;
    alter table SCOTT.DEPT1 move;
    alter table GAO.TEST move;

    alter index SCOTT.PK_DEPT1 rebuild;
    drop table test01.a purge;

    alter database datafile 4 resize 1g;

    NAME TOTAL_MB FREE_MB
    ------------------------------ ---------- ----------
    DATA1 17129 10299

    alter diskgroup DATA1 drop disk 'DATA1_0006','DATA1_0005','DATA1_0004' REBALANCE POWER 0;

    col mount_status for a10
    col header_status for a10
    col mode_status for a10
    col state for a10
    select group_number,disk_number,name,failgroup,total_mb,free_mb,path,mount_status,header_status,mode_status,state from v$asm_disk order by 1,2,3;
    GROUP_NUMBER DISK_NUMBER NAME FAILGROUP TOTAL_MB FREE_MB PATH MOUNT_STAT HEADER_STA MODE_STATU STATE
    ------------ ----------- ---------- ---------- ---------- ---------- ------------------------------ ---------- ---------- ---------- ----------
    1 0 ARCH_0000 ARCH_0000 4016 1635 /dev/oracleasm/disks/ASMDISK14 CACHED MEMBER ONLINE NORMAL
    2 0 DATA1_0000 DATA1_0000 2447 1467 /dev/oracleasm/disks/ASMDISK10 CACHED MEMBER ONLINE NORMAL
    2 1 DATA1_0001 DATA1_0001 2447 1472 /dev/oracleasm/disks/ASMDISK11 CACHED MEMBER ONLINE NORMAL
    2 2 DATA1_0002 DATA1_0002 2447 1472 /dev/oracleasm/disks/ASMDISK12 CACHED MEMBER ONLINE NORMAL
    2 3 DATA1_0003 DATA1_0003 2447 1467 /dev/oracleasm/disks/ASMDISK7 CACHED MEMBER ONLINE NORMAL
    2 4 DATA1_0004 DATA1_0004 2447 1476 /dev/oracleasm/disks/ASMDISK8 CACHED MEMBER ONLINE DROPPING
    2 5 DATA1_0005 DATA1_0005 2447 1472 /dev/oracleasm/disks/ASMDISK9 CACHED MEMBER ONLINE DROPPING
    2 6 DATA1_0006 DATA1_0006 2447 1473 /dev/oracleasm/disks/ASMDISK13 CACHED MEMBER ONLINE DROPPING
    3 0 DATA2_0000 DATA2_0000 2447 2335 /dev/oracleasm/disks/ASMDISK4 CACHED MEMBER ONLINE NORMAL
    3 1 DATA2_0001 DATA2_0001 2447 2336 /dev/oracleasm/disks/ASMDISK5 CACHED MEMBER ONLINE NORMAL
    3 2 DATA2_0002 DATA2_0002 2447 2334 /dev/oracleasm/disks/ASMDISK6 CACHED MEMBER ONLINE NORMAL
    5 0 OCR_0000 OCR_0000 2447 2138 /dev/oracleasm/disks/ASMDISK1 CACHED MEMBER ONLINE NORMAL
    5 1 OCR_0001 OCR_0001 2447 2139 /dev/oracleasm/disks/ASMDISK2 CACHED MEMBER ONLINE NORMAL
    5 2 OCR_0002 OCR_0002 2447 2138 /dev/oracleasm/disks/ASMDISK3 CACHED MEMBER ONLINE NORMAL

    14 rows selected.

    被删除drop的磁盘STATE =DROPPING

    alter diskgroup data1 rebalance power 6;
    select * from v$asm_operation;
    GROUP_NUMBER OPERATION STATE POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES ERROR_CODE
    ------------ --------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------- --------------------
    2 REBAL RUN 6 6 2465 3384 5602 0
    GROUP_NUMBER DISK_NUMBER NAME FAILGROUP TOTAL_MB FREE_MB PATH MOUNT_STAT HEADER_STA MODE_STATU STATE
    ------------ ----------- ---------- ---------- ---------- ---------- ------------------------------ ---------- ---------- ---------- ----------
    0 0 0 0 /dev/oracleasm/disks/ASMDISK13 CLOSED FORMER ONLINE NORMAL
    0 1 0 0 /dev/oracleasm/disks/ASMDISK9 CLOSED FORMER ONLINE NORMAL
    0 2 0 0 /dev/oracleasm/disks/ASMDISK8 CLOSED FORMER ONLINE NORMAL
    1 0 ARCH_0000 ARCH_0000 4016 1635 /dev/oracleasm/disks/ASMDISK14 CACHED MEMBER ONLINE NORMAL
    2 0 DATA1_0000 DATA1_0000 2447 741 /dev/oracleasm/disks/ASMDISK10 CACHED MEMBER ONLINE NORMAL
    2 1 DATA1_0001 DATA1_0001 2447 740 /dev/oracleasm/disks/ASMDISK11 CACHED MEMBER ONLINE NORMAL
    2 2 DATA1_0002 DATA1_0002 2447 743 /dev/oracleasm/disks/ASMDISK12 CACHED MEMBER ONLINE NORMAL
    2 3 DATA1_0003 DATA1_0003 2447 740 /dev/oracleasm/disks/ASMDISK7 CACHED MEMBER ONLINE NORMAL
    3 0 DATA2_0000 DATA2_0000 2447 2335 /dev/oracleasm/disks/ASMDISK4 CACHED MEMBER ONLINE NORMAL
    3 1 DATA2_0001 DATA2_0001 2447 2336 /dev/oracleasm/disks/ASMDISK5 CACHED MEMBER ONLINE NORMAL
    3 2 DATA2_0002 DATA2_0002 2447 2334 /dev/oracleasm/disks/ASMDISK6 CACHED MEMBER ONLINE NORMAL
    5 0 OCR_0000 OCR_0000 2447 2138 /dev/oracleasm/disks/ASMDISK1 CACHED MEMBER ONLINE NORMAL
    5 1 OCR_0001 OCR_0001 2447 2139 /dev/oracleasm/disks/ASMDISK2 CACHED MEMBER ONLINE NORMAL
    5 2 OCR_0002 OCR_0002 2447 2138 /dev/oracleasm/disks/ASMDISK3 CACHED MEMBER ONLINE NORMAL

    14 rows selected.


    添加!
    alter diskgroup DATA2 add
    FAILGROUP DATA2_0000 DISK '/dev/oracleasm/disks/ASMDISK8'
    FAILGROUP DATA2_0001 DISK '/dev/oracleasm/disks/ASMDISK9'
    FAILGROUP DATA2_0002 DISK '/dev/oracleasm/disks/ASMDISK13'
    rebalance power 0;

    SQL> select group_number,disk_number,name,failgroup,total_mb,free_mb,path,mount_status,header_status,mode_status,state from v$asm_disk order by 1,2,3;

    GROUP_NUMBER DISK_NUMBER NAME FAILGROUP TOTAL_MB FREE_MB PATH MOUNT_STAT HEADER_STA MODE_STATU STATE
    ------------ ----------- ---------- ---------- ---------- ---------- ------------------------------ ---------- ---------- ---------- ----------
    1 0 ARCH_0000 ARCH_0000 4016 1635 /dev/oracleasm/disks/ASMDISK14 CACHED MEMBER ONLINE NORMAL
    2 0 DATA1_0000 DATA1_0000 2447 741 /dev/oracleasm/disks/ASMDISK10 CACHED MEMBER ONLINE NORMAL
    2 1 DATA1_0001 DATA1_0001 2447 740 /dev/oracleasm/disks/ASMDISK11 CACHED MEMBER ONLINE NORMAL
    2 2 DATA1_0002 DATA1_0002 2447 743 /dev/oracleasm/disks/ASMDISK12 CACHED MEMBER ONLINE NORMAL
    2 3 DATA1_0003 DATA1_0003 2447 740 /dev/oracleasm/disks/ASMDISK7 CACHED MEMBER ONLINE NORMAL
    3 0 DATA2_0000 DATA2_0000 2447 2388 /dev/oracleasm/disks/ASMDISK4 CACHED MEMBER ONLINE NORMAL
    3 1 DATA2_0001 DATA2_0001 2447 2386 /dev/oracleasm/disks/ASMDISK5 CACHED MEMBER ONLINE NORMAL
    3 2 DATA2_0002 DATA2_0002 2447 2388 /dev/oracleasm/disks/ASMDISK6 CACHED MEMBER ONLINE NORMAL
    3 3 DATA2_0003 DATA2_0000 2447 2393 /dev/oracleasm/disks/ASMDISK8 CACHED MEMBER ONLINE NORMAL
    3 4 DATA2_0004 DATA2_0001 2447 2391 /dev/oracleasm/disks/ASMDISK9 CACHED MEMBER ONLINE NORMAL
    3 5 DATA2_0005 DATA2_0002 2447 2394 /dev/oracleasm/disks/ASMDISK13 CACHED MEMBER ONLINE NORMAL
    5 0 OCR_0000 OCR_0000 2447 2138 /dev/oracleasm/disks/ASMDISK1 CACHED MEMBER ONLINE NORMAL
    5 1 OCR_0001 OCR_0001 2447 2139 /dev/oracleasm/disks/ASMDISK2 CACHED MEMBER ONLINE NORMAL
    5 2 OCR_0002 OCR_0002 2447 2138 /dev/oracleasm/disks/ASMDISK3 CACHED MEMBER ONLINE NORMAL

    14 rows selected.

    对比一下normal冗余模式下三块盘和六块盘的异同:
    相同点:都是存放两份数据,打散在不同的failgroup里面
    不同点:三块盘的normal冗余模式,指定三个failgroup,只允许损坏一个failgroup,也就是只允许损坏一个磁盘(因为一个failgroup里面只含有一个磁盘)
    六块盘的normal冗余模式,同样指定三个failgroup,只允许损坏一个failgroup,也就是只允许损坏(同一个failgroup里面的)两块盘.

    SQL> select group_number,disk_number,failgroup from v$asm_disk where group_number=3 order by 1,3;
    GROUP_NUMBER DISK_NUMBER FAILGROUP
    ------------ ----------- ------------------------------
    3 3 DATA2_0000
    3 0 DATA2_0000
    3 1 DATA2_0001
    3 4 DATA2_0001
    3 2 DATA2_0002
    3 5 DATA2_0002
    6 rows selected.
    GROUP_KFFXP DISK# EXTENT# TYPE
    ----------- ---------- ---------- ---------------------------
    FAILGROUP1
    3 0 2 Mirrored Copy
    3 0 4 Primary Copy
    3 0 9 Mirrored Copy
    3 0 10 Primary Copy
    3 3 1 Primary Copy
    3 3 3 Mirrored Copy
    3 3 6 Mirrored Copy
    3 3 8 Primary Copy
    3 3 14 Primary Copy
    FAILGROUP2
    3 1 0 Primary Copy
    3 1 3 Primary Copy
    3 1 4 Mirrored Copy
    3 1 5 Mirrored Copy
    3 1 9 Primary Copy
    3 1 14 Mirrored Copy
    3 4 1 Mirrored Copy
    3 4 2 Primary Copy
    3 4 7 Primary Copy
    3 4 10 Mirrored Copy
    3 4 11 Mirrored Copy
    3 4 12 Mirrored Copy
    3 4 13 Primary Copy
    FAILGROUP3
    3 2 5 Primary Copy
    3 2 7 Mirrored Copy
    3 2 11 Primary Copy
    3 2 13 Mirrored Copy
    3 5 0 Mirrored Copy
    3 5 6 Primary Copy
    3 5 8 Mirrored Copy
    3 5 12 Primary Copy
    30 rows selected.

      


    第四阶段:测试实验DATA2 HIGH情况下,6块磁盘,观察failgroup情况;

    drop tablespace GAO1 including contents and datafiles;
    SQL> alter diskgroup data2 dismount;
    alter diskgroup data2 mount;
    drop diskgroup data2;
    
    col path for a30
    col name for a15
    col failgroup for a14
    col mount_status for a10
    col header_status for a10
    col mode_status for a10
    col state for a10
    set linesize 200
    set pagesize 200
    select group_number,disk_number,name,failgroup,total_mb,free_mb,path,mount_status,header_status,mode_status,state from v$asm_disk order by 1,2,3;
    GROUP_NUMBER DISK_NUMBER NAME         FAILGROUP      TOTAL_MB    FREE_MB PATH                 MOUNT_STAT HEADER_STA MODE_STATU STATE
    ------------ ----------- --------------- -------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- ----------
           0           0                     0        0 /dev/oracleasm/disks/ASMDISK13 CLOSED    FORMER       ONLINE     NORMAL
           0           1                     0        0 /dev/oracleasm/disks/ASMDISK9  CLOSED    FORMER       ONLINE     NORMAL
           0           2                     0        0 /dev/oracleasm/disks/ASMDISK8  CLOSED    FORMER       ONLINE     NORMAL
           0           3                     0        0 /dev/oracleasm/disks/ASMDISK6  CLOSED    FORMER       ONLINE     NORMAL
           0           4                     0        0 /dev/oracleasm/disks/ASMDISK5  CLOSED    FORMER       ONLINE     NORMAL
           0           5                     0        0 /dev/oracleasm/disks/ASMDISK4  CLOSED    FORMER       ONLINE     NORMAL
           1           0 ARCH_0000     ARCH_0000          4016     1635 /dev/oracleasm/disks/ASMDISK14 CACHED    MEMBER       ONLINE     NORMAL
           2           0 DATA1_0000     DATA1_0000          2447      741 /dev/oracleasm/disks/ASMDISK10 CACHED    MEMBER       ONLINE     NORMAL
           2           1 DATA1_0001     DATA1_0001          2447      740 /dev/oracleasm/disks/ASMDISK11 CACHED    MEMBER       ONLINE     NORMAL
           2           2 DATA1_0002     DATA1_0002          2447      743 /dev/oracleasm/disks/ASMDISK12 CACHED    MEMBER       ONLINE     NORMAL
           2           3 DATA1_0003     DATA1_0003          2447      740 /dev/oracleasm/disks/ASMDISK7  CACHED    MEMBER       ONLINE     NORMAL
           5           0 OCR_0000     OCR_0000          2447     2138 /dev/oracleasm/disks/ASMDISK1  CACHED    MEMBER       ONLINE     NORMAL
           5           1 OCR_0001     OCR_0001          2447     2139 /dev/oracleasm/disks/ASMDISK2  CACHED    MEMBER       ONLINE     NORMAL
           5           2 OCR_0002     OCR_0002          2447     2138 /dev/oracleasm/disks/ASMDISK3  CACHED    MEMBER       ONLINE     NORMAL
    
    14 rows selected.
    
    
    --alter diskgroup data1 rebalance power 6;
    select * from v$asm_operation;
    
    
    create diskgroup DATA2 high redundancy
    FAILGROUP fgroup1 disk '/dev/oracleasm/disks/ASMDISK13','/dev/oracleasm/disks/ASMDISK9'
    FAILGROUP fgroup2 disk '/dev/oracleasm/disks/ASMDISK8','/dev/oracleasm/disks/ASMDISK6'
    FAILGROUP fgroup3 disk '/dev/oracleasm/disks/ASMDISK5','/dev/oracleasm/disks/ASMDISK4'
    ;
    
    
    GROUP_NUMBER DISK_NUMBER NAME         FAILGROUP      TOTAL_MB    FREE_MB PATH                 MOUNT_STAT HEADER_STA MODE_STATU STATE
    ------------ ----------- --------------- -------------- ---------- ---------- ------------------------------ ---------- ---------- ---------- ----------
           1           0 ARCH_0000     ARCH_0000          4016     1635 /dev/oracleasm/disks/ASMDISK14 CACHED    MEMBER       ONLINE     NORMAL
           2           0 DATA1_0000     DATA1_0000          2447      741 /dev/oracleasm/disks/ASMDISK10 CACHED    MEMBER       ONLINE     NORMAL
           2           1 DATA1_0001     DATA1_0001          2447      740 /dev/oracleasm/disks/ASMDISK11 CACHED    MEMBER       ONLINE     NORMAL
           2           2 DATA1_0002     DATA1_0002          2447      743 /dev/oracleasm/disks/ASMDISK12 CACHED    MEMBER       ONLINE     NORMAL
           2           3 DATA1_0003     DATA1_0003          2447      740 /dev/oracleasm/disks/ASMDISK7  CACHED    MEMBER       ONLINE     NORMAL
           3           0 DATA2_0000     FGROUP1          2447     2420 /dev/oracleasm/disks/ASMDISK13 CACHED    MEMBER       ONLINE     NORMAL
           3           1 DATA2_0001     FGROUP1          2447     2421 /dev/oracleasm/disks/ASMDISK9  CACHED    MEMBER       ONLINE     NORMAL
           3           2 DATA2_0002     FGROUP2          2447     2420 /dev/oracleasm/disks/ASMDISK8  CACHED    MEMBER       ONLINE     NORMAL
           3           3 DATA2_0003     FGROUP2          2447     2421 /dev/oracleasm/disks/ASMDISK6  CACHED    MEMBER       ONLINE     NORMAL
           3           4 DATA2_0004     FGROUP3          2447     2420 /dev/oracleasm/disks/ASMDISK5  CACHED    MEMBER       ONLINE     NORMAL
           3           5 DATA2_0005     FGROUP3          2447     2421 /dev/oracleasm/disks/ASMDISK4  CACHED    MEMBER       ONLINE     NORMAL
           5           0 OCR_0000     OCR_0000          2447     2138 /dev/oracleasm/disks/ASMDISK1  CACHED    MEMBER       ONLINE     NORMAL
           5           1 OCR_0001     OCR_0001          2447     2139 /dev/oracleasm/disks/ASMDISK2  CACHED    MEMBER       ONLINE     NORMAL
           5           2 OCR_0002     OCR_0002          2447     2138 /dev/oracleasm/disks/ASMDISK3  CACHED    MEMBER       ONLINE     NORMAL
    
    14 rows selected.
    
    select group_number,name,type,COMPATIBILITY from v$asm_diskgroup
    
    GROUP_NUMBER NAME         TYPE        COMPATIBILITY
    ------------ --------------- ------------------ --------------------
           1 ARCH         EXTERN        11.2.0.0.0
           2 DATA1         EXTERN        11.2.0.0.0
           3 DATA2         HIGH        10.1.0.0.0
           5 OCR         NORMAL        11.2.0.0.0
           
           
    high冗余三份数据:
    failgroup为单位,只允许坏掉两个failgroup里面的数据,是不会造成数据丢失的。
    
           
           
           
           
           
    
    从oracle 11g版本开始,asm磁盘组会有两个新属性来兼容asm版本和数据库版本
    http://blog.itpub.net/31397003/viewspace-2132859/
    COMPATIBLE.ASM - The minimum version of the ASM software that can access the disk group. In 11g, the default setting is 10.1.
    COMPATIBLE.RDBMS - The minimum COMPATIBLE database initialization parameter setting for any database instance that uses the disk group. In 11g, the default setting is 10.1.
           
    SELECT group_number, name, value FROM v$asm_attribute
     where NAME like 'compatible%' ORDER BY group_number, name;
     GROUP_NUMBER NAME                      VALUE
    ------------ ---------------------------------------- ------------------------------
           1 compatible.asm                  11.2.0.0.0
           1 compatible.rdbms              10.1.0.0.0
           2 compatible.asm                  11.2.0.0.0
           2 compatible.rdbms              10.1.0.0.0
           5 compatible.asm                  11.2.0.0.0
           5 compatible.rdbms              10.1.0.0.0
    
    6 rows selected.
    
    SELECT group_number, name, compatibility, database_compatibility FROM v$asm_diskgroup;
    GROUP_NUMBER NAME    COMPATIBILITY         DATABASE_COMPATIBILI
    ------------ ---------- -------------------- --------------------
           1 ARCH    11.2.0.0.0         10.1.0.0.0
           2 DATA1    11.2.0.0.0         10.1.0.0.0
           3 DATA2    10.1.0.0.0         10.1.0.0.0
           5 OCR    11.2.0.0.0         10.1.0.0.0
    
    create tablespace GAO1 datafile '+DATA2' size 14m
    SQL> select file_number,name from v$asm_alias where name like 'GAO%';
    FILE_NUMBER NAME
    ----------- ----------------------------------------------------------------------
        256 GAO1.256.1057165987
    
       0 DATA2_0000     FGROUP1
       1 DATA2_0001     FGROUP1    
       2 DATA2_0002     FGROUP2    
       3 DATA2_0003     FGROUP2    
       4 DATA2_0004     FGROUP3    
       5 DATA2_0005     FGROUP3    
           
    select GROUP_KFFXP,disk_kffxp disk#,
    XNUM_KFFXP extent#,
    case lxn_kffxp
      when 0 then 'Primary Copy'
      when 1 then 'Mirrored Copy'
      when 2 then '2nd Mirrored Copy or metadata'
      else 'Unknown' END TYPE
    from x$kffxp
    where 
    number_kffxp=256
    and GROUP_KFFXP=3
    order by 1,2,3; 
    GROUP_KFFXP     DISK#            EXTENT#             TYPE
    ----------- ---------- ---------- -----------------------------------
          3            0              0                 Mirrored Copy
          3            0              5                 Primary Copy
          3            0              8                 Mirrored Copy
          3            0              9                 2nd Mirrored Copy or metadata
          3            0             10                 Mirrored Copy
          3            0             11                 Primary Copy
          3            0             12                 Mirrored Copy
          3            1              1                 Primary Copy
          3            1              2                 Mirrored Copy
          3            1              3                 Mirrored Copy
          3            1              4                 2nd Mirrored Copy or metadata
          3            1              6                 2nd Mirrored Copy or metadata
          3            1              7                 Primary Copy
          3            1             13                 Primary Copy
          3            1             14                 Mirrored Copy
          
          
          
          
          3            2              3                 Primary Copy
          3            2              4                 Mirrored Copy
          3            2              5                 2nd Mirrored Copy or metadata
          3            2              7                 2nd Mirrored Copy or metadata
          3            2              8                 2nd Mirrored Copy or metadata
          3            2              9                 Primary Copy
          3            3              0                 Primary Copy
          3            3              1                 2nd Mirrored Copy or metadata
          3            3              2                 2nd Mirrored Copy or metadata
          3            3              6                 Primary Copy
          3            3             10                 2nd Mirrored Copy or metadata
          3            3             11                 Mirrored Copy
          3            3             12                 Primary Copy
          3            3             13                 2nd Mirrored Copy or metadata
          3            3             14                 2nd Mirrored Copy or metadata
          
          
          
          3            4              1                 Mirrored Copy
          3            4              4                 Primary Copy
          3            4              6                 Mirrored Copy
          3            4              9                 Mirrored Copy
          3            4             10                 Primary Copy
          3            4             11                 2nd Mirrored Copy or metadata
          3            4             13                 Mirrored Copy
          3            5              0                 2nd Mirrored Copy or metadata
          3            5              2                 Primary Copy
          3            5              3                 2nd Mirrored Copy or metadata
          3            5              5                 Mirrored Copy
          3            5              7                 Mirrored Copy
          3            5              8                 Primary Copy
          3            5             12                 2nd Mirrored Copy or metadata
          3            5             14                 Primary Copy
    
    45 rows selected.
    
    可以发现每个FAILGROUP组存有45/3=15条记录!   整个数据文件占用15个AU即15个extents分配,被3份冗余! 因此high可以丢失2份所有Failgroup数据。

     

  • 相关阅读:
    CF1477F
    UR2 树上 GCD
    CF1491
    碎碎念——Nothing is but what is not
    理希的高考前胡诌
    理希的OI记——补集
    老年人的赛前康复计划
    react中受控组件、非受控组件、纯函数、高阶函数、高阶组件。
    react当中refs
    react当中Props
  • 原文地址:https://www.cnblogs.com/lvcha001/p/14025140.html
Copyright © 2020-2023  润新知