在Linux 6上使用UDEV解决RAC ASM存储设备名问题

Maclean一直是使用UDEV替代ASMLIB做RAC存储设备名绑定的拥护者,相关的专题文章可以作为读者的预读知识是:
Why ASMLIB and why not?
利用UDEV服务解决RAC ASM存储设备名 

 

在《利用UDEV服务解决RAC ASM存储设备名 》一文中我推荐了自己写的一个脚本,该脚本会自动生成udev rule规则文件:

 

for i in b c d e f g h i j k ;
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id -g -u -s %p\", RESULT==\"`scsi_id -g -u -s /block/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""
done

 

以上脚本在Linux 5上是通用的, 但是有同学反映在redhat/Oracle Linux 6以上版本中该脚本失效了。

这是因为:

在OEL6或者RHEL6中,这一切都有所变化。

主要的变化是:
1. scsi_id的命令语法发生了变化,scsi_id -g -u -s这样的命令不再有效。
2. udevtest命令已经没有了,整合到了udevadm中。
How to use udev for Oracle ASM in Oracle Linux 6  

 

 

下面我提供改良后的脚本,可以在redhat/Oracle Linux 6上生成正确的udev rule 规则文件:

 

 

1.

#首先确认是 Linux 6.0以上版本

[root@vrh6 dev]# cat /etc/issue          
Oracle Linux Server release 6.2
Kernel \r on an \m

2.

#添加记录到/etc/scsi_id.config

echo "options=--whitelisted --replace-whitespace"  >> /etc/scsi_id.config

3. 

#确认哪些块设备需要udev绑定

[root@vrh6 dev]# ls -l sd*
brw-rw----. 1 root disk 8,  0 Jun 30 09:29 sda
brw-rw----. 1 root disk 8,  1 Jun 30 09:29 sda1
brw-rw----. 1 root disk 8,  2 Jun 30 09:29 sda2
brw-rw----. 1 root disk 8, 16 Jun 30 09:29 sdb
brw-rw----. 1 root disk 8, 32 Jun 30 09:29 sdc
brw-rw----. 1 root disk 8, 48 Jun 30 09:29 sdd
brw-rw----. 1 root disk 8, 64 Jun 30 09:29 sde
brw-rw----. 1 root disk 8, 80 Jun 30 09:29 sdf

例如在本实例中 sdb-> sdf的块设备需要绑定

4. 将 b->f的编号放入for 循环中,例如:
# AUTO UDEV RULE BY Maclean Liu 2012/06/30
for i in b c d e f ;
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""      
done

就会生成sdb->sdf 设备绑定的RULE,在将这些RULE写入到/etc/udev/rules.d/99-oracle-asmdevices.rules中

也可以直接利用以下脚本 ,写出RULE到99-oracle-asmdevices.rules

# AUTO UDEV RULE BY Maclean Liu 2012/06/30
for i in b c d e f ;
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""      >> /etc/udev/rules.d/99-oracle-asmdevices.rules
done

5. 之后运行用root运行/sbin/start_udev  即可

 

 

 

实际运行示例:

 

[root@vrh6 dev]# echo "options=--whitelisted --replace-whitespace"  >> /etc/scsi_id.config
[root@vrh6 dev]# for i in b c d e f ;
> do
> echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""      >> /etc/udev/rules.d/99-oracle-asmdevices.rules
> done
[root@vrh6 dev]# 

[root@vrh6 dev]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB09cadb31-cfbea255", NAME="asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB5f097069-59efb82f", NAME="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB4e1a81c0-20478bc4", NAME="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VBdcce9285-b13c5a27", NAME="asm-diske", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="1ATA_VBOX_HARDDISK_VB82effe1a-dbca7dff", NAME="asm-diskf", OWNER="grid", GROUP="asmadmin", MODE="0660"

[root@vrh6 dev]# 

[root@vrh6 dev]# /sbin/start_udev
Starting udev:                                             [  OK  ]

