创建ASM磁盘及配置ASMlib驱动
创建ASM磁盘有3种方法
1.配置裸设备映射,修改/etc/udev/rules.d/60-raw.rules文件。
2.采用(root帐户)直接修改/etc/sysconfig/rawdevices 方式来增加磁盘
3.使用asmlib来创建asm磁盘
在Vmware分配几个空闲的磁盘用于创建ASM磁盘,建议使用不同的磁盘控制器
下面使用个磁盘来组建ASM磁盘组,分别为sdd,sde,sdf,sdg。
使用fdisk分别对每个磁盘进行分区,由于不使篇幅过长,只列出对sdd的分区样例
[root@rac1 ~]# fdisk /dev/sdd
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
创建ASM磁盘(三种方法)
1.配置裸设备映射,修改/etc/udev/rules.d/60-raw.rules文件
使用root帐户修改/etc/udev/rules.d/60-raw.rules 按如下方式添加磁盘
[root@rac1 ~]# vi /etc/udev/rules.d/60-raw.rules --添加如下内容
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw/dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw/dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="17", RUN+="/bin/raw/dev/raw/raw2 %M %m"
[root@rac1 ~]# start_udev #重启udev服务
Starting udev: [ OK ]
[root@rac1 ~]# ll /dev/raw
total 0
crw------- 1 root root 162, 1 Nov 10 18:50 raw1
crw------- 1 root root 162, 2 Nov 10 18:50 raw2
[root@rac1 ~]# chown Oracle:dba /dev/raw/raw[1-2] --修改属主,否则创建磁盘组时提示权限不够
2.也可以采用下面的方式来增加磁盘,即直接修改/etc/sysconfig/rawdevices (root帐户)
[root@rac1 ~]# vi /etc/sysconfig/rawdevices 增加如下内容
raw3,raw4
/dev/raw/raw3 /dev/sdf1
/dev/raw/raw4 /dev/sdg1
[root@rac1 ~]# chown oracle:dba /dev/raw/raw[3-4] --修改属主,否则创建磁盘组时提示权限不够
[root@rac1 ~]# ll /dev/raw/
total 0
crw------- 1 oracle dba 162, 1 Nov 10 20:12 raw1
crw------- 1 oracle dba 162, 2 Nov 10 20:12 raw2
crw------- 1 oracle dba 162, 3 Nov 10 20:12 raw3
crw------- 1 oracle dba 162, 4 Nov 10 20:12 raw4
重启裸设备服务
[root@rac1 ~]# /sbin/service rawdevices restart
Assigning devices:
/dev/raw/raw3 --> /dev/sdf1
/dev/raw/raw3: bound to major 8, minor 81
/dev/raw/raw4 --> /dev/sdg1
/dev/raw/raw4: bound to major 8, minor 97
done
重新启动Linux 主机后,ASM磁盘属主性质已发生变化。
[root@rac1 ~]# ls -hlt /dev/raw # LINUX主机重新启动之后属主性质已发生变化
total 0
crw------- 1 root root 162, 4 Nov 10 20:28 raw4
crw------- 1 root root 162, 3 Nov 10 20:28 raw3
crw------- 1 root root 162, 2 Nov 10 20:28 raw2
crw------- 1 root root 162, 1 Nov 10 20:28 raw1
原因:原始设备在引导时会重新映射。默认情况下,在引导时原始设备的拥有者将更改为root 用户
将下面的内容增加到/etc/rc.local文件(root帐户),重新启动主机,使得属主变为oracle,则不再出现类似的提示
chown oracle:dba /dev/raw/raw1
chown oracle:dba /dev/raw/raw2
chown oracle:dba /dev/raw/raw3
chown oracle:dba /dev/raw/raw4
chmod 660 /dev/raw/raw1
chmod 660 /dev/raw/raw2
chmod 660 /dev/raw/raw3
chmod 660 /dev/raw/raw4
3.使用asmlib来创建asm磁盘
使用root帐户配置ASMLib驱动及创建ASM磁盘,Oracle建议使用ASMLIB驱动来配置ASM磁盘
[root@rac1 ~]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
--注意下面创建磁盘前本人重新对磁盘分过区
[root@rac1 ~]# ls /dev/oracleasm/disks
[root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1
Marking disk "VOL1" as an ASM disk: [ OK ]
[root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd2
Marking disk "VOL2" as an ASM disk: [ OK ]
[root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "VOL3" as an ASM disk: [ OK ]
[root@rac1 ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sde2
Marking disk "VOL4" as an ASM disk: [ OK ]
[root@rac1 ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
下一节介绍创建ASM磁盘组