利用UDEV服务解决RAC ASM存储设备名

<Why ASMLIB and why not?>我们介绍了使用ASMLIB作为一种专门为Oracle Automatic Storage Management特性设计的内核支持库(kernel support library)的优缺点,同时建议使用成熟的UDEV方案来替代ASMLIB。

这里我们就给出配置UDEV的具体步骤,还是比较简单的:

1.确认在所有RAC节点上已经安装了必要的UDEV包

[root@rh2 ~]# rpm -qa|grep udev
udev-095-14.21.el5

2.通过scsi_id获取设备的块设备的唯一标识名,假设系统上已有LUN sdc-sdp

for i in c d e f g h i j k l m n o p ;
do
echo "sd$i" "`scsi_id -g -u -s /block/sd$i` ";
done

sdc 1IET_00010001
sdd 1IET_00010002
sde 1IET_00010003
sdf 1IET_00010004
sdg 1IET_00010005
sdh 1IET_00010006
sdi 1IET_00010007
sdj 1IET_00010008
sdk 1IET_00010009
sdl 1IET_0001000a
sdm 1IET_0001000b
sdn 1IET_0001000c
sdo 1IET_0001000d
sdp 1IET_0001000e 

以上列出于块设备名对应的唯一标识名

3.创建必要的UDEV配置文件,

首先切换到配置文件目录

[root@rh2 ~]# cd /etc/udev/rules.d

定义必要的规则配置文件

[root@rh2 rules.d]# touch 99-oracle-asmdevices.rules 

[root@rh2 rules.d]# cat 99-oracle-asmdevices.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010001", NAME="ocr1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010002", NAME="ocr2", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010003", NAME="asm-disk1",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010004", NAME="asm-disk2",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010005", NAME="asm-disk3",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010006", NAME="asm-disk4",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010007", NAME="asm-disk5",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010008", NAME="asm-disk6",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_00010009", NAME="asm-disk7",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_0001000a", NAME="asm-disk8",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_0001000b", NAME="asm-disk9",  OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_0001000c", NAME="asm-disk10", OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_0001000d", NAME="asm-disk11", OWNER="grid",  GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="1IET_0001000e", NAME="asm-disk12", OWNER="grid",  GROUP="asmadmin", MODE="0660"

Result 为/sbin/scsi_id -g -u -s %p的输出--Match the returned string of the last PROGRAM call. This key may be
used in any following rule after a PROGRAM call.
按顺序填入刚才获取的唯一标识名即可

OWNER为安装Grid Infrastructure的用户,在11gr2中一般为grid,GROUP为asmadmin
MODE采用0660即可

NAME为UDEV映射后的设备名,
建议为OCR和VOTE DISK创建独立的DISKGROUP,为了容易区分将该DISKGROUP专用的设备命名为ocr1..ocrn的形式
其余磁盘可以根据其实际用途或磁盘组名来命名

4.将该规则文件拷贝到其他节点上
[root@rh2 rules.d]# scp 99-oracle-asmdevices.rules Other_node:/etc/udev/rules.d

5.在所有节点上启动udev服务,或者重启服务器即可

[root@rh2 rules.d]# /sbin/udevcontrol reload_rules
[root@rh2 rules.d]# /sbin/start_udev
Starting udev:                                            [  OK  ]

6.检查设备是否到位

[root@rh2 rules.d]# cd /dev
[root@rh2 dev]# ls -l ocr*
brw-rw---- 1 grid asmadmin 8, 32 Jul 10 17:31 ocr1
brw-rw---- 1 grid asmadmin 8, 48 Jul 10 17:31 ocr2

[root@rh2 dev]# ls -l asm-disk*
brw-rw---- 1 grid asmadmin 8,  64 Jul 10 17:31 asm-disk1
brw-rw---- 1 grid asmadmin 8, 208 Jul 10 17:31 asm-disk10
brw-rw---- 1 grid asmadmin 8, 224 Jul 10 17:31 asm-disk11
brw-rw---- 1 grid asmadmin 8, 240 Jul 10 17:31 asm-disk12
brw-rw---- 1 grid asmadmin 8,  80 Jul 10 17:31 asm-disk2
brw-rw---- 1 grid asmadmin 8,  96 Jul 10 17:31 asm-disk3
brw-rw---- 1 grid asmadmin 8, 112 Jul 10 17:31 asm-disk4
brw-rw---- 1 grid asmadmin 8, 128 Jul 10 17:31 asm-disk5
brw-rw---- 1 grid asmadmin 8, 144 Jul 10 17:31 asm-disk6
brw-rw---- 1 grid asmadmin 8, 160 Jul 10 17:31 asm-disk7
brw-rw---- 1 grid asmadmin 8, 176 Jul 10 17:31 asm-disk8
brw-rw---- 1 grid asmadmin 8, 192 Jul 10 17:31 asm-disk9

