Thursday, December 28, 2017

Configuring Device Persistence UDEV SCSI Rules Manually for Oracle ASM

In Linux you can either use ASMLib or UDEV SCSI Rules (Manual Method) to manage these tasks, but it is seen as an additional layer of complexity when you use ASMLib and has never really gained any popularity.

On Linux, udev is definitely a better solution to handle persistent device naming and permissions and I don’t see enough benefits in asmlib to outweigh the very slight additional overhead. There have been a small number of past bugs in asmlib and it doesn’t seem to be frequently updated.

Format the Raw Disks/Devices
[root@rac1 dev]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x605bd840.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p

Partition number (1-4): 1
First cylinder (1-7832, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-7832, default 7832):
Using default value 7832

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
Repeat the above step for rest of the raw disks, Once done list all disks:
[root@rac1 dev]# ls sd*
sda  sda1  sda2  sda3  sdb  sdb1  sdc  sdc1  sdd  sdd1
Identify the Disks (/sbin/scsi_id):

We are going to write device-specific rules, so we need to be able to identify each device consistently, irrespective of the order in which Linux discovers it. To do this we are going to use the SCSI ID for each disk (not the partition), which we get using the scsi_id command.
[root@rac1 dev]# /sbin/scsi_id -g -u -d /dev/sdb
1ATA_VBOX_HARDDISK_VBb20ff7a3-b0d96534

[root@rac1 dev]# /sbin/scsi_id -g -u -d /dev/sdc
1ATA_VBOX_HARDDISK_VB1287e6f4-cbd888c1

[root@rac1 dev]# /sbin/scsi_id -g -u -d /dev/sdd
1ATA_VBOX_HARDDISK_VB3f8e1bcd-91e68222
Make SCSI Devices Trusted:

Add the following to the "/etc/scsi_id.config" file to configure SCSI devices as trusted. Create the file if it doesn't already exist.
options=-g
Create UDEV Rules File:

Create the "/etc/udev/rules.d/99-oracle-asmdevices.rules" file.
vi /etc/udev/rules.d/99-oracle-asmdevices.rules

[root@rac1 dev]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBb20ff7a3-b0d96534", NAME="ASM-DISK1", OWNER="oracle", GROUP="oinstall", MODE="0660"
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB1287e6f4-cbd888c1", NAME="ASM-DISK2", OWNER="oracle", GROUP="oinstall", MODE="0660"
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB3f8e1bcd-91e68222", NAME="ASM-DISK3", OWNER="oracle", GROUP="oinstall", MODE="0660"
Load Updated Block Device Partitions (/sbin/partprobe):
[root@rac1 dev]# /sbin/partprobe /dev/sdb1
[root@rac1 dev]# /sbin/partprobe /dev/sdc1
[root@rac1 dev]# /sbin/partprobe /dev/sdd1
Test Rules (udevtest)
# udevadm test /block/sdb/sdb1
# udevadm test /block/sdc/sdc1
# udevadm test /block/sdd/sdd1
Restart UDEV Service
[root@rac1 dev]# udevadm control --reload-rules
Check Ownership and Permissions
[root@rac1 dev]# ls -al ASM-DISK*

brw-rw----. 1 oracle oinstall 8, 17 Nov  9 00:44 ASM-DISK1
brw-rw----. 1 oracle oinstall 8, 33 Nov  9 00:44 ASM-DISK2
brw-rw----. 1 oracle oinstall 8, 49 Nov  9 00:44 ASM-DISK3

No comments:

Post a Comment