ASM Failure Group的一點理解

不一樣的天空w發表於2017-01-24

用perl建立了兩個RAW的1G檔案,準備做failure group


SQL> select GROUP_NUMBER,DISK_NUMBER,INCARNATION,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,
  2  TOTAL_MB,FREE_MB,NAME,FAILGROUP from v$asm_disk;


 GROUP   DISK             MOUNT   HEADER    MODE                     TOTAL  FREE
NUMBER NUMBER INCARNATION STATUS  STATUS    STATUS  STATE  REDUNDANC    MB    MB NAME             FAILGROUP
------ ------ ----------- ------- --------- ------- ------ --------- ----- ----- ---------------- ----------------
     0      0           0 CLOSED  CANDIDATE ONLINE  NORMAL UNKNOWN    1023     0
     0      1           0 CLOSED  CANDIDATE ONLINE  NORMAL UNKNOWN    1023     0
     1      0  4042421333 CACHED  MEMBER    ONLINE  NORMAL UNKNOWN    3072  2391 DISK_GROUP1_0000 DISK_GROUP1_0000
     1      1  4042421334 CACHED  MEMBER    ONLINE  NORMAL UNKNOWN    3072  2399 DISK_GROUP1_0001 DISK_GROUP1_0001
     2      0  4042421335 CACHED  MEMBER    ONLINE  NORMAL UNKNOWN    3072  2665 DISK_GROUP2_0000 DISK_GROUP2_0000
     2      1  4042421336 CACHED  MEMBER    ONLINE  NORMAL UNKNOWN    3072  2668 DISK_GROUP2_0001 DISK_GROUP2_0001

已選擇6行。

SQL> CREATE DISKGROUP DISK_GROUP3 NORMAL REDUNDANCY
  2  FAILGROUP controller2 DISK 'D:\ASM DISK\DISK_FILE_DISK6' ;
CREATE DISKGROUP DISK_GROUP3 NORMAL REDUNDANCY
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15072: command requires at least 2 failure groups, discovered only 1

如果只有一個磁碟(failure group)是不可以做冗餘策略(FAILURE GROUPS).


SQL> CREATE DISKGROUP DISK_GROUP3 NORMAL REDUNDANCY
  2  FAILGROUP controller2 DISK 'D:\ASM DISK\DISK_FILE_DISK6'
  3  FAILGROUP controller1 DISK 'D:\ASM DISK\DISK_FILE_DISK5' NAME disk5 SIZE 1023 M FORCE ;
CREATE DISKGROUP DISK_GROUP3 NORMAL REDUNDANCY
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15034: disk 'D:\ASM DISK\DISK_FILE_DISK5' does not require the FORCE option

因為磁碟5從來沒有被ASM格式化過,所以不能用force選項,如果已經被ASM格式化過,就可以透過FORCE跳過格式化.


SQL> CREATE DISKGROUP DISK_GROUP3 NORMAL REDUNDANCY
  2  FAILGROUP controller2 DISK 'D:\ASM DISK\DISK_FILE_DISK6'
  3  FAILGROUP controller1 DISK 'D:\ASM DISK\DISK_FILE_DISK5' NAME disk5 SIZE 1023 M;

Diskgroup created.

磁碟組已經建立,faigroup分別命名controller1 ,controller2  .其中一個failgroup被命名為disk5


SQL> select  GROUP_NUMBER,NAME,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,
  2  TYPE,TOTAL_MB,FREE_MB,REQUIRED_MIRROR_FREE_MB,
  3  USABLE_FILE_MB,OFFLINE_DISKS,UNBALANCED from v$asm_diskgroup;

                                                                          REQUIRED     USABLE
 GROUP              SECTOR BLOCK ALLOCATION                 TOTAL  FREE     MIRROR       FILE
NUMBER NAME           SIZE  SIZE  UNIT_SIZE STATE    TYPE      MB    MB    FREE_MB         MB OFFLINE_DISKS UN
------ ------------ ------ ----- ---------- -------- ------ ----- ----- ---------- ---------- ------------- --
     1 DISK_GROUP1     512  4096    1048576 MOUNTED  EXTERN  6144  4790          0       4790          0 N
     2 DISK_GROUP2     512  4096    1048576 MOUNTED  EXTERN  6144  5333          0       5333          0 N
     3 DISK_GROUP3     512  4096    1048576 MOUNTED  NORMAL  2046  1944          0        972          0 N

可以看到磁碟組是normal型別

