# 使用grid用户(asmadmin角色用户)
[root@rac1 ~]# su grid
# 加载~/.bash_profile文件中的环境变量
[grid@rac1 ~]$ source ~/.bash_profile
# 修改环境变量,一般已经配置在~/.bash_profile文件中,变量值按实际安装情况修改
[grid@rac1 ~]$ export ORACLE_SID=+ASM1
[grid@rac1 ~]$ export ORA_CRS_HOME=/u01/app/gridhome/11.2.0.4
[grid@rac1 ~]$ export ORACLE_HOME=/u01/app/gridhome/11.2.0.4
# 进入asmcmd命令行
[grid@rac1 ~]$ asmcmd
# lsdg命令查看asm磁盘使用情况
ASMCMD> lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 4096 1048576 512000 373400 0 373400 0 N ARCHDG/
MOUNTED EXTERN N 512 4096 1048576 10240 9836 0 9836 0 Y CRSDG/
MOUNTED EXTERN N 512 4096 1048576 512000 0 0 512000 0 N DATADG/
# 可以看到数据盘DATADG已没有可用空间(Free_MB为0)
-- 使用sysasm身份登录
[grid@rac1 ~]# sqlplus /nolog
SQL> conn / as sysasm
-- 查看磁盘组
SQL> col name format a10
SQL> select group_number,name,state from v$asm_diskgroup;
GROUP_NUMBER NAME STATE
------------ -------------------- -----------
1 ARCHDG MOUNTED
2 CRSDG MOUNTED
3 DATADG MOUNTED
-- 查看磁盘
SQL> col path format a20
SQL> select group_number,name,path,mount_status from v$asm_disk;
GROUP_NUMBER NAME PATH MOUNT_S
------------ --------------- ---------------------- -------
0 /dev/mapper/asm-disk3 CLOSED
1 ARCHDG_0000 /dev/mapper/asm-disk1 CACHED
2 CRSDG_0000 /dev/mapper/asm-crs1 CACHED
2 CRSDG_0001 /dev/mapper/asm-crs2 CACHED
3 DATADG_0000 /dev/mapper/asm-disk2 CACHED
-- 可以看到GROUP_NUMBER为0,NAME为空,MOUNT_STATUS为CLOSED,就是新加的磁盘
SQL> alter diskgroup DATADG add disk '/dev/mapper/asm-disk3' rebalance power 5;
-- 查看rebalance重平衡的状态和剩余时间(EST_MINUTES为估算的再平衡时间)
SQL> select GROUP_NUMBER,OPERATION,STATE,POWER,EST_MINUTES from gv$asm_operation;
GROUP_NUMBER OPERA STAT POWER EST_MINUTES
------------ ----- ---- ---------- -----------
3 REBAL WAIT 5
3 REBAL RUN 5 17
-- 平衡后修改回来
SQL> alter diskgroup DATADG rebalance power 1;
注:rebalance power的级别从1到11中选择一个数值;数值越大,rebalance速度越快,对现有运行系统影响也越大。需要根据当时业务权衡选择适合的级别;
# 查看未挂载的盘,df -h查看已挂载的盘,lsblk对比df -h中未挂载的盘
[root@rac1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 1010G 8.0G 951G 1% /
tmpfs 253G 536M 252G 1% /dev/shm
/dev/sda1 485M 38M 422M 9% /boot
[root@rac1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.1T 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:5 0 1T 0 part /
└─sda3 8:3 0 32G 0 part [SWAP]
sdb 8:32 0 500G 0 disk
└─asm-disk2 (dm-0) 253:0 0 500G 0 mpath
sdc 8:160 0 500G 0 disk
└─asm-disk2 (dm-0) 253:0 0 500G 0 mpath
# 例.查看磁盘sda的wwid号(用于配置多路径)
[root@rac1 ~]# /sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sda
[root@rac1 ~]# vim /etc/multipath.conf
直接创建(oracle 11g 开始能用)
# 修改磁盘所有者及权限
[root@rac1 ~]# ls -l /dev/sdb
brw-r----- 1 root disk 8, 16 Jun 22 09:56 /dev/sdb
[root@rac1 ~]# chown grid:asmadmin /dev/sdb
[root@rac1 ~]# chmod 660 /dev/sdb
[root@rac1 ~]# ls -l /dev/sdb
brw-rw---- 1 grid asmadmin 8, 16 Jun 22 09:56 /dev/sdb
这样子就能在添加asm磁盘的时候认到,不过会报PRVF-5184,忽视直接执行
有两点需要注意,一般来说能作为asm磁盘的都是c设备,也就是字符设备,而使用/dev/sdb时没有这个限制。
另外oracle 11g后所有磁盘的权限是 grid:asmadmin 660,10g时是oracle:oinstall 600