重启或者 echo ‘—’ >/sys/class/scsi_host/host1/scan
备注:安全起见,操作之前停数据库实例、ASM实例
本次实施是在线执行
无法直接获取新磁盘UUID,需要关机后ssh登陆虚拟机主机修改.vmx文件增加 一行 disk.EnableUUID = “TRUE”
[root@YCPUBDB01 ~]# for i in d; 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 -s %p", RESULT=="", NAME="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE="0660"
[root@esxi-07:/vmfs/volumes/503d6571-6ee8b75a-5801-0025b501006f/YCPUBDB01] vi YCPUBDB01.vmx
scsi2:0.deviceType = "scsi-hardDisk"
scsi2:0.present = "TRUE"
scsi2:0.redo = ""
annotation = "autostartdb|0Ayc.2015/Welcome1|0APDE-DB|0A"
config.readOnly = "FALSE"
softPowerOff = "TRUE"
tools.remindInstall = "FALSE"
uuid.location = "56 4d 9c 0c 21 e8 e7 de-a2 f2 da b5 33 30 9a 0f"
monitor.phys_bits_used = "40"
scsi0:0.cvctkSize = "53687091200"
scsi1:0.cvctkSize = "64424509440"
scsi2:0.cvctkSize = "214748364800"
ctkEnabled = "TRUE"
scsi0:0.ctkEnabled = "TRUE"
scsi1:0.ctkEnabled = "TRUE"
ethernet0.networkName = "VLAN90"
scsi0:1.deviceType = "scsi-hardDisk"
scsi0:1.fileName = "YCPUBDB01.vmdk"
scsi0:1.ctkEnabled = "true"
sched.scsi0:1.shares = "normal"
sched.scsi0:1.throughputCap = "off"
scsi0:1.present = "true"
scsi0:1.redo = ""
disk.EnableUUID = "TRUE"
~
~
重新获取UUID
[root@YCPUBDB01 ~]# for i in d; 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 -s %p", RESULT=="3600601603e403100ca9d0ddb4cf3e111", NAME="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE="0660"
[root@YCPUBDB01 ~]# fdisk -l
Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 6527 52323705 8e Linux LVM
Disk /dev/sdb: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 7832 62909516 83 Linux
Disk /dev/sdd: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/dm-0: 42.6 GB, 42681237504 bytes
255 heads, 63 sectors/track, 5189 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
[root@YCPUBDB01 ~]# for i in b; 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 -s %p", RESULT=="36000c294e731447e231aed94d593883a", NAME="asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660"
[root@YCPUBDB01 ~]#
[root@YCPUBDB01 ~]# ll /dev/a
agpgart asm-diskc autofs
[root@YCPUBDB01 ~]# ll /dev/asm-diskc
brw-rw---- 1 grid asmadmin 8, 48 Mar 7 01:57 /dev/asm-diskc
[root@YCPUBDB01 ~]# vi /etc/udev/rules.d/99-oracle-asmdevices.rules
[root@YCPUBDB01 ~]# start_udev
Starting udev: [ OK ]
[root@YCPUBDB01 ~]# ll /dev/asm-disk*
brw-rw---- 1 grid asmadmin 8, 16 Mar 7 01:56 /dev/asm-diskb
brw-rw---- 1 grid asmadmin 8, 48 Mar 7 01:56 /dev/asm-diskc
[root@YCPUBDB01 ~]#
-- 向ASM磁盘组中加盘(grid用户的sysasm)
01:58:57 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 STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
1 0 ONLINE MEMBER ONLINE NORMAL 204800 144365 DATA01_0000 /dev/asm-diskc
0 0 ONLINE CANDIDATE ONLINE NORMAL 0 0 /dev/asm-diskb
Elapsed: 00:00:00.57
01:59:01 SQL>
02:00:33 SQL> select group_number,name,total_mb,free_mb from v$asm_diskgroup;
GROUP_NUMBER NAME TOTAL_MB FREE_MB
------------ ------------------------------ ---------- ----------
1 DATA01 204800 144365
Elapsed: 00:00:00.02
02:00:33 SQL> alter diskgroup DATA01 add disk '/dev/asm-diskb';
Diskgroup altered.
Elapsed: 00:00:03.73
02:00:59 SQL>
02:00:59 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 STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
1 0 ONLINE MEMBER ONLINE NORMAL 204800 144403 DATA01_0000 /dev/asm-diskc
1 1 ONLINE MEMBER ONLINE NORMAL 256000 255958 DATA01_0001 /dev/asm-diskb
Elapsed: 00:00:00.02
02:01:04 SQL>
--添加完磁盘之后,oracle会自动做重平衡rebalance操作,可以通过视图查看
02:01:04 SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- ----------------------------
1 REBAL RUN 1 1 990 33575 2491 13
Elapsed: 00:00:00.20
02:01:34 SQL>
--SOFAR:就是目前为止挪动的AU数量
--EST_WORK:估计要挪动的AU数量
--EST_RATE:估计每分钟挪动的AU数量
--EST_MINUTES:估计挪动多少分钟
--重平衡的过程就是从其他的磁盘向新磁盘挪动数据的过程,如果数据量很大,这个时间会很长,可以更改power值加快速度,默认power值为1,可根据存储性能将此值设置大一些(power取值0-11),数据平衡完毕复原power值即可
02:01:34 SQL> show parameter asm_power_limit
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
asm_power_limit integer 1
注:power=0是停止rebalance操作
也可在加盘时直接添加rebalance指令,如下:
SQL> alter diskgroup DATA01 rebalance power 11;
注:如添加磁盘报错(新增磁盘不为全新盘,有旧数据在里头),可使用dd命令将磁盘头信息清除掉
dd if=/dev/zero of=/dev/sdd bs=4096 count=256 --磁盘头信息大小一般是1M。
6、删除ASM磁盘
SQL> select GROUP_NUMBER,DISK_NUMBER, MODE_STATUS,HEADER_STATUS, MODE_STATUS,state,TOTAL_MB,FREE_MB,name,PATH from v$asm_disk;
07:19:06 SQL> select * from v$asm_operation;
no rows selected
Elapsed: 00:00:00.03
07:19:29 SQL> select state,name,type from v$asm_diskgroup;
STATE NAME TYPE
----------- ------------------------------ ------
MOUNTED DATA01 EXTERN
Elapsed: 00:00:00.05
07:57:01 SQL> select GROUP_NUMBER,DISK_NUMBER,TOTAL_MB,FREE_MB,NAME from v$asm_disk;
GROUP_NUMBER DISK_NUMBER TOTAL_MB FREE_MB NAME
------------ ----------- ---------- ---------- ------------------------------
1 0 204800 177943 DATA01_0000
1 1 256000 222434 DATA01_0001
Elapsed: 00:00:00.05
07:57:24 SQL>
08:00:58 SQL> select * from v$asm_operation;
no rows selected
Elapsed: 00:00:00.03
08:01:06 SQL> select GROUP_NUMBER,DISK_NUMBER,TOTAL_MB,FREE_MB,NAME from v$asm_disk;
GROUP_NUMBER DISK_NUMBER TOTAL_MB FREE_MB NAME
------------ ----------- ---------- ---------- ------------------------------
1 0 204800 177943 DATA01_0000
1 1 256000 222434 DATA01_0001
Elapsed: 00:00:00.03
08:01:25 SQL> select name,free_mb,total_mb from v$asm_disk;
NAME FREE_MB TOTAL_MB
------------------------------ ---------- ----------
DATA01_0000 177943 204800
DATA01_0001 222434 256000
Elapsed: 00:00:00.05
08:03:03 SQL> select group_number,operation,state,power from v$asm_operation;
no rows selected
Elapsed: 00:00:00.03
08:03:31 SQL> alter diskgroup DATA01 drop disk DATA01_0000 rebalance power 8;--按照name来删除
Diskgroup altered.
Elapsed: 00:00:04.45
08:04:31 SQL> select group_number,operation,state,power from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER
------------ ----- ---- ----------
1 REBAL RUN 8
Elapsed: 00:00:00.06
08:04:39 SQL>
08:04:39 SQL> select name,free_mb,total_mb,path,state,mount_status,header_status from v$asm_disk;
NAME FREE_MB TOTAL_MB PATH STATE MOUNT_S HEADER_STATU
------------------------------ ---------- ---------- ------------------------------------------------------------------
DATA01_0000 179464 204800 /dev/asm-diskc DROPPING CACHED MEMBER
DATA01_0001 220913 256000 /dev/asm-diskb NORMAL CACHED MEMBER
Elapsed: 00:00:00.03
08:04:53 SQL>
08:06:17 SQL> select group_number,operation,state,power from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER
------------ ----- ---- ----------
1 REBAL RUN 8
Elapsed: 00:00:00.06
08:06:53 SQL> /
no rows selected
Elapsed: 00:00:00.03
08:11:58 SQL> select * from v$asm_operation;
no rows selected
Elapsed: 00:00:00.03
09:12:49 SQL> select name,state,mount_status,header_status from v$asm_disk;
NAME STATE MOUNT_S HEADER_STATU
------------------------------ -------- ------- ------------
NORMAL CLOSED FORMER
DATA01_0001 NORMAL CACHED MEMBER
Elapsed: 00:00:00.05
--磁盘已删除但仍然识别
09:13:48 SQL>
09:13:48 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 STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
0 0 ONLINE FORMER ONLINE NORMAL 0 0 /dev/asm-diskc
1 1 ONLINE MEMBER ONLINE NORMAL 256000 195544 DATA01_0001 /dev/asm-diskb
Elapsed: 00:00:00.04
09:14:15 SQL>
[root@YCPUBDB01 ~]# vi /etc/udev/rules.d/99-oracle-asmdevices.rules
#KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="3600601603e403100ca9d0ddb4cf3e111", NAME="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="36000c294e731447e231aed94d593883a", NAME="asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660"
~
[root@YCPUBDB01 ~]# start_udev
Starting udev: [ OK ]
[root@YCPUBDB01 ~]# ll /dev/asm-disk*
brw-rw---- 1 grid asmadmin 8, 16 Mar 7 09:19 /dev/asm-diskb
09:18:32 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 STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
0 0 ONLINE FORMER ONLINE NORMAL 0 0 /dev/asm-diskc
1 1 ONLINE MEMBER ONLINE NORMAL 256000 195544 DATA01_0001 /dev/asm-diskb
Elapsed: 00:00:00.06
09:18:35 SQL> /
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
0 0 ONLINE FORMER ONLINE NORMAL 0 0 /dev/asm-diskc
1 1 ONLINE MEMBER ONLINE NORMAL 256000 195544 DATA01_0001 /dev/asm-diskb
Elapsed: 00:00:00.02
09:20:41 SQL>
09:20:43 SQL> /
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
0 0 ONLINE FORMER ONLINE NORMAL 0 0 /dev/asm-diskc
1 1 ONLINE MEMBER ONLINE NORMAL 256000 195544 DATA01_0001 /dev/asm-diskb
Elapsed: 00:00:00.03
09:20:46 SQL> /
GROUP_NUMBER DISK_NUMBER MODE_ST HEADER_STATU MODE_ST STATE TOTAL_MB FREE_MB NAME PATH
------------ ----------- ------- ------------ ------- -------- ---------- ---------- ------------------------------ ---
1 1 ONLINE MEMBER ONLINE NORMAL 256000 195544 DATA01_0001 /dev/asm-diskb
Elapsed: 00:00:00.03
09:21:22 SQL>