新添加的磁盘大小与原磁盘组中的磁盘大小相同;新添加的磁盘路径与原磁盘组中磁盘路径相同。
SQL> set pagesize 100
SQL> set line 100
SQL> col name for a15
SQL> select group_number,name,state,type,total_mb,usable_file_mb from v$asm_diskgroup;
GROUP_NUMBER NAME STATE TYPE TOTAL_MB USABLE_FILE_MB
------------ ------ ----------- ------ -------- --------------
1 DATA CONNECTED EXTERN 30720 5425
2 FRA CONNECTED EXTERN 2048 314
3 OCR MOUNTED EXTERN 4096 3698
SQL> set pagesize 200
SQL> set linesize 150
SQL> col path for a20
SQL> col group_name for a10
SQL> col name for a20
SQL> col failgroup_type for a15
SQL> col failgroup for a15
SQL> Select a.group_number,b.name as group_name,a.FAILGROUP,a.name,a.path,a.state,a.total_mb from v$asm_disk a,v$asm_diskgroup b where a.group_number=b.group_number;
GROUP_NUMBER GROUP_NAME FAILGROUP NAME PATH STATE TOTAL_MB
------------ ---------- ----------- --------- -------------------- -------- --------
3 OCR OCR_0000 OCR_0000 /u01/asm-disk/ocr1 NORMAL 2048
3 OCR OCR_0001 OCR_0001 /u01/asm-disk/ocr2 NORMAL 2048
2 FRA FRA_0000 FRA_0000 /u01/asm-disk/fra NORMAL 2048
1 DATA DATA_0000 DATA_0000 /u01/asm-disk/data NORMAL 30720
for DISK in $(awk '!/name/ {print $NF}' /proc/partitions); do echo -n "$DISK "; if [ $(hexdump -n10485760 /dev/$DISK | head | wc -l) -gt "3" ]; then echo "has data"; else echo "is empty"; fi; done;
sdf is empty
vim /etc/multipath.conf
multipath {
wwid 14f504e46494c4552416a4e6938672d363876662d6d636735
alias data5
path_grouping_policy multibus
}
}
vi /etc/udev/rules.d/11-dm-permissions-highgo.rules
注意:如RAC处于正在运行状态,不要执行start_udev进行修改,需手动执行 chown grid:asmadmin 进行修改。
systemctl restart multipathd.service
multipath -ll
ls -l /dev/dm-*
SQL> alter diskgroup DATA add disk '/u01/asm-disk/data5';
Diskgroup altered.
SQL> col path for a20;
SQL> col group_name for a10
SQL> col name for a20
SQL> col failgroup_type for a15
SQL> col failgroup for a15
SQL> select a.group_number,b.name as group_name,a.failgroup,a.name,a.state,a.total_mb from v$asm_disk a,v$asm_diskgroup b where a.group_number=b.group_number;
GROUP_NUMBER GROUP_NAME FAILGROUP NAME STATE TOTAL_MB
------------ ---------- --------------- -------------------- -------- ----------
3 OCR OCR_0000 OCR_0000 NORMAL 2048
3 OCR OCR_0001 OCR_0001 NORMAL 2048
2 FRA FRA_0000 FRA_0000 NORMAL 2048
1 DATA DATA_0000 DATA_0000 NORMAL 30720
2 DATA DATA_0001 DATA_0001 NORMAL 3072
3 DATA DATA_0002 DATA_0002 NORMAL 3072
4 DATA DATA_0003 DATA_0003 NORMAL 3072
5 DATA DATA_0004 DATA_0004 NORMAL 3072
重启后,新磁盘挂载正常,至此ASM添加新磁盘操作完成。
SQL> set pagesize 200
SQL> set linesize 150
SQL> col path for a20
SQL> col group_name for a10
SQL> col name for a20
SQL> col failgroup_type for a15
SQL> col failgroup for a15
SQL> select a.group_number,b.name as group_name,a.FAILGROUP,a.name,a.path,a.state,a.total_mb from v$asm_disk a,v$asm_diskgroup b where a.group_number=b.group_number;
GROUP_NUMBER GROUP_NAME FAILGROUP NAME STATE TOTAL_MB
------------ ---------- --------------- -------------------- -------- ----------
3 OCR OCR_0000 OCR_0000 NORMAL 2048
3 OCR OCR_0001 OCR_0001 NORMAL 2048
2 FRA FRA_0000 FRA_0000 NORMAL 2048
1 DATA DATA_0000 DATA_0000 NORMAL 30720
2 DATA DATA_0001 DATA_0001 NORMAL 3072
3 DATA DATA_0002 DATA_0002 NORMAL 3072
4 DATA DATA_0003 DATA_0003 NORMAL 3072
5 DATA DATA_0004 DATA_0004 NORMAL 3072
注意:删除磁盘前需要确认磁盘组中剩余的磁盘是否可以存放磁盘组中所有的数据。
sqlplus / as sysasm
SQL> alter diskgroup data drop disk 'DATA_0004';
Diskgroup altered.
注意:虽然命令已经结束,但是磁盘组还未完全删除,ASM在平衡磁盘组中的数据。
切记不能立即格式化删除的磁盘,等ASM平衡完成后在对磁盘进行操作。
SQL> select group_number,operation,power,est_work,est_minutes from v$asm_operation;
(查询无返回结果,表示数据平衡结束)
–v$asm_operation视图介绍:
GROUP_NUMBER:ASM正在平衡数据的磁盘组编号
OPERATION:ASM的操作类型,REBAL表示正在平衡数据
EST_WORK:预计需要平衡的单元数
EST_RATE:预计每分钟平衡的单元数
EST_MINUTES:预计剩余时间,分钟为单位
POWER:数据平衡时使用的进程数量,进程数量越多,重新平衡操作就越快,但会消耗更多的CPU和I/O资源,在业务繁忙时段,不要将此数值设置的过高,以免影响应用程序因系统资源 消耗过高而变慢。
POWER取值在0到11之间,其中0表示停止重新平衡,11是平衡的速度最快。
可以动态的调整此参数,但调整ASM_POWER_LIMIT只会影响未来的重新平衡,不影响正在进行的平衡。
–查看平衡进程数:
SQL> show parameter limit
NAME TYPE VALUE
------------------ -------- ----------
asm_power_limit integer 1
–为了改变进行中的平衡进程数,需要执行新的重新平衡命令:
SQL> alter diskgroup data rebalance power 2;
SQL> select path,header_status from v$asm_disk where path='/u01/asm-disk/data2';
PATH HEADER_STATU
---------------------- ------------
/u01/asm-disk/data5 FORMER
HEADER_STATU的值为FORMER时,表示磁盘已经完全从磁盘组中踢出。
HEADER_STATU的值为MEMBER时,表示磁盘还是当前磁盘组中的成员。
至此ASM删除磁盘操作完成。
[grid@rac-1 ~]$ crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 1863d2997e324f05bfefcaab366db799 (/u01/asm-disk/ocr1) [OCR]
2. ONLINE 86507776f53a4fb5bfab70772f8d3054 (/u01/asm-disk/ocr2) [OCR]
3. ONLINE 73d32c957c9e4fbabfd4882a8fd2c041 (/u01/asm-disk/ocr3) [OCR]
for DISK in $(awk '!/name/ {print $NF}' /proc/partitions); do echo -n "$DISK "; if [ $(hexdump -n10485760 /dev/$DISK | head | wc -l) -gt "3" ]; then echo "has data"; else echo "is empty"; fi; done;
--修改磁盘多路径
vim /etc/multipath.conf
multipaths {
multipath {
wwid VBOX_HARDDISK_VB59b14ffa-e7392b8a
alias fra
path_grouping_policy multibus
}
}
--修改磁盘属主
vi /etc/udev/rules.d/11-dm-permissions-highgo.rules
ENV{DM_NAME}=="ocr1", OWNER:="grid", GROUP:="asmadmin", MODE:="660", SYMLINK+="mapper/$env{DM_NAME}"
注意:不要执行start_udev
--查看磁盘属主
[root@rac-1 ~]# ls -l /dev/dm-*
brw-rw---- 1 grid asmadmin 253, 6 Nov 29 14:12 /dev/dm-6
su - grid
ln -s /dev/mapper/crs1 /u01/asm-disk/crs1
ln -s /dev/mapper/crs2 /u01/asm-disk/crs2
ln -s /dev/mapper/crs3 /u01/asm-disk/crs3
[grid@rac-1 ~]$ asmca
cd /u01/app/11.2.0/grid/bin
./ocrconfig -add +CRS
./ocrconfig -delete +OCR
--手动添加磁盘组
su - grid
crsctl replace votedisk +CRS
ocrcheck
crsctl query css votedisk
[grid@rac-1 ~]$ crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 76b7fc3b1c544fa9bf0947cc49036baf (/u01/asm-disk/crs1) [CRS]
2. ONLINE 0ff98b97f4144f80bf31ef95da207c20 (/u01/asm-disk/crs2) [CRS]
3. ONLINE 6ffa6c0d5fd24f80bf790c95ec280ca8 (/u01/asm-disk/crs3) [CRS]
[grid@rac-1 ~]$ sqlplus / as sysasm
SQL> show parameter spfile
NAME TYPE VALUE
------- ------ ------------------------------
spfile string +OCR/rac-cluster/asmparameterfile/registry.253.1049039589
[grid@rac-1 ~]$ sqlplus / as sysasm
SQL> create pfile='/home/grid/pfile.ora' from spfile;
SQL> create spfile='+CRS' from pfile='/home/grid/pfile.ora';
--RAC正常启动后,spfile位置已修改完成
[grid@rac-1 ~]$ sqlplus / as sysasm
SQL> show parameter spfile
NAME TYPE VALUE
------- ------ ------------------------------
spfile string +CRS/rac-cluster/asmparameterfile/registry.253.1049039589
--集群状态正常
[grid@rac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.FRA.dg
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.LISTENER.lsnr
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.OCR.dg
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.asm
ONLINE ONLINE rac1 Started
ONLINE ONLINE rac2 Started
ora.gsd
OFFLINE OFFLINE rac1
OFFLINE OFFLINE rac2
ora.net1.network
ONLINE ONLINE rac1
ONLINE ONLINE rac2
ora.ons
ONLINE ONLINE rac1
ONLINE ONLINE rac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE rac1
ora.cvu
1 ONLINE ONLINE rac1
ora.oc4j
1 ONLINE ONLINE rac1
ora.orcl.db
1 ONLINE ONLINE rac1 Open
2 ONLINE ONLINE rac2 Open
ora.rac1.vip
1 ONLINE ONLINE rac1
ora.rac2.vip
1 ONLINE ONLINE rac2
ora.scan1.vip
1 ONLINE ONLINE rac1