今天是2014-02-27,從今天開始准備記錄一系列的asm筆記。在此記錄一下。
(一)asm常見參數:
和database實例一樣,asm同樣具有啟動實例的相關參數,具體如下:
asm_diskgroups:指定asm實例啟動的時候需要mount的disk group名字:
asm_disktsring :指定一個asm實例尋找磁盤的路徑名可以有通配符。
asm_power_limit:指定在磁盤組中平衡數據的時候默認的power大小。
asm_preferred_read_failure_groups:指定優先讀取的故障組
diagnostic_dest:asm實例diagnostics的目錄
instance_type:實例類型,對於asm實例必須為asm
remote_login_passwordfile:驗證是否需要去讀密碼文件
(二)asm實例和數據庫實例參數文件搜索過程:
對於asm實例在啟動的時候需要參數文件,那麼一般搜索過程為:
1、先根據GPNP profile文件指定的參數文件位置進行尋找
2、如果沒有在GPNP profile中指定的目錄找到,那麼將尋找$ORACLE_HME/dbs/spfile+ASM.ora
3、如果沒有spfile+ASM.ora,那麼將尋找pfile文件。
如果上述沒有找到則無法啟動asm
對於數據庫實例啟動的時候需要參數文件,那麼搜素過程為:
1、尋找 $ORACLE_HOME/dbs/spfile<ORACLE_SID>.ora,
2、尋找 $ORACLE_HOME/dbs/spfile.ora
3、尋找 $ORACLE_HOME/dbs/init<ORACLE_SID>.ora
如果上述沒有找到參數文件,那麼數據庫實例無法啟動。
(三)使用sql命令create diskgroup創建磁盤組
當創建磁盤組之前需要注意一下幾點:
1、指定磁盤組的唯一名字(注:不要使用對象名字)
2、指定磁盤組的平衡等級,一旦自定將無法修改
3、指定的磁盤將被格式化為oracle asm磁盤組的磁盤
4、選擇指定磁盤組屬於指定的故障組
5、選擇指定故障組的類型(有QUORUM和REGULAR故障組)
6、指定磁盤組的屬性(如軟件兼容版本或是au大小等)
注意:一個磁盤只能屬於一個磁盤組,且所有剛剛創建的磁盤都是有唯一的地址路徑不屬於現有的所有磁盤組,如果一個磁盤原先屬於一個磁盤組,但是壞掉 了當修復後,這個磁盤將不在是磁盤組的一部分,但是asm實例依然在磁盤組 中保留該磁盤的成員信息,可以使用force參數將該磁盤加入磁盤組。當drop的使用force,那麼加入的時候使用force參數,如果在刪除的時候沒有使用force,那麼就不使用force(或是noforce)。
The CREATE DISKGROUP statement mounts the disk group for the first time, and adds the disk group name to the ASM_DISKGROUPS initialization parameter if a server parameter file is being used. If a text initialization parameter file is being used and you want the disk group to be automatically mounted at instance startup, then you must remember to add the disk group name to the ASM_DISKGROUPS initialization parameter before you shut down and restart the Oracle ASM instance.
由於我是采用asmlib的方式管理asm磁盤,因此需要創建asm磁盤,如果采用/dev/udev綁定磁盤的方式,那麼需要在/etc/udev/rules.d/xxx寫相關策略保證在系統重啟後設備名和磁盤組名對應關系,防止變化。
創建asm磁盤:
[root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK7 /dev/sdj1 Marking disk "ASMDISK7" as an ASM disk: [ OK ] [root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK8 /dev/sdk1 Marking disk "ASMDISK8" as an ASM disk: [ OK ] [root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK9 /dev/sdl1 Marking disk "ASMDISK9" as an ASM disk: [ OK ] [root@oracle-one ~]# /etc/init.d/oracleasm createdisk ASMDISK10 /dev/sdm1 Marking disk "ASMDISK10" as an ASM disk: [ OK ] [root@oracle-one ~]#
查看創建磁盤信息:
SQL> select name,state,path from v$asm_disk; NAME STATE PATH ------------------------- -------- ---------------------------------------- NORMAL /dev/oracleasm/disks/ASMDISK10 NORMAL /dev/oracleasm/disks/ASMDISK9 NORMAL /dev/oracleasm/disks/ASMDISK8 NORMAL /dev/oracleasm/disks/ASMDISK7 NORMAL /dev/oracleasm/disks/ASMDISK4 NORMAL /dev/oracleasm/disks/ASMDISK2 NORMAL /dev/oracleasm/disks/ASMDISK3 DATAGROUP2_0002 NORMAL /dev/oracleasm/disks/ASMDISK6 DATAGROUP2_0001 NORMAL /dev/oracleasm/disks/ASMDISK5 DATAGROUP2_0000 NORMAL /dev/oracleasm/disks/ASMDISK1 10 rows selected. SQL>
創建不指定故障組的磁盤組:
如果在創建磁盤組的時候不指定故障組,那麼會默認將每個磁盤作為一個故障組:
There are always failure groups even if they are not explicitly created. If you do not specify a failure group for a disk, then Oracle automatically creates a new failure group containing just that disk, except for disk groups containing disks on Oracle Exadata cells.
eg:
SQL> create diskgroup datagroup3 normal redundancy 2 disk '/dev/oracleasm/disks/ASMDISK7' NAME DATAGROUP3_DISK7, 3 4 '/dev/oracleasm/disks/ASMDISK8' NAME DATAGROUP3_DISK8, 5 '/dev/oracleasm/disks/ASMDISK9' NAME DATAGROUP3_DISK9, 6 '/dev/oracleasm/disks/ASMDISK10' NAME DATAGROUP3_DISK10 7 ATTRIBUTE 'au_size'='1M', 8 'compatible.rdbms'='11.2', 9 'compatible.asm'='11.2', 10 'sector_size'='512'; Diskgroup created. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 980 NORMAL DATAGROUP3_DISK10 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 977 NORMAL DATAGROUP3_DISK7 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 980 NORMAL DATAGROUP3_DISK8 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 978 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
指定故障組創建磁盤組:
eg:
SQL> create diskgroup datagroup3 normal redundancy 2 failgroup failgroup_1 disk 3 '/dev/oracleasm/disks/ASMDISK7' NAME DATAGROUP3_DISK7 4 failgroup failgroup_2 disk 5 '/dev/oracleasm/disks/ASMDISK8' NAME DATAGROUP3_DISK8, 6 '/dev/oracleasm/disks/ASMDISK9' NAME DATAGROUP3_DISK9 7 failgroup failgroup_3 disk '/dev/oracleasm/disks/ASMDISK10' NAME DATAGROUP3_DISK10 8 9 ATTRIBUTE 'au_size'='1M', 'compatible.rdbms'='11.2', 10 11 'compatible.asm'='11.2', 12 'sector_size'='512'; Diskgroup created. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 993 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 990 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
A quorum failure group is not considered when determining redundancy requirements in respect to storing user data. However, a quorum failure group counts when mounting a disk group.
注意故障磁盤組有兩種一種是quorum一種是regular,不同之處是quorum不包含用戶數據。
如創建quorum故障組的磁盤組:
eg:
SQL> drop diskgroup datagroup3 including contents; Diskgroup dropped. SQL> create diskgroup datagroup3 normal redundancy 2 failgroup failgroup_1 disk 3 '/dev/oracleasm/disks/ASMDISK7' NAME DATAGROUP3_DISK7 4 failgroup failgroup_2 disk 5 '/dev/oracleasm/disks/ASMDISK8' NAME DATAGROUP3_DISK8, 6 '/dev/oracleasm/disks/ASMDISK9' NAME DATAGROUP3_DISK9 quorum failgroup failgroup_3 disk 7 8 '/dev/oracleasm/disks/ASMDISK10' NAME DATAGROUP3_DISK10 9 ATTRIBUTE 'au_size'='1M', 10 'compatible.rdbms'='11.2', 11 'compatible.asm'='11.2', 12 'sector_size'='512'; Diskgroup created. SQL> SQL> SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
(四)刪除磁盤組
對於磁盤組使用alter diskgroup命令進行相應維護,但在磁盤組中無論是刪除磁盤、添加磁盤還是重置磁盤大小,那麼都是在線的不影響正常使用。在每次磁盤組信息進行改變的時候oracle都會自動的rebalance磁盤組中的數據,當我們執行alter diskgroup 之後的sql命令執行提示,並不是在完成rebalance數據之後才返回的。而是數據的rebalance是在後台進行的,如果要等到平衡數據完成 後才告知命令執行情況,可以考慮添加rebalance wait參數。另外要注意,當我們使用alter diskgoup命令的時候突然按ctrl+c,那麼oracle是不會取消磁盤的刪除、添加、重定義大小和平衡操作。而是在後台執行。
刪除磁盤組中的磁盤:
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> alter diskgroup datagroup3 drop disk DATAGROUP3_DISK10; SQL> alter diskgroup datagroup3 drop disk datagroup3_disk7; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 DROPPING FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
當我們進行磁盤組操作的時候,如果在刪除磁盤的時候需要取消,那麼可以使用alter diskgroup undrop disks命令,以此進行取消,類似於此時的磁盤數據restore
如下當磁盤狀態是droping的時候,再次執行undrop;
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 DROPPING FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%' G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 DROPPING FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> alter diskgroup datagroup3 undrop disks; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 1017 NORMAL FAILGROUP_3 QUORUM /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 992 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 991 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
刪除故障組中的所有磁盤:
注意:
A normal redundancy disk group must contain at least two failure groups. A high redundancy disk group must contain at least three failure groups.
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 994 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 989 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> alter diskgroup datagroup3 drop disks in failgroup failgroup_2; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 1003 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 999 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%' G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 1017 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 1017 DROPPING FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%' G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK8 0 1019 966 DROPPING FAILGROUP_2 REGULAR DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK9 0 1019 966 DROPPING FAILGROUP_2 REGULAR SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%' G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 SQL>
另外,如果刪除磁盤組的磁盤,那麼該磁盤組將故障磁盤的數據進行再次平衡,這時要保證磁盤空間足以容納故障磁盤的數據進行鏡像,否則會失敗。至此可以通過添加磁盤和刪除磁盤both的形式,保證磁盤組有足夠的空間完成數據的rebalance。
eg:
SQL> r 1 SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4* AND B.NAME LIKE 'DATAGROUP3%' G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 SQL> alter diskgroup datagroup3 drop disk datagroup3_disk10 add failgroup failgroup_2 disk '/dev/oracleasm/disks/ASMDISK8'; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_0001 1019 1019 966 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 SQL>
If you specify the FORCE clause for the drop operation, the disk is dropped even if Oracle ASM cannot read or write to the disk. You cannot use the FORCE flag when dropping a disk from an external redundancy disk group.
Caution:
A DROP FORCE operation leaves data at reduced redundancy until the subsequent rebalance operation completes. This increases your exposure to data loss if there is a subsequent disk failure during rebalancing. Use DROP FORCE with caution.(五)向磁盤組中添加磁盤和故障組
當向現有的磁盤組添加磁盤的時候也是在線的rebalance數據,可以通過v$asm_operation視圖查看進度:
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_0001 1019 1019 966 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 SQL> alter diskgroup datagroup3 add disk '/dev/oracleasm/disks/ASMDISK9' NAME datagroup3_disk9 ; Diskgroup altered. SQL> select b.group_number group_number, a.name name, 2 3 b.operation operation, 4 b.state state, 5 b.power power, 6 b.actual actual, 7 b.sofar sofar, 8 b.est_work ext_work, 9 b.est_rate est_rate, 10 b.est_minutes est_minutes 11 from v$asm_diskgroup a, v$asm_operation b 12 where a.group_number = b.group_number 13 and a.name like 'DATAGROUP3%'; GROUP_NUMBER NAME OPERA STAT POWER ACTUAL SOFAR EXT_WORK EST_RATE EST_MINUTES ------------ ------------------------- ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- 2 DATAGROUP3 REBAL RUN 2 2 2 69 265 0 SQL>
可以看到,目前添加磁盤組的狀態為rebalance,正在運行run,當時平衡力度為2,正常使用的為2,目前平衡了2個au,需要69個au進行rebalance,每分鐘可以完成265個au的平衡。
添加故障組:
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_0001 1019 1019 966 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 966 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> ALTER DISKGROUP DATAGROUP3 ADD FAILGROUP FAILGROUP_4 DISK '/dev/oracleasm/disks/ASMDISK10'; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_0003 1019 1019 982 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_0001 1019 1019 977 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 978 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 978 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 SQL>
(六)重置大小。
磁盤組的resize有如下情況
1、重置整個磁盤組所有磁盤的大小
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_0003 1019 1019 982 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_0001 1019 1019 977 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 978 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 978 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 SQL> SQL> SQL> SQL> alter diskgroup datagroup3 resize all size 512M; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_0003 1019 512 475 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_0001 1019 512 470 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 512 471 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9 DATAGROUP3 DATAGROUP3_DISK7 1019 512 471 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7
2、重置磁盤組中指定磁盤的大小
SQL> alter diskgroup datagroup3 resize disk datagroup3_0003 size 1019M; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER AND B.NAME LIKE 'DATAGROUP3%'; 4 G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_0003 1019 1019 979 NORMAL FAILGROUP_4 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_0001 1019 512 470 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 512 472 NORMAL DATAGROUP3_DISK9 REGULAR /dev/oracleasm/disks/ASMDISK9 DATAGROUP3 DATAGROUP3_DISK7 1019 512 473 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7
3、重置磁盤組中指定故障組中所有磁盤的大小。
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER AND B.NAME LIKE 'DATAGROUP3%'; 4 G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 993 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 990 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> alter diskgroup datagroup3 resize disks in failgroup failgroup_2 size 512M; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 512 485 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 512 484 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
當指定故障組中一個磁盤大小之後,重新指定故障組所有磁盤大小如果默認沒有size,那麼將按照最大的操作系統磁盤進行resize 。
If you do not specify a new size in the SIZE clause, then Oracle ASM uses the size of the disk as returned by the operating system.
eg:
SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 512 485 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 512 484 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> alter diskgroup datagroup3 resize disk datagroup3_disk8 size 1019M; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 986 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 512 490 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL> alter diskgroup datagroup3 resize disks in failgroup failgroup_2; Diskgroup altered. SQL> SELECT A.NAME G_NAME, B.NAME D_NAME,B.OS_MB,B.TOTAL_MB,B.FREE_MB,B.STATE, FAILGROUP, B.FAILGROUP_TYPE, PATH 2 FROM V$ASM_DISKGROUP A, V$ASM_DISK B 3 WHERE A.GROUP_NUMBER = B.GROUP_NUMBER 4 AND B.NAME LIKE 'DATAGROUP3%'; G_NAME D_NAME OS_MB TOTAL_MB FREE_MB STATE FAILGROUP FAILGRO PATH --------------- ------------------------- ---------- ---------- ---------- -------- ------------------------------ ------- ---------------------------------------- DATAGROUP3 DATAGROUP3_DISK10 1019 1019 966 NORMAL FAILGROUP_3 REGULAR /dev/oracleasm/disks/ASMDISK10 DATAGROUP3 DATAGROUP3_DISK7 1019 1019 966 NORMAL FAILGROUP_1 REGULAR /dev/oracleasm/disks/ASMDISK7 DATAGROUP3 DATAGROUP3_DISK8 1019 1019 990 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK8 DATAGROUP3 DATAGROUP3_DISK9 1019 1019 993 NORMAL FAILGROUP_2 REGULAR /dev/oracleasm/disks/ASMDISK9 SQL>
注意:oracle建議故障組大小最好保證一致提高更好的性能實用。
(七)手動平衡數據
可以通過手動執行alter diskgroup rebalance 進行數據的平衡,如果默認情況下不指定power,那麼將采用asm_power_limit參數值,如果手動將忽略參數文件中的該參數
如下:
SQL> show parameter asm_power_limit; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ asm_power_limit integer 2 SQL> alter diskgroup datagroup3 rebalance; Diskgroup altered. SQL> select b.group_number group_number, 2 a.name name, 3 b.operation operation, 4 b.state state, 5 b.power power, 6 b.actual actual, 7 b.sofar sofar, 8 b.est_work ext_work, 9 b.est_rate est_rate, 10 b.est_minutes est_minutes 11 from v$asm_diskgroup a, v$asm_operation b where a.group_number = b.group_number 12 13 and a.name like 'DATAGROUP3%'; GROUP_NUMBER NAME OPERA STAT POWER ACTUAL SOFAR EXT_WORK EST_RATE EST_MINUTES ------------ ------------------------- ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- 2 DATAGROUP3 REBAL REAP 2 2 0 0 0 0 SQL> SQL> alter diskgroup datagroup3 rebalance power 10; Diskgroup altered. SQL> select b.group_number group_number, 2 a.name name, 3 b.operation operation, 4 b.state state, 5 b.power power, 6 b.actual actual, 7 b.sofar sofar, 8 b.est_work ext_work, 9 b.est_rate est_rate, 10 b.est_minutes est_minutes 11 from v$asm_diskgroup a, v$asm_operation b 12 where a.group_number = b.group_number 13 and a.name like 'DATAGROUP3%'; GROUP_NUMBER NAME OPERA STAT POWER ACTUAL SOFAR EXT_WORK EST_RATE EST_MINUTES ------------ ------------------------- ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- 2 DATAGROUP3 REBAL REAP 10 10 0 0 0 0 SQL>
That's all !