[root@vrh6 dev]# ls -l asm*
brw-rw----. 1 grid asmadmin 8, 16 Jun 30 09:34 asm-diskb
brw-rw----. 1 grid asmadmin 8, 32 Jun 30 09:34 asm-diskc
brw-rw----. 1 grid asmadmin 8, 48 Jun 30 09:34 asm-diskd
brw-rw----. 1 grid asmadmin 8, 64 Jun 30 09:34 asm-diske
brw-rw----. 1 grid asmadmin 8, 80 Jun 30 09:34 asm-diskf

Posted

in

by

Tags:

Comments

32 responses to “在Linux 6上使用UDEV解决RAC ASM存储设备名问题”

  1. luzp Avatar
    luzp

    为啥不用multipath呢?

    1. Maclean Liu Avatar

      在实际非多路径的情况下,不推荐使用multipath做设备绑定。

      1. coolzsb Avatar
        coolzsb

        为什么呢?是出于什么考虑?能给个具体案例吗?

        签名

        难道是为了减少不必要的服务?

  2. richardzgt Avatar
    richardzgt

    使用vmware,需要在vmx文件中加入: disk.EnableUUID = “TRUE”,否则UUID出不来

    1. Maclean Liu Avatar

      maclean推荐使用vbox 替代vmware, vmware 确实是有该问题,我在另一个帖子里也回复过这个问题,谢谢指出。

  3. […]  在Linux 6上使用UDEV解决RAC ASM存储设备名问题 利用UDEV服务解决RAC ASM存储设备名 Why ASMLIB and why not? 如何诊断ASMLIB故障 […]

  4. cuizj923 Avatar
    cuizj923

    我的环境是两台机器通过多路径的方式 共享一个存储。按照您提供的方法udev 帮定wwid.oracle 安装程度提示不是共享磁盘。我的操作步骤如下:

    From Configuring persistent storage in Red Hat Enterprise Linux 6

    1.Create /etc/scsi_id.config add

    options=–whitelisted –replace-whitespace

    2.Get UUID for disks you want to created ASM on

    scsi_id –whitelisted –replace-whitespace –device=/dev/sda

    [root@racnode2 rules.d]# multipath -ll
    mpathe (36000d3100055f5000000000000000043) dm-8 COMPELNT,Compellent Vol
    size=1.0T features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
    `-+- policy=’round-robin 0′ prio=1 status=active
    |- 1:0:3:2 sdg 8:96 active ready running
    |- 2:0:2:2 sdk 8:160 active ready running
    |- 1:0:2:2 sde 8:64 active ready running
    `- 2:0:3:2 sdm 8:192 active ready running
    mpathd (36000d3100055f5000000000000000044) dm-2 COMPELNT,Compellent Vol
    size=1.5T features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
    `-+- policy=’round-robin 0′ prio=1 status=active
    |- 1:0:3:1 sdf 8:80 active ready running
    |- 1:0:2:1 sdd 8:48 active ready running
    |- 2:0:2:1 sdj 8:144 active ready running
    `- 2:0:3:1 sdl 8:176 active ready running
    mpatha (36000d3100055f5000000000000000042) dm-7 COMPELNT,Compellent Vol
    size=5.0G features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
    `-+- policy=’round-robin 0′ prio=1 status=active
    |- 1:0:0:3 sdb 8:16 active ready running
    |- 1:0:1:3 sdc 8:32 active ready running
    |- 2:0:0:3 sdh 8:112 active ready running
    `- 2:0:1:3 sdi 8:128 active ready running

    [root@racnode1 rules.d]# multipath -ll
    mpathe (36000d3100055f5000000000000000042) dm-2 COMPELNT,Compellent Vol
    size=5.0G features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
    `-+- policy=’round-robin 0′ prio=1 status=active
    |- 1:0:1:3 sdc 8:32 active ready running
    |- 1:0:0:3 sdb 8:16 active ready running
    |- 2:0:0:3 sdh 8:112 active ready running
    `- 2:0:1:3 sdi 8:128 active ready running
    mpathc (36000d3100055f5000000000000000043) dm-7 COMPELNT,Compellent Vol
    size=1.0T features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
    `-+- policy=’round-robin 0′ prio=1 status=active
    |- 1:0:2:2 sde 8:64 active ready running
    |- 1:0:3:2 sdg 8:96 active ready running
    |- 2:0:2:2 sdk 8:160 active ready running
    `- 2:0:3:2 sdm 8:192 active ready running
    mpathb (36000d3100055f5000000000000000044) dm-8 COMPELNT,Compellent Vol
    size=1.5T features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw
    `-+- policy=’round-robin 0′ prio=1 status=active
    |- 1:0:3:1 sdf 8:80 active ready running
    |- 2:0:2:1 sdj 8:144 active ready running
    |- 1:0:2:1 sdd 8:48 active ready running
    `- 2:0:3:1 sdl 8:176 active ready running

    3. Create UDEV rules file

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

    PROGRAM add scsi_id command, RESULT is UUID

    KERNEL==”sd*”, BUS==”scsi”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”36000d3100055f5000000000000000042″,

    NAME=”asmdisk1″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″
    KERNEL==”sd*”, BUS==”scsi”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”36000d3100055f5000000000000000044″,

    NAME=”asmdisk2″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″

    KERNEL==\”sd*\”, BUS==\”scsi\”, PROGRAM==\”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/\$name\”, RESULT==\”`/sbin/scsi_id –whitelisted –replace-

    whitespace –device=/dev/sd$i`\”, NAME=\”asm-disk$i\”, OWNER=\”grid\”, GROUP=\”asmadmin\”, MODE=\”0660\””

    4.udevadm command can test UDEV configuration

    5.Start udev

    /sbin/start_udev

    6. Restart and check

    ls -l /dev/asm*

    [root@racnode1 dev]# ls -al
    total 4
    drwxr-xr-x. 18 root root 4380 Jan 28 17:41 .
    dr-xr-xr-x. 30 root root 4096 Jan 29 2013 ..
    brw-rw—-. 1 grid asmadmin 8, 32 Jan 29 2013 asmdisk1
    brw-rw—-. 1 grid asmadmin 8, 144 Jan 29 2013 asmdisk2

    [root@racnode2 dev]# ls -al
    total 4
    drwxr-xr-x. 18 root root 4380 Jan 29 09:42 .
    dr-xr-xr-x. 30 root root 4096 Jan 29 2013 ..
    brw-rw—-. 1 grid asmadmin 8, 128 Jan 29 2013 asmdisk1
    brw-rw—-. 1 grid asmadmin 8, 144 Jan 29 2013 asmdisk2

    Device Checks for ASM – This is a pre-check to verify if the specified devices meet the requirements for configuration through the Oracle Universal Storage Manager

    Configuration Assistant.? Error:
    ?-?
    “/dev/asmdisk1” is not shared ?- Cause:?Cause Of Problem Not Available ?- Action:?User Action Not Available
    ?-?
    racnode2:Unable to determine the sharedness of /dev/sdd on nodes: The problem occurred on nodes: racnode2 ?- Cause:?Cause Of Problem Not Available ?- Action:?User

    Action Not Available
    ?-?
    racnode1:Unable to determine the sharedness of /dev/sdf on nodes: The problem occurred on nodes: racnode1 ?- Cause:?Cause Of Problem Not Available ?- Action:?User

    Action Not Available

    Check Failed on Nodes: [racnode2, ?racnode1]
    Verification result of failed node: racnode2

    ?Details:
    ?-?
    Unable to determine the sharedness of /dev/asmdisk2 on nodes: [racnode2, racnode1] ?- Cause:?Cause Of Problem Not Available ?- Action:?User Action Not Available
    ?-?
    Unable to determine the sharedness of /dev/asmdisk1 on nodes: [racnode2, racnode1] ?- Cause:?Cause Of Problem Not Available ?- Action:?User Action Not Available
    ?-?
    PRVF-9802 : Attempt to get udev info from node “racnode2” failed ?- Cause:? Attempt to read the udev permissions file failed, probably due to missing permissions

    directory, missing or invalid permissions file, or permissions file not accessible to use account running the check. ?- Action:? Make sure that the udev permissions

    directory is created, the udev permissions file is available, and it has correct read permissions for access by the user running the check.
    Back to Top
    Verification result of failed node: racnode1

    ?Details:
    ?-?
    Unable to determine the sharedness of /dev/asmdisk2 on nodes: [racnode2, racnode1] ?- Cause:?Cause Of Problem Not Available ?- Action:?User Action Not Available
    ?-?
    Unable to determine the sharedness of /dev/asmdisk1 on nodes: [racnode2, racnode1] ?- Cause:?Cause Of Problem Not Available ?- Action:?User Action Not Available
    ?-?
    PRVF-9802 : Attempt to get udev info from node “racnode1” failed ?- Cause:? Attempt to read the udev permissions file failed, probably due to missing permissions

    directory, missing or invalid permissions file, or permissions file not accessible to use account running the check. ?- Action:? Make sure that the udev permissions

    directory is created, the udev permissions file is available, and it has correct read permissions for access by the user running the check.
    Back to Top

  5. […] 在Linux 6上使用UDEV解决RAC ASM存储设备名问题 […]

  6. admxy Avatar
    admxy

    你好,我的环境是virtualbox+rhel6.0+11gr2+rac 也按照你上面的方法来配置adm存储设备,但是在安装grid的时候就是发现不了asm磁盘,

  7. admxy Avatar
    admxy

    [root@rac1 ~]# ll /dev/asm*brw-rw—- 1 grid asmadmin 8, 17 May 13 11:05 /dev/asm-diskbbrw-rw—- 1 grid asmadmin 8, 33 May 13 11:05 /dev/asm-diskc请问,用udev后,是不是还需要安装oracle官网上的两个包啊oracleasmlib-2.0.4-1.el6.x86_64oracleasm-support-2.1.8-1.el6.x86_64操作系统发现的硬盘,是否要在进行start_udev之前就进行分区呢?

    1. Ask_Maclean_liu_Oracle Avatar

      RAC使用了UDEV之后 完全不需要 ASMLIB了!!

  8. frankying Avatar
    frankying

    很多情况下,生产不会用SCSI的,我发现/dev/disk/by-id 下面有对应的盘号,但是测试怎么也用不到UDEV中,绑定不上去,类似这样:vi /etc/udev/rules.d/99-oracle-asmdevices.rulesKERNEL==”/dev/disk/by-id/scsi-26131333933306632″, NAME=”asmdisk”, OWNER=”grid”, GROUP=”asmdba”, MODE=”0660″

  9. admxy Avatar
    admxy

    找到问题了,就是需要手动选一下路径,就会发现/dev 下面的asm盘,但是请问博主,这个手动指定asm盘的路径会影响rac的运行或者其他的一些情况吗?

    1. sync Avatar
      sync

      不会,ASMLIB不等于ASM

  10. dzq0371 Avatar
    dzq0371

    有人遇到过这样的问题吗?像这样的情况怎么处理?redhat6 多路径配置裸设备

  11. river Avatar
    river

    只能针对lun,而不能针对patition一个lun分3个分区,/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/sdb与/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/sdb[1-3]获取的值都是一样的。。。

  12. zl秋天的雪 Avatar

    问一下,使用这种方式,以后要添加磁盘的时候,需要停库重启么?

      1. LBJ Avatar
        LBJ

        在存储上新增加了5个LUN ,然后通过udev方式做了绑定,并能看到 /etc/udev/rules.d/99-oracle-asmdevices.rules的结果,但是最后一步要执行 /sbin/udev_start ,那么在udev服务重启的过程中不会对原有已经绑定的磁盘产生影响吗 ?
        虽然我在执行/sbin/udev_start 时 看到实例状态都为open ,但是还不清楚理论上为何这样? 有 理论上的一些说明吗?谢谢

  13. d.b.c.a Avatar
    d.b.c.a

    配置了DHS HDLM存储多路径之后,我在asmca 直接使用映射的磁盘来创建asm磁盘组,还需要使用udev来绑定之后,再创建asm磁盘组。谢谢

  14. d.b.c.a Avatar
    d.b.c.a

    udev所映射的盘,有多路径的功能吗

  15. oradbguy Avatar
    oradbguy

    查了下linux 6的文档 里面把关键字 “BUS” 替换为 “SUBSYSTEM” 了

  16. blue Avatar
    blue

    [root@rac1 rules.d]# more 99-oracle-asmdevices.rules KERNEL==”sd*5″, BUS==”scsi”, PROGRAM==”/sbin/scsi_id -g -u -s %p”, RESULT==”SATA_VBOX_HARDDISK_VB1f438a3a-b80b7cbe_”, NAME=”asm-disk5″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″KERNEL==”sd*6″, BUS==”scsi”, PROGRAM==”/sbin/scsi_id -g -u -s %p”, RESULT==”SATA_VBOX_HARDDISK_VB1f438a3a-b80b7cbe_”, NAME=”asm-disk6″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″KERNEL==”sd*7″, BUS==”scsi”, PROGRAM==”/sbin/scsi_id -g -u -s %p”, RESULT==”SATA_VBOX_HARDDISK_VB1f438a3a-b80b7cbe_”, NAME=”asm-disk7″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″KERNEL==”sd*8″, BUS==”scsi”, PROGRAM==”/sbin/scsi_id -g -u -s %p”, RESULT==”SATA_VBOX_HARDDISK_VB1f438a3a-b80b7cbe_”, NAME=”asm-disk8″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″[root@rac1 rules.d]# [root@rac1 rules.d]# ls -l /dev/asm*brw-rw—- 1 grid asmadmin 8, 37 Apr 8 13:11 /dev/asm-disk5brw-rw—- 1 grid asmadmin 8, 38 Apr 8 13:11 /dev/asm-disk6brw-rw—- 1 grid asmadmin 8, 39 Apr 8 13:11 /dev/asm-disk7brw-rw—- 1 grid asmadmin 8, 40 Apr 8 13:11 /dev/asm-disk8你好,麻烦问下,我用此方式绑定asm后,为什么权限明明正确,安装检查时却任然报:device checks for asm 属主属组不正确,而且说检查到的属主是root,不知道Oracle是通过那个脚本去检测的那个文件,还是直接用ll命令取的属主属组,不应该呀!

    1. Ask_Maclean_liu_Oracle Avatar

      你看到这个检测问题是一个bug

      1. blue Avatar
        blue

        谢谢回复,确实是个bug忽略该问题,安装正常。

  17. boyboyman Avatar
    boyboyman

    我使用udev进行绑定后,添加新的磁盘把新的磁盘的信息添加进99-oracle-asmdevices.rules ,后启动start_udev,成功完成但发现vip资源down了,请问使用udev进行绑定如何正确添加磁盘不影响crs其他的资源呢

    1. Ask_Maclean_liu_Oracle Avatar

      请参加我的RAC安装视频,正常使用udev绝对不会造成资源问题,而且配置udev一般也都在安装RAC之前就搞定了。

  18. busy Avatar
    busy

    看完你上面的文章有点不理解想请教,就是实际的环境中如果存在多路径访问存储。哪么同一个设备就会有两个设备名如/dev/sdc和/dev/sdd这两个的scsi_id是一样的,按上面配置方式用udev作配置后最后映射成/dev/asm-1这个设备有用到多路软件吗?有用到多路径访问存储吗?UDEV是把两个/dev/sd*映射成/dev/asm-1还是只要第一个?还是说直接用多路软件的mpath*作为asm的访问路径?

  19. 华快回答

    楼主用的是“iscsi”的命令。但是在实际生产中基本都是用的FC-SAN的存储,楼主的这个方法还可以使用吗?

  20. 沩妳而戰 Avatar

    您好我在安装的时候总提示ssh问题,但是我通过ssh互相访问没问题啊

  21. 沩妳而戰 Avatar

    还有您的rac安装视频在哪里可以下载得到??

Leave a Reply

Your email address will not be published. Required fields are marked *