原文地址:
http://blog.itpub.net/21752515/viewspace-1063051/
linux磁盘重启乱序问题处理
最近到客户那去巡检时,客户提到一个问题,他们的rac在重启的时候,原来的sda1、sdb1、sdc1会对应变成sdd1、sde1、sdf1,由于他们使用的是盘符来绑定裸设备,所以启动后,经常要手动执行以下命令
[root@ractest1 ~]# raw /dev/raw/raw1 /dev/sda1
[root@ractest1 ~]# raw /dev/raw/raw2 /dev/sdb1
[root@ractest1 ~]# raw /dev/raw/raw3 /dev/sdc1
并且,比较奇怪的事,两边有时认得的盘完全不一样,一边是sda\b\c,另一边是sdd\e\f,这样,使oracle rac的共享盘出现问题。
在了解了他们的情况后,我基本上明白是什么原因,这种盘序错乱,与linux对磁盘的扫描机制有关,所以我们只能从另一角度去规避这样的问题,使用id号去绑定,这样就没有问题。在告诉他后,他同意我们对他原来的绑定方式进行修改,具体操作如下:
[root@ractest1 ~]# fdisk -l
Disk /dev/sdd: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 52216 419424988+ 83 Linux
Disk /dev/sde: 209 MB, 209715200 bytes
7 heads, 58 sectors/track, 1008 cylinders
Units = cylinders of 406 * 512 = 207872 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 1008 204595 83 Linux
Disk /dev/sdf: 209 MB, 209715200 bytes
7 heads, 58 sectors/track, 1008 cylinders
Units = cylinders of 406 * 512 = 207872 bytes
Device Boot Start End Blocks Id System
/dev/sdf1 1 1008 204595 83 Linux
可以看到,刚重启的节点1是sdd/sde/sdf
另一个节点的情况是:
[root@ractest2 ~]# fdisk -l
Disk /dev/sda: 429.4 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 52216 419424988+ 83 Linux
Disk /dev/sdb: 209 MB, 209715200 bytes
7 heads, 58 sectors/track, 1008 cylinders
Units = cylinders of 406 * 512 = 207872 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1008 204595 83 Linux
Disk /dev/sdc: 209 MB, 209715200 bytes
7 heads, 58 sectors/track, 1008 cylinders
Units = cylinders of 406 * 512 = 207872 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 1008 204595 83 Linux
分别在两台机子上执行如下命令:
[root@ractest2 ~] scsi_id -g -s /block/sda
360080e500017ff06000004054c47bd4a
[root@ractest2 ~] scsi_id -g -s /block/sdb
360080e500017fdd8000004c74c6344ef
[root@ractest2 ~] scsi_id -g -s /block/sdc
360080e500017ff060000044f4c63446e
[root@ractest1 ~] scsi_id -g -s /block/sdd
360080e500017ff06000004054c47bd4a
[root@ractest1 ~] scsi_id -g -s /block/sde
360080e500017fdd8000004c74c6344ef
[root@ractest1 ~] scsi_id -g -s /block/sdf
360080e500017ff060000044f4c63446e
能过对比,可以看到sda与sdd,sdb与sde,sdc与sdf是对应用的,所以我们启用udev,通过绑定id来规避这个问题!
[root@ractest1 ~]# cd /etc/udev/rules.d/
[root@ractest1 rules.d]# ls -a
. 50-udev.rules 60-pcmcia.rules 61-uinput-wacom.rules 90-hal.rules
.. 51-hotplug.rules 60-raw.rules 85-pcscd_ccid.rules 95-pam-console.rules
05-udev-early.rules 60-libsane.rules 60-wacom.rules 90-alsa.rules 98-kexec.rules
40-multipath.rules 60-net.rules 61-uinput-stddev.rules 90-dm.rules bluetooth.rules
[root@ractest1 rules.d]# vi 60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
# ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
# ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.
ACTION=="add", KERNEL=="sd*1", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="360080e500017ff060000044f4c63446e", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sd*1", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="360080e500017fdd8000004c74c6344ef", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sd*1", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="360080e500017ff06000004054c47bd4a", RUN+="/bin/raw /dev/raw/raw3 %N"
KERNEL=="raw[1-3]", OWNER="oracle", GROUP="dba", MODE="660"
[root@ractest1 rules.d]# start_udev
Starting udev: [ OK ]
[root@ractest1 rules.d]#
[root@ractest1 rules.d]# raw -qa
/dev/raw/raw1: bound to major 8, minor 81
/dev/raw/raw2: bound to major 8, minor 65
/dev/raw/raw3: bound to major 8, minor 49
同理,在另一台机,也进行同样的操作。
经过如上操作后,所有问题都解决了,不管怎么重启都不会有问题!