檢視磁碟的狀態和名稱:
SQL> select GROUP_NUMBER,DISK_NUMBER,INCARNATION,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,
  2  TOTAL_MB,FREE_MB,NAME,FAILGROUP from v$asm_disk;

 GROUP   DISK             MOUNT   HEADER    MODE                       TOTAL  FREE
NUMBER NUMBER INCARNATION STATUS  STATUS    STATUS  STATE    REDUNDANC    MB    MB NAME             FAILGROUP
------ ------ ----------- ------- --------- ------- -------- --------- ----- ----- ---------------- ----------------
     1      0  4042421333 CACHED  MEMBER    ONLINE  NORMAL   UNKNOWN    3072  2391 DISK_GROUP1_0000 DISK_GROUP1_0000
     1      1  4042421334 CACHED  MEMBER    ONLINE  NORMAL   UNKNOWN    3072  2399 DISK_GROUP1_0001 DISK_GROUP1_0001
     2      0  4042421335 CACHED  MEMBER    ONLINE  NORMAL   UNKNOWN    3072  2665 DISK_GROUP2_0000 DISK_GROUP2_0000
     2      1  4042421336 CACHED  MEMBER    ONLINE  NORMAL   UNKNOWN    3072  2668 DISK_GROUP2_0001 DISK_GROUP2_0001
     3      1  4042421348 CACHED  MEMBER    ONLINE  NORMAL   UNKNOWN    1023   972 DISK5            CONTROLLER1
     3      0  4042421349 CACHED  MEMBER    ONLINE  NORMAL   UNKNOWN    1023   972 DISK_GROUP3_0000 CONTROLLER2

6 rows selected.

磁碟都是normal了

SQL> alter diskgroup disk_group3 dismount;

Diskgroup altered.

因為沒有資料,可以線上dismount.

SQL> select state from v$asm_diskgroup where name='DISK_GROUP3';

STATE
------------------
DISMOUNTED


SQL> alter diskgroup disk_group3 mount;

Diskgroup altered.


SQL> alter diskgroup disk_group3 drop disk disk5;

磁碟組已變更。

刪除一個磁碟,由於磁碟組要是normal的話,必須有兩個磁碟,但是這個動作仍然可以完成.


SQL> select GROUP_NUMBER,DISK_NUMBER,INCARNATION,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,
  2  TOTAL_MB,FREE_MB,NAME,FAILGROUP from v$asm_disk;


GROUP_NUMBER DISK_NUMBER INCARNATION MOUNT_STATUS   HEADER_STATUS            MODE_STATUS    STATE         REDUNDANCY
------------ ----------- ----------- -------------- ------------------------ -------------- ---------------- --------
           1           0  4042862971 CACHED         MEMBER                   ONLINE         NORMAL           UNKNOWN
           1           1  4042862972 CACHED         MEMBER                   ONLINE         NORMAL           UNKNOWN
           2           0  4042862973 CACHED         MEMBER                   ONLINE         NORMAL           UNKNOWN
           2           1  4042862974 CACHED         MEMBER                   ONLINE         NORMAL           UNKNOWN
           3           1  4042862975 CACHED         MEMBER                   ONLINE         HUNG             UNKNOWN
           3           0  4042862976 CACHED         MEMBER                   ONLINE         NORMAL           UNKNOWN

已選擇6行。

我們看到這個磁碟是HUNG狀態.
SQL> select * from v$asm_diskgroup;


GROUP_NUMBER NAME            SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE       TYPE     TOTAL_MB    FREE_MB U COMP
------------ --------------- ----------- ---------- -------------------- ----------- ------ ---------- ---------- - ----
           1 DISK_GROUP1             512       4096              1048576 CONNECTED   EXTERN       6144       4790 N 10.1
           2 DISK_GROUP2             512       4096              1048576 CONNECTED   EXTERN       6144       5333 N 10.1
           3 DISK_GROUP3             512       4096              1048576 CONNECTED   NORMAL       2046       1936 N 10.1

SQL>

SQL> ALTER DISKGROUP DISK_GROUP3 CHECK DISK DISK5;

磁碟組已變更。


SQL> conn / as sysdba
已連線。
SQL> select file_name from dba_data_files;

