VirtualBox中实施ASM扩容实施记录

实施ASM在线扩容

1. 首先关闭集群
[root@node1 bin]# ./crsctl stop crs
 [root@node2 bin]# ./crsctl stop crs

关机,halt

再第一台主机上创建添加两块磁盘vdi,并设置共享,挂载给node2
asmn6.vdi 5G
asmn7.vdi 8G

2.开机挂载,为Oracle ASM 创建磁盘分区

[root@node1 dev]# ls -la sd*
brw-rw---- 1 root disk 8, 0 May 9 20:56 sda
brw-rw---- 1 root disk 8, 1 May 9 20:56 sda1
brw-rw---- 1 root disk 8, 2 May 9 20:56 sda2
brw-rw---- 1 root disk 8, 96 May 9 20:56 sdg
brw-rw---- 1 root disk 8, 112 May 9 20:56 sdh

[root@node1 ~]# fdisk -l

Disk /dev/sdg: 5368 MB, 5368709120 bytes

Disk /dev/sdh: 8589 MB, 8589934592 bytes

发现sdg,sdh两块盘

3.格式化分区:###也可以不用。
fdisk /dev/sdg
fdisk /dev/sdh

Command (m for help): n
e extended
p primary partition (1-4)p
Partition number (1-4): 1
First cylinder (1-512, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
calling ioctl() to re-read partition table.
Syncing disks.

第一种方法:用UDEV绑定裸设备

vi /etc/udev/rules.d/60-raw.rules

ACTION=="add",KERNEL=="sdg",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add",KERNEL=="sdh",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add",KERNEL=="raw[1-2]",OWNER="grid", GROUP="asmadmin", MODE="660"

查看裸设备:
raw -qa
/dev/raw/raw1: bound to major 8, minor 96
/dev/raw/raw2: bound to major 8, minor 112

传送到node2节点:
scp /etc/udev/rules.d/60-raw.rules node2:/etc/udev/rules.d/

partprobe
start_UDEV

第二种方法:UDEV绑定磁盘
for i in g 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 -s %p", RESULT=="360080e50003f55d6000007a7535c0dad", name="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="360080e50003f55d6000007a9535c0dd1", name="asm-diske", OWNER="grid", GROUP="asmadmin", MODE="0660"

vi /etc/udev/rules.d/99-oracle-asmdevices.rules

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="360080e50003f55d6000007a7535c0dad", name="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="360080e50003f55d6000007a9535c0dd1", name="asm-diske", OWNER="grid", GROUP="asmadmin", MODE="0660"

传输到其他节点。
scp /etc/udev/rules.d/99-oracle-asmdevices.rules jdserver24:/etc/udev/rules.d/
artprobe
start_udev
[root@quan-rac1 /]# ls -la /dev/a*
crw-rw---- 1 root audio 14, 12 Jul 26 12:58 /dev/adsp
brw-rw---- 1 oracle oinstall 8, 32 Jul 26 13:40 /dev/asm-diskg
brw-rw---- 1 oracle oinstall 8, 48 Jul 26 13:40 /dev/asm-diskh

4.ASM磁盘组操作

查看磁盘组状态:
select group_number,total_mb,required_mirror_free_mb,free_mb,usable_file_mb,state from v$asm_diskgroup;

GROUP_NUMBER TOTAL_MB REQUIRED_MIRROR_FREE_MB FREE_MB USABLE_FILE_MB STATE
------------ ---------- ----------------------- ---------- -------------- -----------
 1 1024 0 922 922 MOUNTED
 2 1024 0 748 748 MOUNTED
 3 3072 0 468 468 MOUNTED
 4 1024 0 628 628 MOUNTED

--TOTAL_MB: 磁盘组的大小
--FREE_MB : 在不考虑冗余的情况下,剩余的空间大小
--USABLE_FILE_MB:1).在外部冗余情况下 USABLE_FILE_MB=FREE_MB
 2).普通冗余 USABLE_FILE_MB=FREE_MB/2
 3).高冗余 USABLE_FILE_MB=FREE_MB/3

select group_number,disk_number,name,failgroup,state,path from v$asm_disk order by 1,2;

SELECT GROUP_NUMBER, OPERATION, STATE,POWER,EST_MINUTES FROM V$ASM_OPERATION;

检查asm_diskstring,看新加的磁盘是否在相应的目录下
show parameter asm_diskstring

设置asm_diskstring
alter system set asm_diskstring='/dev/asm*','/dev/raw/raw*' sid='*';

ASM_DISKSTRING = 'path1'[,'path2', . . .]
用最简单的话说,就是设置ASM启动时检查的磁盘,该选项可以同时指定多个值,并且支持通配符。比如说,只检查/dev/dsk/下的设备,可以设置该参数如下:/dev/dsk/*,默认情况下该参数为空,为空的话,表示ASM将查找系统中所有ASM拥有读写权限的设备。
ASM_DISKSTRING specifies an operating system-dependent value used by Automatic Storage Management to limit the set of disks considered for discovery. When a new disk is added to a disk group, each Automatic Storage Management instance that has the disk group mounted must be able to discover the new disk using the value of ASM_DISKSTRING.
An attempt to dynamically modify ASM_DISKSTRING will be rejected and the old value retained if the new value cannot be used to discover a disk that is in a disk group that is already mounted.


创建外部冗余磁盘组:
create diskgroup AUX_DATA external redundancy disk '/dev/asm-diskg','/dev/asm-diskh';

给现有磁盘组添加磁盘:
alter diskgroup DT02 add disk '/dev/raw/raw1','/dev/raw/raw2' rebalance power 10;

select * from v$asm_opration;

注意:
新添加的asmdiskgroup并不能在实例重启后自动mount,原因在于asm采用pfile启动实例 默认会去找asm_diskgroups参数所列出diskgroup并在实例启动时执行mount.
为了避免有些diskgroup不能自动mount,可采用如下两种办法:
手工修改pfile, asm_diskgroups改成PROD_DATA,AUX_DATA
创建spfile:create spfile from pfile;
alter system set asm_diskgroups=PROD_DATA,AUX_DATA sid='*';

最终:
SQL> select GROUP_NUMBER,DISK_NUMBER,NAME,PATH,TOTAL_MB,FREE_MB from v$asm_disk order by NAME;

相关推荐