Friday, August 15, 2014

Udev as alternative for ASMlib in virtual Centos 6

I was trying to setup RAC in virtual environment. My virtual machines are Centos 6.5. Unfortunatelly there is no kmod-oracleasm for default kernel 2.6.32-431. To be completelly true, there is required kernel module, but it is only available for redhat subscribers. There I will describe how to use udev instead of asmlib.

Here is definition of my asm disk from libvirt domain:

    <disk type='file' device='disk'>
      &l;tdriver name='qemu' type='raw'/>
      <source file='/home/hasul/images/test.img'/>
      <target dev='vdf' bus='virtio'/>
      <shareable/>
    </disk>

I use virtio driver to improve performance. Disk is marked as shareable. This tells QEMU/KVM that the disk should be accessible from multiple guest. In the guest, disk will be presented as vdf:

[root@centos-rac1 ~]# ls -l /dev/vdf 
brw-rw----. 1 root disk 252, 80 Aug 15 15:26 /dev/vdf

Now I need to create new udev rule for the disk:

[root@centos-rac1 ~]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules 
KERNEL=="vdf", NAME="asm-disk", OWNER="oracle", GROUP="oinstall", MODE="0660"

This rule says that if appears device vdf, change device name to "asm-disk" and set owner, group and permission accordingly. I'll check if rule is understood by udev:

[root@centos-rac1 ~]# udevadm test /block/vdf
run_command: calling: test
udevadm_test: version 147
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
.
.
.
parse_file: reading '/etc/udev/rules.d/99-oracle-asmdevices.rules' as rules file
.
.
.
util_run_program: 'fstab_import vdf block/252:80 disk/by-path/pci-0000:00:0b.0-virtio-
pci-virtio8 mapper/' returned with exitcode 1
udev_rules_apply_to_event: ATTR '/sys/devices/pci0000:00/0000:00:0b.0/virtio8/block/
vdf/queue/iosched/slice_idle' writing '0' /lib/udev/rules.d/80-iosched.rules:12
udev_rules_apply_to_event: ATTR '/sys/devices/pci0000:00/0000:00:0b.0/virtio8/block/
vdf/queue/iosched/quantum' writing '32' /lib/udev/rules.d/80-iosched.rules:13
udev_rules_apply_to_event: OWNER 54321 /etc/udev/rules.d/99-oracle-asmdevices.rules:6
udev_rules_apply_to_event: GROUP 54321 /etc/udev/rules.d/99-oracle-asmdevices.rules:6
udev_rules_apply_to_event: MODE 0660 /etc/udev/rules.d/99-oracle-asmdevices.rules:6
udev_rules_apply_to_event: NAME 'asm-disk' /etc/udev/rules.d/99-oracle-asmdevices.rules:6
udev_device_update_db: created db file for '/devices/pci0000:00/0000:00:0b.0/virtio8/block/vdf'
in '/dev/.udev/db/block:vdf'
udev_node_add: creating device node '/dev/asm-disk', devnum=252:80, mode=0660, uid=54321, gid=54321
udev_node_mknod: mknod(/dev/asm-disk, 060660, (252,80))
udev_node_mknod: set permissions /dev/asm-disk, 060660, uid=54321, gid=54321
node_symlink: atomically replace '/dev/block/252:80'
link_find_prioritized: found '/sys/devices/pci0000:00/0000:00:0b.0/virtio8/block/vdf'
claiming '/dev/.udev/links/disk\x2fby-path\x2fpci-0000:00:0b.0-virtio-pci-virtio8'
link_update: creating link '/dev/disk/by-path/pci-0000:00:0b.0-virtio-pci-virtio8' to '/dev/asm-disk'
node_symlink: atomically replace '/dev/disk/by-path/pci-0000:00:0b.0-virtio-pci-virtio8'
udev_event_execute_rules: removed kernel created node '/dev/vdf'
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/pci0000:00/0000:00:0b.0/virtio8/block/vdf
udevadm_test: MAJOR=252
udevadm_test: MINOR=80
udevadm_test: DEVNAME=/dev/asm-disk
udevadm_test: DEVTYPE=disk
udevadm_test: ACTION=add
udevadm_test: SUBSYSTEM=block
udevadm_test: DEVLINKS=/dev/block/252:80 /dev/disk/by-path/pci-0000:00:0b.0-virtio-pci-virtio8
udevadm_test: ID_PATH=pci-0000:00:0b.0-virtio-pci-virtio8
udevadm_test: ID_FS_TYPE=oracleasm
udevadm_test: ID_FS_USAGE=filesystem
udevadm_test: LVM_SBIN_PATH=/sbin
udevadm_test: .ID_FS_TYPE_NEW=oracleasm

It looks ok, udev is happy with new rule. Udev has already changed the device:

[root@centos-rac1 ~]# ls -l /dev/vdf /dev/asm-disk
ls: cannot access /dev/vdf: No such file or directory
brw-rw----. 1 oracle oinstall 252, 80 Aug 15 16:00 /dev/asm-disk

That's it. Disk is ready to be used by ASM:

[oracle@centos-rac1 ~]$ echo "show parameter asm_diskstring" | sqlplus -S -L / as sysasm 

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskstring                       string      /dev

[oracle@centos-rac1 ~]$ asmcmd lsdsk --discovery
Path
/dev/asm-disk
.
.
.

Sources

  • Inspired by this

No comments:

Post a Comment