利用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

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

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


 

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

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

===   分区的话又是一笔管理成本,  一般推荐直接用/dev/sdb这样的块设备

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

===   正常现象,vmware中创建的disk默认不提供scsi_id, 你需要启用disk.EnableUUID 这个选项, 具体可以参考这篇文章 http://diznix.com/2011/05/21/the-case-of-vmware-and-the-missing-scsi-id/

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值