在Linux 5/6上使用UDEV SCSI规则配置ASM DISK

下面来看看创建ASM disk所使用的必须步骤

1.识别磁盘(/sbin/scsi_id)
 
对于Oracle Linux 5, 使用以下命令.
    # /sbin/scsi_id -g -u -s /block/sdb
    SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
    # /sbin/scsi_id -g -u -s /block/sdc
    SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_

但是参数"-s"在Linux 6中已经废弃,使用如下命令
    # /sbin/scsi_id -g -u -d /dev/sdb
    SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
    # /sbin/scsi_id -g -u -d /dev/sdc
    SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_

2.添加SCSI设备信任关系

创建编辑"/etc/scsi_id.config" 文件t配置SCSI设备信任关系.
    options=-g

3.创建UDEV规则文件
创建"/etc/udev/rules.d/99-oracle-asmdevices.rules" file.

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

对于Oracle Linux 5, 使用以下编辑配置:

    KERNEL=="sdb1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/$parent", RESULT=="SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_", NAME="asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660"
    KERNEL=="sdc1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/$parent", RESULT=="SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_", NAME="asm-disk2", OWNER="oracle", GROUP="dba", MODE="0660"

对于Linux 6等价配置如下

    KERNEL=="sdb1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_", NAME="asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660"
    KERNEL=="sdc1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_", NAME="asm-disk2", OWNER="oracle", GROUP="dba", MODE="0660"

4.引导更新块设备分区(/sbin/partprobe)

引导更新块设备分区表.

    # /sbin/partprobe /dev/sdb1
    # /sbin/partprobe /dev/sdc1


5.测试规则Test Rules (udevtest)
测试规则文件是否生效
   # #Linux5
    # udevtest /block/sdb/sdb1
    # udevtest /block/sdc/sdc1


    # #Linux6
    # udevadm test /block/sdb/sdb1
    # udevadm test /block/sdc/sdc1

输出实例如下:

    # udevtest /block/sdb/sdb1
    main: looking at device '/block/sdb/sdb1' from subsystem 'block'
    udev_rules_get_name: add symlink 'disk/by-id/scsi-SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3-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) 'SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_'
    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 = '1200'
    udev_node_add: creating symlink '/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3-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/dm/multipath_event'
    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-SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3-part1 /dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1'
    #

6.重启UDEV服务
    # #Linux5
    # /sbin/udevcontrol reload_rules

    # #Linux6
    # udevadm control --reload-rules

    # #Linux5 and Linux6
    # /sbin/start_udev

7.检查属主关系和权限

    # cd /dev
    # ls -al asm-disk*
    brw-rw---- 1 oracle dba 8, 17 Apr  8 22:47 asm-disk1
    brw-rw---- 1 oracle dba 8, 33 Apr  8 22:47 asm-disk2
    #

因此ASM_DISKSTRING 初始化参数 可以设置为 '/dev/asm-disk*' 来识别 ASM disks.

你可能感兴趣的:(linux,udev,SCSI,56,ASMdisk)