學習ASM技術(三)--diskgroup管理

yezhibin發表於2010-02-24
1、刪除disk

SQL> select group_number, name from v$asm_diskgroup;

GROUP_NUMBER         NAME
---------------------------- ------------------
           1                         ASM_DISKGROUP

SQL> select path, name from v$asm_disk where group_number=1;
PATH                           NAME
------------------------------ ------------------------------
/dev/raw/raw5                  ASM_DISKGROUP_0004
/dev/raw/raw4                  ASM_DISKGROUP_0003
/dev/raw/raw3                  ASM_DISKGROUP_0002
/dev/raw/raw2                  ASM_DISKGROUP_0001
/dev/raw/raw1                  ASM_DISKGROUP_0000

SQL>alter diskgroup ASM_DISKGROUP drop disk asm_diskgroup_0004;
SQL>alter diskgroup ASM_DISKGROUP drop disk asm_diskgroup_0003;

2、建立新的diskgroup
SQL> select name, path, mode_status, state from v$asm_disk; 

NAME                           PATH                           MODE_ST STATE
------------------------------ ------------------------------ ------- --------
                                                          /dev/raw/raw6                  ONLINE  NORMAL
                                                          /dev/raw/raw5                  ONLINE  NORMAL
                                                           /dev/raw/raw4                  ONLINE  NORMAL
ASM_DISKGROUP_0002             /dev/raw/raw3                  ONLINE  NORMAL
ASM_DISKGROUP_0001             /dev/raw/raw2                  ONLINE  NORMAL
ASM_DISKGROUP_0000             /dev/raw/raw1                  ONLINE  NORMAL

SQL>create diskgroup dg1  external redundancy disk '/dev/raw/raw4';

SQL> select name, state, type, total_mb, free_mb from v$asm_diskgroup;

NAME                                STATE            TYPE       TOTAL_MB    FREE_MB
------------------------------ ----------- ------ ---------- ----------
ASM_DISKGROUP        MOUNTED     NORMAL      15072      14919
DG1                                  MOUNTED     EXTERN          5024       4974

SQL>drop diskgroup dg1;

SQL> create diskgroup dg1 normal redundancy
  2  failgroup f1 disk '/dev/raw/raw4'                        
  3  failgroup f2 disk '/dev/raw/raw5';

在建立diskgroup有三個選項:external, normal和high redunancy,具體在使用中,如果使用中高階儲存裝置,通常磁碟映象在硬體級別就完成了,所以在建立diskgroup採用external,normal則至少需要兩個磁碟,high則是三個磁碟,通常用於低端儲存裝置。

3、新增disk到現有的diskgroup
SQL>alter diskgroup ASM_DISKGROUP add disk
          '/dev/raw/raw6' name ASM_DISKGROUP_0003;

刪除failure group 下的所有disk
SQL>alter diskgroup dg1 drop disks in failgroup f2;
檢查disk狀態,f2下的磁碟處於hung狀態
SQL> select group_number,disk_number,name,failgroup,state from v$asm_disk;

4、重新設定disk大小
alter diskgroup asm_diskgroup resize disk ASM_DISKGROUP_0001 size 800m;

5、將diskgroup進行dismount和mount

SQL> select name, state from v$asm_diskgroup;
NAME                                         STATE
------------------------------------- ---------------
ASM_DISKGROUP                  MOUNTED
DG1                                            MOUNTED

SQL>alter diskgroup dg1 dismount;
SQL> alter diskgroup asm_diskgroup dismount;

SQL> select name, state from v$asm_diskgroup;
NAME                                         STATE
------------------------------------- ---------------
ASM_DISKGROUP                  DISMOUNTED
DG1                                            DISMOUNTED

SQL> alter diskgroup dg1 mount;
SQL>alter diskgroup  asm_diskgroup mount;

SQL> select name, state from v$asm_diskgroup;
NAME                                         STATE
------------------------------------- ---------------
ASM_DISKGROUP                  MOUNTED
DG1                                            MOUNTEDx`

6、冗餘性考慮

        我們在建立diskgroup沒有指定failure group, failure group 自動在自己盤重建。但我們要注意指定failure group 時,每個failure group中的盤數量和大小要一致,避免空間浪費。
        在ASM的diskgroup中,第一個被分配的file extents,作為primary extent,其他作為second extents,在10g中,預設都是先讀primary extents,但在11g,我們可以設定prefered read 特性,主要解決了RAC的兩個節點中,節點1優先讀取primary extent,節點2優先讀取second extents,提高I/O效能

7、disk partnership
     在normal和high redundancy diskgroup中,磁碟故障切換備用盤的資訊可查詢x$kfdpartner.

SQL> select name, disk_number
            from v$asm_disk
            where GROUP_NUMBER=2
            order by 2;

NAME                                         DISK_NUMBER
----------------------------------- -------------------------
ASM_DISKGROUP_0000                       0
ASM_DISKGROUP_0001                       1
ASM_DISKGROUP_0002                       2

SQL> select disk, NUMBER_KFDPARTNER from x$kfdpartner;

      DISK        NUMBER_KFDPARTNER
----------------- -----------------------------------
         0                 1
         0                 2
         1                 0
         1                 2
         2                 0
         2                 1
可以看到磁碟1的parner是磁碟2和磁碟3.

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

相關文章