red hat linux 5使用udev绑定裸设备

在Linux操作系统上,一般会为光纤存储或者ISSCI存储设备设置一个持久性的名字,这个就是通过udev来实现的.red hat linux5比red hat linux4在udev的使用上有了一些改进.Universally Unique Identifiers也就是UUID是在分布式计算环境中识别计算机设备的标准方法.因此在Linux5版本采用了UUID来识别SCSI或者是光纤lUN.
下面以red hat linux5.7为例绑定SCSI设备为oracle使用:
1.修改/etc/scsi_id.config文件.把options=-b注释掉,加入options=-g,该选项保证所有连接的SCSI设备返回一个UUID.如果该文件不存在,可以手动创建一个.

# options=-b
  options=-g

2.查询指定设备的UUID.比如我们要用/dev/sdb和/dev/sdc来作为asm磁盘,那么执行下列命令:

[root@racdb1 ~]# scsi_id -g -u -s /block/sdb/sdb1
1ATA_VBOX_HARDDISK_VBdff3d588-fa8ea521_
[root@racdb1 ~]# scsi_id -g -u -s /block/sdc/sdc1
1ATA_VBOX_HARDDISK_VB737e91ee-347bd083_

3.创建udev规则文件,Program写我们要运行的PROGRAM命令,而RESULT就写我们运行完的结果.

#vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*",BUS=="scsi",PROGRAM=="/sbin/scsi_id -g -u -s %p",RESULT=="1ATA_VBOX_HARDDISK_VBdff3d588-fa8ea521_",NAME="asm-disk1",OWNER="grid",GROUP="asmadmin",MODE="0660"
KERNEL=="sd*",BUS=="scsi",PROGRAM=="/sbin/scsi_id -g -u -s %p",RESULT=="1ATA_VBOX_HARDDISK_VB737e91ee-347bd083_",NAME="asm-disk2",OWNER="grid",GROUP="asmadmin",MODE="0660"

4.测试udev是否绑定成功.如果绑定失败,会提示失败.

[root@racdb1 ~]# udevtest /block/sdb/sdb1
main: looking at device '/block/sdb/sdb1' from subsystem 'block'
udev_rules_get_name: add symlink 'disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBdff3d588-fa8e-part1'
udev_rules_get_name: add symlink 'disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1'
run_program: '/lib/udev/vol_id --export /dev/.tmp-8-17'
run_program: '/lib/udev/vol_id' returned with status 4
run_program: '/sbin/scsi_id -g -u -s /block/sdb/sdb1'
run_program: '/sbin/scsi_id' (stdout) '1ATA_VBOX_HARDDISK_VBdff3d588-fa8ea521_'
run_program: '/sbin/scsi_id' returned with status 0
udev_rules_get_name: rule applied, 'sdb1' becomes 'asm-disk1'
udev_device_event: device '/block/sdb/sdb1' already in database, validate currently present symlinks
udev_node_add: creating device node '/dev/asm-disk1', major = '8', minor = '17', mode = '0660', uid = '1100', gid = '1100'
udev_node_add: creating symlink '/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBdff3d588-fa8e-part1' to '../../asm-disk1'
udev_node_add: creating symlink '/dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1' to '../../asm-disk1'
main: run: 'socket:/org/kernel/udev/monitor'
main: run: '/lib/udev/udev_run_devd'
main: run: 'socket:/org/freedesktop/hal/udev_event'
main: run: '/sbin/pam_console_apply /dev/asm-disk1 /dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBdff3d588-fa8e-part1 /dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1'

5.重启udev服务.

# /sbin/udevcontrol reload_rules
# /sbin/start_udev

6.检查裸设备是否成功绑定,如果绑定成功,会在/dev下面看到

[root@racdb1 dev]# ls -l asm*
brw-rw---- 1 grid asmadmin 8, 17 Nov 12 16:08 asm-disk1
brw-rw---- 1 grid asmadmin 8, 33 Nov 12 16:08 asm-disk2
分享到: 更多

Post a Comment

Your email is never published nor shared. Required fields are marked *