oot 8, 48 Mar 24 20:46 /dev/sdd
brw-rw---- 1 root root 8, 64 Mar 24 20:46 /dev/sde
brw-rw---- 1 root root 8, 80 Mar 24 20:46 /dev/sdf
brw-rw---- 1 root root 8, 96 Mar 24 20:46 /dev/sdg
brw-r----- 1 root disk 8, 112 Mar 24 20:46 /dev/sdh
brw-rw---- 1 root root 8, 128 Mar 24 20:46 /dev/sdi
现在要将新添加的磁盘/dev/sdh设置为ASM共享磁盘,并且添加到磁盘组中。
2.[root@11grac1 rules.d]# pwd
/etc/udev/rules.d
[root@11grac1 rules.d]# for i in h; do echo 'KERNEL==\'sd*\',BUS==\'scsi\', PROGRAM==\'/sbin/scsi_id -g -u -s %p\',RESULT==\'`scsi_id -g -u -s /block/sd$i`\', NAME=\'asm-disk$i\',OWNER=\'grid\', GROUP=\'asmadmin\', MODE=\'0660\''; done
KERNEL=='sd*', BUS=='scsi', PROGRAM=='/sbin/scsi_id -g -u -sp',RESULT=='SATA_VBOX_HARDDISK_VBfeab29eb-3b887e7b_',NAME='asm-diskh', OWNER='grid', GROUP='asmadmin', MODE='0660'
[root@11grac1 rules.d]# vi 99-oracle-asmdevices.rules
添加如上一行信息到文件中
[root@11grac1 rules.d]# vi 99-oracle-asmdevices.rules
KERNEL=='sd*', BUS=='scsi', PROGRAM=='/sbin/scsi_id -g -u -s%p',RESULT=='SATA_VBOX_HARDDISK_VB132c7b61-b9c9f7fe_',NAME='asm-diskg',OWNER='grid', GROUP='asmadmin', MODE='0660'
KERNEL=='sd*', BUS=='scsi', PROGRAM=='/sbin/scsi_id -g -u -s%p',RESULT=='SATA_VBOX_HARDDISK_VBa246668a-4855c053_',NAME='asm-diski',OWNER='grid', GROUP='asmadmin', MODE='0660'
KERNEL=='sd*', BUS=='scsi', PROGRAM=='/sbin/scsi_id -g -u -s %p',RESULT=='SATA_VBOX_HARDDISK_VBfeab29eb-3b887e7b_',NAME='asmdiskh',OWNER='grid',GROUP='asmadmin', MODE='0660'
用udev进行绑定
[root@11grac1 rules.d]# start_udev
节点2上做同样的修改
[root@11grac2 rules.d]# start_udev
在两个节点上查看磁盘信息
root@11grac2 rules.d]# ls -l/dev/asm*
brw-rw---- 1 grid asmadmin 8, 16 Mar 25 03:39 /dev/asm-diskb
brw-rw---- 1 grid asmadmin 8, 32 Mar 25 03:39 /dev/asm-diskc
brw-rw---- 1 grid asmadmin 8, 48 Mar 25 03:39 /dev/asm-diskd
brw-rw---- 1 grid asmadmin 8, 64 Mar 24 20:46 /dev/asm-diske
brw-rw---- 1 grid asmadmin 8, 80 Mar 25 03:37 /dev/asm-diskf
brw-rw---- 1 grid asmadmin 8, 96 Mar 25 03:37 /dev/asm-diskg
brw-rw---- 1 grid asmadmin 8, 112 Mar 25 03:39 /dev/asm-diskh--新添加的ASM磁盘
brw-rw---- 1 grid asmadmin 8, 128 Mar 25 03:35 /dev/asm-diski
2.向磁盘组中添加磁盘/dev/asm-diskh
SQL> select GROUP_NUMBER,DISK_NUMBER, MODE_STATUS,HEADER_STATUS,MODE_STATUS,state,TOTAL_MB,FREE_MB,name,PATH from v$asm_disk;
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATETOTAL_MB FREE_MB
NAME PATH
------------ ----------- ------- ------------ ------- ------------------ ---------- -------------------- --------------
0 0 ONLINE CANDIDATE ONLINE NORMAL 0 0 /dev/asm-diskh
1 0 ONLINE MEMBER ONLINE NORMAL 5120 3406 BACKUP_DG_0000/dev/asm-diskg
2 0 ONLINE MEMBER ONLINE NORMAL 5120 1929 DATA_DG_0000/dev/asm-diskf
3 0 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0000/dev/asm-diskb
1 1 ONLINE MEMBER ONLINE NORMAL 5120 3400 BACKUP_DG_0001/dev/asm-diski
2 1 ONLINE MEMBER ONLINE NORMAL 5120 5118 DATA_DG_0001/dev/asm-diske
3 1 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0001/dev/asm-diskc
3 2 ONLINE MEMBER ONLINE NORMAL 5120 4810 SYS_DG_0002/dev/asm-diskd
SQL> alter diskgroup data_dg add disk '/dev/asm-diskh';
Diskgroup altered.
SQL> select GROUP_NUMBER,DISK_NUMBER,MODE_STATUS,HEADER_STATUS,MODE_STATUS,state,TOTAL_MB,FREE_MB,name,PATHfrom v$asm_disk;
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATETOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- ------------------ ----------
2 2 ONLINE MEMBER ONLINE NORMAL 5120 3525 DATA_DG_0002/dev/asm-diskh
1 0 ONLINE MEMBER ONLINE NORMAL 5120 3406 BACKUP_DG_0000/dev/asm-diskg
2 0 ONLINE MEMBER ONLINE NORMAL 5120 2513 DATA_DG_0000/dev/asm-diskf
3 0 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0000/dev/asm-diskb
1 1 ONLINE MEMBER ONLINE NORMAL 5120 3400 BACKUP_DG_0001/dev/asm-diski
2 1 ONLINE MEMBER ONLINE NORMAL 5120 5118 DATA_DG_0001/dev/asm-diske
3 1 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0001/dev/asm-diskc
3 2 ONLINE MEMBER ONLINE NORMAL 5120 4810 SYS_DG_0002/dev/asm-diskd
添加完磁盘之后,oracle会自动做重平衡rebalance操作,可以通过视图查看
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATEEST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- -------------------- ----------- -------
2 REBAL RUN 1 1 1593 1601 320 0
说明还在做重平衡的操作,重平衡的过程就是从其他的磁盘向新磁盘挪动数据的过程,如果数据量很大,这个时间会很长。
SOFAR:就是目前为止挪动的AU数量1593
EST_WORK:估计要挪动的AU数量1601
实际挪动5120-3525=1595MB,即1595个AU,即重平衡过程中需要大概挪到1595MB的数据。而且POWER默认是POWER
SQL> show parameter asm_power_limit
NAME TYPE VALUE
------------------------------------ -----------------------------------------
asm_power_limit integer 1
如果存储比较高端,可以将这个值设置大一点(power取值0-11),alter diskgroup data_dg rebalancepower 11; power=0就是停止rebalance操作。
EST_RATE:估计每分钟挪动的AU数量
EST_MINUTES:估计挪动多少分钟
Oracle执行重平衡的进程是ASMB,可以查看一下:
[grid@11grac1 ~]$ ps -ef|grep asmb
grid 21701 1 0 03:50 ? 00:00:05 asm_asmb_+ASM1
grid 21706 1 0 03:50 ? 00:00:12 oracle+ASM1_asmb_+asm1(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
过段时间查看,重平衡操作结束。
SQL> select * from v$asm_operation;
no rows selected
3.删除磁盘组
SQL> alter diskgroup data_dg drop disk 'DATA_DG_0002';--按照name来删除
Diskgroup altered.
SQL> select GROUP_NUMBER,DISK_NUMBER, MODE_STATUS,HEADER_STATUS,MODE_STATUS,state,TOTAL_MB,FREE_MB,name,PATH from v$asm_disk;
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATETOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- ------------------ ---------- -------------
2 2 ONLINE MEMBER ONLINE DROPPING 5120 3555 DATA_DG_0002/dev/asm-diskh
1 0 ONLINE MEMBER ONLINE NORMAL 5120 3406 BACKUP_DG_0000/dev/asm-diskg
2 0 ONLINE MEMBER ONLINE NORMAL 5120 3492 DATA_DG_0000/dev/asm-diskf
3 0 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0000/dev/asm-diskb
1 1 ONLINE MEMBER ONLINE NORMAL 5120 3400 BACKUP_DG_0001/dev/asm-diski
2 1 ONLINE MEMBER ONLINE NORMAL 5120 5118 DATA_DG_0001/dev/asm-diske
3 1 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0001/dev/asm-diskc
3 2 ONLINE MEMBER ONLINE NORMAL 5120 4810 SYS_DG_0002/dev/asm-diskd
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATEEST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- -------------------- ----------- -------
2 REBAL RUN 1 1 168 1601 204 7
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATEEST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- -------------------- ----------- -------
2 REBAL RUN 1 1 288 1601 239 5
SQL> select * from v$asm_operation;、
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATEEST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- -------------------- ----------- -
2 REBAL RUN 1 1 1275 1601 292 1
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATEEST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- -------------------- ----------- 2 REBAL RUN 1 1 1326 1601 290 0
SQL> select * from v$asm_operation;
no rows selected
大概需要挪动1601个AU才能完成重平衡。
SQL> select GROUP_NUMBER,DISK_NUMBER, MODE_STATUS,HEADER_STATUS,MODE_STATUS,state,TOTAL_MB,FREE_MB,name,PATH from v$asm_disk;
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATETOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- ------------------ ---------- -------------
0 0 ONLINE FORMER ONLINE NORMAL 0 0 /dev/asm-diskh
1 0 ONLINE MEMBER ONLINE NORMAL 5120 3406 BACKUP_DG_0000/dev/asm-diskg
2 0 ONLINE MEMBER ONLINE NORMAL 5120 1929 DATA_DG_0000/dev/asm-diskf
3 0 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0000/dev/asm-diskb
1 1 ONLINE MEMBER ONLINE NORMAL 5120 3400 BACKUP_DG_0001/dev/asm-diski
2 1 ONLINE MEMBER ONLINE NORMAL 5120 5118 DATA_DG_0001/dev/asm-diske
3 1 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0001/dev/asm-diskc
3 2 ONLINE MEMBER ONLINE NORMAL 5120 4810 SYS_DG_0002/dev/asm-diskd
FORMER - Disk was once part of a disk group but has been droppedcleanly from the group. It may be added to a new disk group withthe ALTER DISKGROUP statement.
4.重新添加该磁盘
SQL> alter diskgroup data_dg add disk '/dev/asm-diskh';
Diskgroup altered.
如果这步添加有错误,可以使用dd命令将磁盘头信息清除掉,通过如下方式:
dd if=/dev/zero of=/dev/sdd bs=4096 count=256 磁盘头信息大小一般是1M。
SQL> select GROUP_NUMBER,DISK_NUMBER, MODE_STATUS,HEADER_STATUS,MODE_STATUS,state,TOTAL_MB,FREE_MB,name,PATH from v$asm_disk;
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATETOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- ------------------ ---------- -------------------- ---------------
2 2 ONLINE MEMBER ONLINE NORMAL 5120 5070 DATA_DG_0002/dev/asm-diskh
1 0 ONLINE MEMBER ONLINE NORMAL 5120 3406 BACKUP_DG_0000/dev/asm-diskg
2 0 ONLINE MEMBER ONLINE NORMAL 5120 1977 DATA_DG_0000/dev/asm-diskf
3 0 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0000/dev/asm-diskb
1 1 ONLINE MEMBER ONLINE NORMAL 5120 3400 BACKUP_DG_0001/dev/asm-diski
2 1 ONLINE MEMBER ONLINE NORMAL 5120 5118 DATA_DG_0001/dev/asm-diske
3 1 ONLINE MEMBER ONLINE NORMAL 5120 4812 SYS_DG_0001/dev/asm-diskc
3 2 ONLINE MEMBER ONLINE NORMAL 5120 4810 SYS_DG_0002/dev/asm-diskd
手动执行重平衡操作
SQL> alter diskgroup data_dg rebalance power 8;
Diskgroup altered.
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATEEST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- -------------------- -------------------------------------------------------
2 REBAL RUN 8 8 113 1379 626 2
SQL> select * from v$asm_operation;
no rows selected
之前power=1时候,AU/min大概是300不到,power=8的时候,AU/min达到600多,明显快了一点。
总结:向磁盘组加盘减盘是一个IO繁忙的操作,建议放在业务空闲时间来做,可以通过设置power并行来加快rebalance的速度。