for Linux 5.x
for i in b c d;
do
echo "KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="scsi_id -g -u -s /block/sd$i",, OWNER="grid", GROUP="asmadmin", MODE="0660""
done
使用的时候要注意在不同版本上脚本的区别,否则获取不到磁盘的scsi_id
[root@rac1 ]# /sbin/service ntpd stop
关闭 ntpd: [失败][root@rac1 ]# chkconfig ntpd off
[root@rac1 ]# mv /etc/ntp.conf /etc/ntp.conf.original
直接使用裸设备的方法:
1.在RHEL6以前的可以直接通过rawdevices的管理方法,系统安装后默认已存在/etc/init.d/rawdevices和/etc/sysconfig/rawdevices这两个文件。
1.在RHEL6中,系统里面虽然已经不存在/etc/sysconfig/rawdevices和/etc/init.d/rawdevices文件了,但是依然支持rawdevices的方式,可以通过如下方法来管理raw文件。
a.手动创建/etc/sysconfig/rawdevices和/etc/init.d/rawdevices文件,然后依然以rawdevices的方式
b.通过udev来管理raw,同样也可以通过udev固定磁盘对应的设备名
采用新建的方法
vi /etc/init.d/rawdevices
!/bin/bash
rawdevices This shell script assignes rawdevices to block devices
chkconfig: 345 56 44
description: This scripts assignes raw devices to block devices \
(such as hard drive partitions). This is for the use \
of applications such as Oracle. You can set up the \
raw device to block device mapping by editing \
the file /etc/sysconfig/rawdevices.
config: /etc/sysconfig/rawdevices
[ -f /bin/raw ] || exit 0
[ -f /etc/sysconfig/rawdevices ] || exit 0
Exit if the file just has the default comments.
LC_ALL=C /bin/egrep -q -v "^ #" /etc/sysconfig/rawdevices 2>/dev/null || exit 0
. /etc/init.d/functions
function assign_raw()
{
LC_ALL=C egrep -v '^ #' /etc/sysconfig/rawdevices |
while read RAW BLOCK; do
if [ -n "$RAW" -a -n "$BLOCK" ]; then
rawdirname=${RAW%/*}
if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then
echo $" Please correct your /etc/sysconfig/rawdevices:"
echo $" rawdevices are now located in the directory /dev/raw/ "
echo $" If the command 'raw' still refers to /dev/raw as a file."
echo $" you'll have to upgrade your util-linux package"
exit 0
fi
if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then
echo $" Please correct your /etc/sysconfig/rawdevices:"
echo $" rawdevices are now located in the directory /dev/raw/ "
echo $" If the command 'raw' still refers to /dev/raw as a file."
echo $" you'll have to upgrade your util-linux package"
exit 0
fi
echo " $RAW --> $BLOCK";
raw $RAW $BLOCK
fi
done
}
See how we were called.
case "$1" in
start)
# Assign devices
echo $"Assigning devices: "
assign_raw
添加以下两行(默认不存在),即默认情况下生成的裸设备为root所有,
所以必须修改属主,否则oracle用户无法使用裸设备
sleep 5
chown -R grid:asmadmin /dev/raw/
echo $"done"
;;
stop)
# No action to be taken here
;;
status)
ID=id -u
if [ $ID -eq 0 ]; then
raw -qa
else
echo $"You need to be root to use this command ! "
fi
;;
restart|reload)
$0 start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
--------------------------------------------------------------------------------
vi /etc/sysconfig/rawdevices //映射将要绑定的裸设备
/dev/raw/raw5 /dev/sdb
/dev/raw/raw6 /dev/sdc
/dev/raw/raw7 /dev/sdd
/dev/raw/raw8 /dev/sde
[root@rac1]# chkconfig rawdevices on
[root@rac1]# service rawdevices start
1.4 绑定裸设备(用于创建ASM磁盘组,更详细的内容请参考:)
[root@ydtest host2]# pwd
/sys/class/scsi_host/host2
[root@ydtest host2]# echo '- - -' > scan
[root@ydtest host2]#
[root@ydtest host2]# cd ../host0
[root@ydtest host0]# echo '- - -' > scan
虚拟机加盘后 扫描盘
[root@rac1]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 2172 17406427+ 8e Linux LVM
/dev/sda3 2173 2237 522112+ 82 Linux swap / Solaris
/dev/sda4 2238 3916 13486567+ 5 Extended
/dev/sda5 2238 2542 2449881 83 Linux
/dev/sda6 2543 2847 2449881 83 Linux
/dev/sda7 2848 3152 2449881 83 Linux
/dev/sda8 3153 3457 2449881 83 Linux
/dev/sda9 3458 3916 3686886 83 Linux
[root@rac1 rules.d]# cd /etc/udev/rules.d/
[root@rac1 rules.d]# vi 99-oracle.rules
ACTION=="add",KERNEL=="sdb",RUN+="/bin/raw /dev/raw/raw5 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
ACTION=="add",KERNEL=="sdc",RUN+="/bin/raw /dev/raw/raw6 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
ACTION=="add",KERNEL=="sdd",RUN+="/bin/raw /dev/raw/raw7 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
ACTION=="add",KERNEL=="sde",RUN+="/bin/raw /dev/raw/raw8 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
--重启udev,使配置生效
/sbin/start_udev
[root@rac1]# vi /etc/sysconfig/rawdevices
/dev/raw/raw5 /dev/sdb
/dev/raw/raw6 /dev/sdc
/dev/raw/raw7 /dev/sdd
/dev/raw/raw8 /dev/sde