关注dbDao.com的新浪微博

扫码关注dbDao.com 微信公众号:

Comments

  1. maclean says:

    写了一段直接获得语句的脚本

    
    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
    
    
  2. maclean says:

    VBoxManage createhd –filename asm1.vdi –size 40960 –format VDI –variant Fixed
    VBoxManage createhd –filename asm2.vdi –size 40960 –format VDI –variant Fixed
    VBoxManage createhd –filename asm3.vdi –size 40960 –format VDI –variant Fixed
    VBoxManage createhd –filename asm4.vdi –size 5120 –format VDI –variant Fixed
    VBoxManage createhd –filename asm5.vdi –size 5120 –format VDI –variant Fixed
    VBoxManage createhd –filename asm6.vdi –size 5120 –format VDI –variant Fixed
    VBoxManage createhd –filename asm7.vdi –size 5120 –format VDI –variant Fixed
    VBoxManage createhd –filename asm8.vdi –size 5120 –format VDI –variant Fixed
    VBoxManage createhd –filename asm9.vdi –size 5120 –format VDI –variant Fixed
    VBoxManage createhd –filename asma.vdi –size 5120 –format VDI –variant Fixed

    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 1 –device 0 –type hdd –medium asm1.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 2 –device 0 –type hdd –medium asm2.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 3 –device 0 –type hdd –medium asm3.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 4 –device 0 –type hdd –medium asm4.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 5 –device 0 –type hdd –medium asm5.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 6 –device 0 –type hdd –medium asm6.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 7 –device 0 –type hdd –medium asm7.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 8 –device 0 –type hdd –medium asm8.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 9 –device 0 –type hdd –medium asm9.vdi –mtype shareable
    VBoxManage storageattach vrh1 –storagectl “SATA Controller” –port 10 –device 0 –type hdd –medium asma.vdi –mtype shareable

    VBoxManage modifyhd asm1.vdi –type shareable
    VBoxManage modifyhd asm2.vdi –type shareable
    VBoxManage modifyhd asm3.vdi –type shareable
    VBoxManage modifyhd asm4.vdi –type shareable
    VBoxManage modifyhd asm5.vdi –type shareable
    VBoxManage modifyhd asm6.vdi –type shareable
    VBoxManage modifyhd asm7.vdi –type shareable
    VBoxManage modifyhd asm8.vdi –type shareable
    VBoxManage modifyhd asm9.vdi –type shareable
    VBoxManage modifyhd asma.vdi –type shareable

    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 1 –device 0 –type hdd –medium asm1.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 2 –device 0 –type hdd –medium asm2.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 3 –device 0 –type hdd –medium asm3.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 4 –device 0 –type hdd –medium asm4.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 5 –device 0 –type hdd –medium asm5.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 6 –device 0 –type hdd –medium asm6.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 7 –device 0 –type hdd –medium asm7.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 8 –device 0 –type hdd –medium asm8.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 9 –device 0 –type hdd –medium asm9.vdi –mtype shareable
    VBoxManage storageattach vrh2 –storagectl “SATA Controller” –port 10 –device 0 –type hdd –medium asma.vdi –mtype shareable

    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 1 –device 0 –type hdd –medium asm1.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 2 –device 0 –type hdd –medium asm2.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 3 –device 0 –type hdd –medium asm3.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 4 –device 0 –type hdd –medium asm4.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 5 –device 0 –type hdd –medium asm5.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 6 –device 0 –type hdd –medium asm6.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 7 –device 0 –type hdd –medium asm7.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 8 –device 0 –type hdd –medium asm8.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 9 –device 0 –type hdd –medium asm9.vdi –mtype shareable
    VBoxManage storageattach vrh8 –storagectl “SATA Controller” –port 10 –device 0 –type hdd –medium asma.vdi –mtype shareable

  3. Yipeng says:

    linux 下用udev管理asm的磁盘名称,
    用磁盘/dev/sdb 或者用磁盘分区/dev/sdb1 都可以,优先用哪种呢?

  4. Yipeng says:

    谢谢你回答!

  5. Betty says:

    创建在vmware上的虚拟机,用scsi_id一个disk来获得唯一标识,没有任何输出,有什么解决办法吗?

  6. 小江 says:

    如果仅仅是用于解决存储设备命名一致性的问题,asmlib可以解决,udev也可以解决。
    问题是如果1个盘用于asm,那该盘上已经被做了asm的标记,那么即使重启使得操作系统识别到的盘的名称变了,但oracle还是可以通过该盘上的asm标记来识别该盘,并不影响使用。

    11gr2 rac里,ocrvote datafile均可以放在asm里,对于linux 来说,是否不用amlib ,不用udev 也可以。

    • RAC+ASM下要求多节点的LUN DISK名字一致,如果不使用udev、asmlib这些设备名绑定服务的话,无法确保设备名一致。
      例如安装RAC时所有节点的/dev/sdb这个设备均指向一致正确的LUN,但如果某次启动时有一个节点多插入了某个磁盘设备,可能导致/dev/sdb这个设备文件指向的不是正确的LUN, 所以需要使用设备名绑定服务。

      • 小江 says:

        谢谢,
        例如安装RAC时所有节点的/dev/sdb这个设备均指向一致正确的LUN,但如果某次启动时有一个节点多插入了某个磁盘设备,可能导致/dev/sdb这个设备文件指向的不是正确的LUN, 所以需要使用设备名绑定服务。

        关于这一点好像记得对于ASM盘来说是名称需要要一直保持不变的,原因就是上面提到的 唯一识别1块ASM盘是通过该盘上的ASM标记,至于说/deb/sdb 在启动后因为插入了另外一块盘变成/dev/sdc ,这种情况下 oracle asm 还是能通过/dev/sdc上的asm标记识别该盘的。不会因为其名称变化而不能识别该盘。关于同一个节点的名字不用前后保持一致

        RAC+ASM下要求多节点的LUN DISK名字一致

        关于这一点 2个节点之间如果用ASM ,好像也不是所有的ASM盘名称都要求一致的。虽然没试验过,但是在11gr1 rac aix 的cookbook中看到过这个描述。

        asm instance will be able to deal with /dev/rhdisk’s, reading the rhdisk header
        virtual device are not mandatory for ASM ,even if hdisks names are diffrents for a same LUN on each node
        using /dev/rhdisk then we don’t need to create virtual device,we’ll just have to set the right
        user ownership and unix read/write permissions

        以上都是自己的理解,请指正。谢谢

  7. 博主你好,我现在在rhel6.2上用udev的方式来配置asm磁盘组,第一次安装11g(11.2.0.3)集群软件失败后,重新分区sdb1,sdb2,sdb3 sdb4(扩展分区包含sdb5,sdb6),然后配置规则如下
    KERNEL==”sdb1″, SUBSYSTEM==”block”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”3600d0231000ccbd20a0a10796e616496″, NAME=”asm-disk1″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″
    KERNEL==”sdb2″, SUBSYSTEM==”block”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”3600d0231000ccbd20a0a10796e616496″, NAME=”asm-disk2″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″
    KERNEL==”sdb3″, SUBSYSTEM==”block”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”3600d0231000ccbd20a0a10796e616496″, NAME=”asm-disk3″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″
    KERNEL==”sdb5″, SUBSYSTEM==”block”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”3600d0231000ccbd20a0a10796e616496″, NAME=”asm-disk5″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″
    KERNEL==”sdb6″, SUBSYSTEM==”block”, PROGRAM==”/sbin/scsi_id –whitelisted –replace-whitespace –device=/dev/$name”, RESULT==”3600d0231000ccbd20a0a10796e616496″, NAME=”asm-disk6″, OWNER=”grid”, GROUP=”asmadmin”, MODE=”0660″
    重新安装集群软件,在选择磁盘的时候发现没有asm-disk1(在上一次安装过程中使用过,但后来删除并重建了分区),麻烦指点一下这是怎么回事,因为sdb是从存储上划过来的,所以采用这种方式

  8. haha says:

    能实现多路径设备的的绑定吗?/dev/mapper/下的设备?

    • 背向天堂 says:

      我也遇到了同样的问题,想绑定 /dev/mapper/ 下的设备, 现在都是用 /etc/sysconfig/rawdevices 的方式来绑定! 不清楚你解决了没有? RHEL5.7

  9. oracle艾奥 says:

    linux6.0到linux6.3这些版本,绑定/dev/mapper/下的设备,有比较好的方案吗?谢谢

  10. 安装10grac 这个脚本能用吗? 生成后把用户和组改成10g的 oracle oinstall

Trackbacks

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

  2. […] 6上使用UDEV解决RAC ASM存储设备名问题 利用UDEV服务解决RAC ASM存储设备名 Why ASMLIB and why not? […]

  3. […] 利用UDEV服务解决RAC ASM存储设备名 […]

Speak Your Mind

TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569