FILE_NAME
---------------------------------------------------------------------------
+DISK_GROUP1/devdb/datafile/users.291.652996483
+DISK_GROUP1/devdb/datafile/sysaux.293.652996483
+DISK_GROUP1/devdb/datafile/undotbs1.292.652996483
+DISK_GROUP1/devdb/datafile/system.260.652996483
+DISK_GROUP1/devdb/datafile/example.256.652996665
D:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST.DBF
D:\ORACLE\PRODUCT\10.2.0\ORADATA\O1_MF_TEST2_42QWS6VO_.DBF
+DISK_GROUP3/devdb/datafile/teste.256.655147089

已選擇8行。

SQL> create table scott.user_session_t as select * from v$session;

表已建立。


SQL> alter tablespace teste offline;

表空間已更改。

 

表空間offline以後,磁碟組解除安裝:

SQL> ALTER DISKGROUP DISK_GROUP3 DISMOUNT;

磁碟組已變更。


SQL> ALTER DISKGROUP DISK_GROUP3 MOUNT;

磁碟組已變更。


SQL> alter diskgroup disk_group3 rebalance power 2;

磁碟組已變更。

 

 

SQL> alter tablespace teste online;

表空間已更改。

SQL> alter database datafile '+DISK_GROUP3/devdb/datafile/teste.256.655147089' resize 200m;
alter database datafile '+DISK_GROUP3/devdb/datafile/teste.256.655147089' resize 200m
*
第 1 行出現錯誤:
ORA-01237: 無法擴充套件資料檔案 8
ORA-01110: 資料檔案 8: '+DISK_GROUP3/devdb/datafile/teste.256.655147089'
ORA-17505: ksfdrsz: 1 未能將檔案大小調整為大小為 25600 的塊
ORA-15041: diskgroup space exhausted

我們發現不能擴充套件資料檔案

SQL> select  GROUP_NUMBER,name,TOTAL_MB,FREE_MB,OFFLINE_DISKS,STATE from v$asm_diskgroup;

GROUP_NUMBER NAME                             TOTAL_MB    FREE_MB OFFLINE_DISKS STATE
------------ ------------------------------ ---------- ---------- ------------- -----------
           1 DISK_GROUP1                          6144       4790             0 CONNECTED
           2 DISK_GROUP2                          6144       5333             0 CONNECTED
           3 DISK_GROUP3                          2046       1936             0 CONNECTED

空間是夠的


SQL> alter database datafile '+DISK_GROUP3/devdb/datafile/teste.256.655147089' resize 10m;
alter database datafile '+DISK_GROUP3/devdb/datafile/teste.256.655147089' resize 10m
*
第 1 行出現錯誤:
ORA-01237: 無法擴充套件資料檔案 8
ORA-01110: 資料檔案 8: '+DISK_GROUP3/devdb/datafile/teste.256.655147089'
ORA-17505: ksfdrsz: 1 未能將檔案大小調整為大小為 1280 的塊
ORA-15041: diskgroup space exhausted


SQL> shutdown immediate
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。


SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown


SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1295152 bytes
Variable Size              57425104 bytes
ASM Cache                  25165824 bytes
ASM 磁碟組已裝載


SQL> alter diskgroup disk_group3 undrop disks;

磁碟組已變更。

這個時候,我們發現是可以取消這個刪除動作


SQL> select * from v$asm_disk;

GROUP_NUMBER DISK_NUMBER COMPOUND_INDEX INCARNATION MOUNT_STATUS   HEADER_STATUS            MODE_STATUS    STATE
------------ ----------- -------------- ----------- -------------- ------------------------ -------------- -------------
           1           0       16777216  4041340299 CACHED         MEMBER                   ONLINE         NORMAL
           1           1       16777217  4041340300 CACHED         MEMBER                   ONLINE         NORMAL
           2           0       33554432  4041340301 CACHED         MEMBER                   ONLINE         NORMAL
           2           1       33554433  4041340302 CACHED         MEMBER                   ONLINE         NORMAL
           3           1       50331649  4041340303 CACHED         MEMBER                   ONLINE         NORMAL
           3           0       50331648  4041340304 CACHED         MEMBER                   ONLINE         NORMAL

已選擇6行。


SQL> alter database datafile '+DISK_GROUP3/devdb/datafile/teste.256.655147089' resize 12m;

資料庫已更改。

其實,我們做drop disk以後,並沒有刪除disk,我們看看hung狀態的解釋:
HUNG - Disk drop operation cannot continue because there is insufficient space to relocate the data from the disk being dropped

我們看到由於是failure group需要把資料轉移到其他的failura group,而只有2個disk,所以這個資料並沒有轉移,而是停在那

 

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

相關文章