The following rules are exactly the same, except matching different device names and creating new devices in their place. When the host is rebooted we now see a new set of devices under /dev/oracleasm:
# ll /dev/oracleasm
total 0brw-rw----. 1 oracle dba 8, 21 Dec 18 13:57 data1brw-rw----. 1 oracle dba 8, 22 Dec 18 13:57 data2brw-rw----. 1 oracle dba 8, 17 Dec 18 12:29 ocrvote1brw-rw----. 1 oracle dba 8, 18 Dec 18 13:57 ocrvote2brw-rw----. 1 oracle dba 8, 19 Dec 18 13:57 ocrvote3
When running the Oracle Universal Installer you can simply change your disk string to /dev/oracleasm/* and these disks are made available to use with ASM.
A Slightly Less Trivial Case
Ok, so in the real world we tend to have disk arrays that have hundreds of spindles and LUNs are carved out of them and presented to the host. Instead of one big disk, we may get 20 smaller disks instead. To simulate this example I have a VM with three 5GB luns and two 50GB luns. The small LUNs are for OCR/VOTE again, and the larger ones are for the +DATA diskgroup. When initially presented to the host I just have a bunch of scsi devices:
# ll /dev/sd*
brw-rw---- 1 root disk 8, 0 Dec 18 14:03 /dev/sda
brw-rw---- 1 root disk 8, 1 Dec 18 14:03 /dev/sda1
brw-rw---- 1 root disk 8, 2 Dec 18 14:03 /dev/sda2
brw-rw---- 1 root disk 8, 16 Dec 18 14:03 /dev/sdb
brw-rw---- 1 root disk 8, 32 Dec 18 14:03 /dev/sdc
brw-rw---- 1 root disk 8, 48 Dec 18 14:03 /dev/sdd
brw-rw---- 1 root disk 8, 64 Dec 18 14:03 /dev/sde
brw-rw---- 1 root disk 8, 80 Dec 18 14:03 /dev/sdf
/dev/sda is the Linux O/S, the rest are LUNs meant to be used for ASM. How can udev help
us here? Let’s look at the following rules, again placed in /etc/udev/rules.d/99-oracle.rules.
KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36000c290e2feb0a79b4ebe855688ae7c", NAME+="oracleasm/ocrvote1", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36000c297cae9913d395a112e3205cdc8", NAME+="oracleasm/ocrvote2", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36000c296772099ed8a7387461a1e99d3", NAME+="oracleasm/ocrvote3", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36000c294f6839516720e007185a3f617", NAME+="oracleasm/data1", OWNER="oracle", GROUP="dba", MODE="0660"
KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="36000c29a75f655d777930b9abd29ead0", NAME+="oracleasm/data2", OWNER="oracle", GROUP="dba", MODE="0660"
What is all that gibberish? Let’s look at the rules again. Remember, commas separate matches followed by actions. So for the first line:
IF
- the kernel device matches /dev/sd* (any scsi disk device)
- AND put it in the dba group
- AND the device is a BLOCK device
- AND the block device is a DISK
- AND the disk has serial number 36000c290e2feb0a79b4ebe855688ae7c
THEN
- Name it /dev/oracleasm/ocrvote1
- AND make it owned by user oracle
- AND change permissions to 0660 (owner,group read/write)
After a reboot and looking at /dev/oracleasm we see:
# ll /dev/oracleasm
total 0
brw-rw----. 1 oracle dba 8, 64 Dec 18 14:09 data1
brw-rw----. 1 oracle dba 8, 80 Dec 18 14:09 data2
brw-rw----. 1 oracle dba 8, 16 Dec 18 14:09 ocrvote1
brw-rw----. 1 oracle dba 8, 32 Dec 18 14:09 ocrvote2
brw-rw----. 1 oracle dba 8, 48 Dec 18 14:09 ocrvote3
How did we get the serial number from the scsi devices? Our friend scsi_id comes to the rescue. As root run the following command:
# scsi_id -g -u -d /dev/sdb
36000c290e2feb0a79b4ebe855688ae7c
There's your serial number. If you're running in a VM that doesn't enable disk UUID's by default (I'm looking at you VMWare) then you need to add the following entry to the VM's .vmx configuration file:
disk.EnableUUID = true
and serial numbers/IDs will become visible.
Enabling direct I/O
Remember also to set the oracle parameter filesystemio_options to ‘setall’ or ‘directio’ in order to enable direct i/o operations. See this My Oracle Support Document for more details: File System's Buffer
Cache versus Direct I/O (Doc ID 462072.1). As that article points out if you have been allocating a huge amount of memory to the operating system and unknowingly counting on it you’re going to be surprised when certain operations slow down. You are moving the cache from the operating system directly to Oracle, so give the database that memory so it can cache blocks instead.
But! But! But!
I know by now some of you are reading this and saying to yourselves "Well this is nice but ASMLib provides specific performance gains under Linux. I'm not going to use this just because you say so." I know, I thought the same thing too. However, I challenge you to find anything in the official documentation or elsewhere on the internet that says you must use ASMLib to get high performance read/write in Linux. It's true that in the old days the only guarantee of direct I/O with Linux was via RAW devices and other horrible things that most of us would like to forget. Current Versions of Linux and Oracle support direct I/O without using ASMLib as we saw above.
Conclusions
Should you immediately rush out and remove ASMLib from every system you have in place? Of course not. But the next time you're building out a new system, take the time to investigate udev. As many of the linked articles below reiterate - ASMLib is fine, but it's another layer or moving part that you have to keep track of. udev comes with Linux right out of the box and it's very flexible. You don't need to worry about kernel modules when you patch your kernel. Is ASMLib a bad thing? No. But it's getting much harder to implement and if the alternative is just as good and removes some additional package maintenance why not give it a try?
I know it's hard to hear ASMLib, but we need to move on. We'll always be friends, right?
Related Links: