Configuring ASM on Oracle Linux using Udev SCSI rules

Source: Internet
Author: User
Tags dba symlink

For disks that are managed with ASM, you need a means to consistently identify disk devices and their proper owning relationships and permissions. In a Linux system, you can use Asmlib to perform this task, but the disadvantage of doing so is to add an extra layer to the operating system, which leads to the complexity of management, and the way to configure ASM with Asmlib is now no longer popular.

An alternative solution is to use the Linux Device Manager "Udev" to accomplish this task. From the 2.6 kernel onwards, Udev can be used to assist in managing the device names in the system, and Udev can dynamically generate custom, highly identifiable device files or device links in the/dev directory. This article outlines how to use UDEV rules to configure an ASM disk.

In essence, Udev is an application of defined rules that are stored as files in the "/ETC/UDEV/RULES.D" directory. The definition of a rule can take a number of ways, and what we need to do is identify the device and explain what you want Udev to do with it. As is known to all, all disk devices are named "/dev/sd?1", so we can use the following rule parameters to identify the device:

kernel== "Sd?1", bus== "SCSI"

Make an alias for each disk so that it is always identified in a consistent way, regardless of the device name that Linux assigns to it. So before you do this, you need to do a test to determine if the disk is the one you need to configure ASM. The testing principle is that because each disk has a unique SCSI ID, it can be used as a test rule to match this ID. The following rule parameters explain how to do this Test match:

#OL5中, the test rules are as follows: program== "/sbin/scsi_id-g-u-s/block/$parent", result== "sata_vbox_harddisk_vbd306dbe0-df3367e3_" # The scsi_id command is slightly different in OL6, and the test rules are as follows: program== "/sbin/scsi_id-g-u-d/dev/$parent", result== "sata_vbox_harddisk_ Vbd306dbe0-df3367e3_ "#在OL7中, the scsi_id command is under the different path, the test rule is as follows: program=="/usr/lib/udev/scsi_id-g-u-d/dev/$parent ", result== "Sata_vbox_harddisk_vbd306dbe0-df3367e3_"

Once the specified disk is clearly identified, we can indicate the action performed on the disk, the following udev parameters specify an alias for the disk, the owning relationship of the disk, and the permissions:

Name= "Asm-disk1", owner= "Oracle", group= "DBA", mode= "0660"

In summary, for a disk, the complete Udev rule is defined as follows:

#OL5KERNEL = = "Sd?1", bus== "scsi", program== "/sbin/scsi_id-g-u-s/block/$parent", result== "sata_vbox_harddisk_ Vbd306dbe0-df3367e3_ ", name=" Asm-disk1 ", owner=" Oracle ", group=" DBA ", mode=" 0660 "#OL6KERNEL = =" Sd?1 ", bus==" SCSI ", program== "/sbin/scsi_id-g-u-d/dev/$parent", result== "sata_vbox_harddisk_vbd306dbe0-df3367e3_", NAME= "Asm-disk1", Owner= "Oracle", group= "DBA", mode= "0660" #OL7KERNEL = = "Sd?1", subsystem== "block", program== "/usr/lib/udev/scsi_id-g"- u-d/dev/$parent ", result==" sata_vbox_harddisk_vbd306dbe0-df3367e3_ ", symlink+=" Asm-disk1 ", owner=" Oracle ", GROUP=" DBA ", mode=" 0660 "

This means that the SCSI ID pointing to the disk "sd*1" Partition and "Sata_vbox_harddisk_vbd306dbe0-df3367e3_" is always called "/dev/asm-disk1", regardless of whether Linux is "?". What characters are assigned. Additionally, the device will have the correct owning relationship and permissions.

Next you need to continue on the remaining disk (note that the disk is not a partition) using the SCSI_ID command to generate the SCSI ID:

Oracle Linux 5:

#/sbin/scsi_id-g-u-s/block/sdbsata_vbox_harddisk_vbd306dbe0-df3367e3_#/sbin/scsi_id-g-u-s/block/sdcSATA_VBOX_ harddisk_vb46dec7e0-192e8000_#/sbin/scsi_id-g-u-s/block/sddsata_vbox_harddisk_vbce8c63bb-ac67a172_#/sbin/scsi_ Id-g-u-s/block/sdesata_vbox_harddisk_vb7437a3b7-95b199cd_

Oracle Linux 6:

Oracle Linux 6:#/sbin/scsi_id-g-u-d/dev/sdbsata_vbox_harddisk_vbd306dbe0-df3367e3_#/sbin/scsi_id-g-u-d/dev/sdcSA ta_vbox_harddisk_vb46dec7e0-192e8000_#/sbin/scsi_id-g-u-d/dev/sddsata_vbox_harddisk_vbce8c63bb-ac67a172_#/sbin /scsi_id-g-u-d/dev/sdesata_vbox_harddisk_vb7437a3b7-95b199cd_

Oraclelinux 7:

#/usr/lib/udev/scsi_id-g-u-d/dev/sdbsata_vbox_harddisk_vbd306dbe0-df3367e3_#/usr/lib/udev/scsi_id-g-u-d/dev/ sdcsata_vbox_harddisk_vb46dec7e0-192e8000_#/usr/lib/udev/scsi_id-g-u-d/dev/sddsata_vbox_harddisk_ vbce8c63bb-ac67a172_#/usr/lib/udev/scsi_id-g-u-d/dev/sdesata_vbox_harddisk_vb7437a3b7-95b199cd_

Use the Vi/etc/udev/rules.d/99-oracle-asmdevices.rules command to create a udev rule file:

# #OL5KERNEL = = "Sd?1", bus== "scsi", program== "/sbin/scsi_id-g-u-s/block/$parent", result== "sata_vbox_harddisk_ Vbd306dbe0-df3367e3_ ", name=" Asm-disk1 ", owner=" Oracle ", group=" DBA ", mode=" 0660 "kernel==" sd?1 ", bus==" SCSI ", program== "/sbin/scsi_id-g-u-s/block/$parent", result== "sata_vbox_harddisk_vb46dec7e0-192e8000_", NAME= "Asm-disk2 ", owner=" Oracle ", group=" DBA ", mode=" 0660 "kernel==" sd?1 ", bus==" scsi ", program=="/sbin/scsi_id-g-u-s/block/$parent ", result==" sata_vbox_harddisk_vbce8c63bb-ac67a172_ ", name=" Asm-disk3 ", owner=" Oracle ", group=" DBA ", mode=" 0660 " kernel== "Sd?1", bus== "scsi", program== "/sbin/scsi_id-g-u-s/block/$parent", result== "sata_vbox_harddisk_ Vb7437a3b7-95b199cd_ ", name=" Asm-disk4 ", owner=" Oracle ", group=" DBA ", Mode=" 0660 "# #OL6KERNEL = =" Sd?1 ", bus==" SCSI ", program== "/sbin/scsi_id-g-u-d/dev/$parent", result== "sata_vbox_harddisk_vbd306dbe0-df3367e3_", NAME= "Asm-disk1", Owner= "Oracle", group= "DBA", mode= "0660" kernel== "sd?1", bus== "scsi", program== "/sbin/scsi_id -g-u-d/dev/$parent ", result==" sata_vbox_harddisk_vb46dec7e0-192e8000_ ", name=" Asm-disk2 ", owner=" Oracle ", GROUP=" DBA ", mode=" 0660 "kernel==" sd?1 ", bus==" scsi ", program=="/sbin/scsi_id-g-u-d/dev/$parent ", result==" Sata_vbox_ Harddisk_vbce8c63bb-ac67a172_ ", name=" Asm-disk3 ", owner=" Oracle ", group=" DBA ", mode=" 0660 "kernel==" sd?1 ", BUS==" SCSI ", program=="/sbin/scsi_id-g-u-d/dev/$parent ", result==" Sata_vbox_harddisk_vb7437a3b7-95b199cd_ ", NAME=" Asm-disk4 ", owner=" Oracle ", group=" DBA ", Mode=" 0660 "# #OL7KERNEL = =" Sd?1 ", subsystem==" block ", program=="/usr/lib/ Udev/scsi_id-g-u-d/dev/$parent ", result==" sata_vbox_harddisk_vbd306dbe0-df3367e3_ ", symlink+=" Asm-disk1 ", OWNER=" Oracle ", group=" DBA ", mode=" 0660 "kernel==" sd?1 ", subsystem==" block ", program=="/usr/lib/udev/scsi_id-g-u-d/dev/$ Parent ", result==" sata_vbox_harddisk_vb46dec7e0-192e8000_ ", symlink+=" Asm-disk2 ", owner=" Oracle ", group=" DBA ", MODE = "0660" kernel== "sd?1", subsystem== "block", program== "/usr/lib/udev/scsi_id-g-u-d/Dev/$parent ", result==" sata_vbox_harddisk_vbce8c63bb-ac67a172 ", symlink+=" Asm-disk3 ", owner=" Oracle ", group=" DBA ", Mode= "0660" kernel== "sd?1", subsystem== "block", program== "/usr/lib/udev/scsi_id-g-u-d/dev/$parent", result== "SATA_ Vbox_harddisk_vb7437a3b7-95b199cd_ ", symlink+=" Asm-disk4 ", owner=" Oracle ", group=" DBA ", mode=" 0660 "

To update the partition (/sbin/partprobe) of a block device:

/sbin/partprobe/dev/sdb1/sbin/partprobe/dev/sdc1/sbin/partprobe/dev/sdd1/sbin/partprobe/dev/sde1

Test rule:

# #OL5udevtest/block/sdb/sdb1udevtest/block/sdc/sdc1udevtest/block/sdd/sdd1udevtest/block/sde/sde1# #OL6 and Ol7udevadm test/block/sdb/sdb1udevadm test/block/sdc/sdc1udevadm Test/block/sdd/sdd1udevadm test/block/sde/sde1

Reload the rule file and start the Udev service:

# #OL5/sbin/udevcontrol reload_rules# #OL6 and Ol7udevadm control--reload-rules# #OL5 and Ol6,not needed for ol7/sbin/ Start_udev

Check the owning relationship and permissions of the disk:

Cd/devls-al ASM-DISK*BRW-RW----1 Oracle DBA 8, Apr  8 22:47 ASM-DISK1BRW-RW----1 Oracle DBA 8, Apr  8 22:4 7 ASM-DISK2BRW-RW----1 Oracle DBA 8, Apr  8 22:47 ASM-DISK3BRW-RW----1 Oracle DBA 8, APR  8 22:47 asm-disk4

This article references: https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux#scsi_id

Finally, attach a script to quickly generate Udev rule files on OL6:

#添加记录到/etc/scsi_id.configecho "options=--whitelisted--replace-whitespace"  >>/etc/scsi_id.configfor i in b c D E F G;doecho "kernel==\" sd*\ ", bus==\" scsi\ ", program==\"/sbin/scsi_id--whitelisted--replace-whitespace--device= /dev/\ $name \ ", result==\" '/sbin/scsi_id--whitelisted--replace-whitespace--device=/dev/sd$i ' \ ", NAME=\" asm-disk$i \ ", owner=\" grid\ ", group=\" asmadmin\ ", mode=\" 0660\ ""  >>/etc/udev/rules.d/99- Oracle-asmdevices.rulesdone

  

Configuring ASM on Oracle Linux using Udev SCSI rules

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.