UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6

For Oracle Automatic Storage Manager (ASM) to use disks, it needs to be able to identify the devices consistently and for them to have the correct ownership and permissions. In Linux you can use ASMLib to manage these tasks, but it is seen as an additional
layer of complexity and has never really gained any popularity. Instead, many people use the Linux device manager "udev" to perform these tasks. This article presents a brief overview of setting up udev rules with respect to disks for use with ASM in Oracle
11g. The examples are all done using Oracle Linux 5 and 6, so they will be consistent with RHEL and CentOS 5 and 6.

Background

Essentially, what udev does is apply rules defined in files in the "/etc/udev/rules.d" directory to the device nodes listed in the "/dev" directory. The rules can be defined in a variety of ways, but what we need to do is identify the device and say what
we want udev to do with it.

In this case I know all my disk devices are named "/dev/sd?1", where the "?

" represents a letter from a-d, so I can identify the devices of interest using the following rule parameters.

  1. KERNEL=="sd?1", BUS=="scsi"

I want to tie each specific device to an alias, so it is always identified the same way, regardless of the device name Linux assigns it. So I need to be able to test each device that matches the previous pattern to see if it is the disk I am interested in.
Each disk has a unique SCSI ID, so I can place a test into the rule, telling it how to perform the test, and the result it should return for a positive match. The following rule parameters explain how to test the device and what result constitutes a match
in Oracle Linux 5.

  1. PROGRAM=="/sbin/scsi_id -g -u -s /block/$parent", RESULT=="SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_"

The scsi_id command works a little differently in Oracle Linux 6, so for that the following test works better.

  1. PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_"

Once we have identified the specific device of interest, we need to indicate what actions should be performed on it. The following parameters specify an alias, the ownership and the permissions for the device.

  1. NAME="asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660"

So the whole rule for each disk will look something like this in Oracle Linux 5.

  1. KERNEL=="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"

Or this in Oracle Linux 6.

  1. KERNEL=="sd?
  2.  
  3. 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"

This means that the device pointing to the partition "sd*1" on the disk with the SCSI ID of "SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_" will always be called "/dev/asm-disk1", regardless of the letter "?" Linux assigns when the device is discovered. In addition,
the device will have the correct ownership and permissions for ASM.

There are a number of wildcards and matching patterns that can be used if you don't want to write device-specific rules.

Now we know roughly what we are trying to achieve, we will look at each step necessary for setting up the disks for ASM to use.

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. The "-s" option makes the paths relative to the "/sys" directory. For Oracle Linux 5, use the following command.

  1. # /sbin/scsi_id -g -u -s /block/sdb
  2. SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
  3. # /sbin/scsi_id -g -u -s /block/sdc
  4. SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_
  5. # /sbin/scsi_id -g -u -s /block/sdd
  6. SATA_VBOX_HARDDISK_VBce8c63bb-ac67a172_
  7. # /sbin/scsi_id -g -u -s /block/sde
  8. SATA_VBOX_HARDDISK_VB7437a3b7-95b199cd_
  9. #

The "-s" is not available in Oracle Linux 6, so you must use the following syntax.

  1. # /sbin/scsi_id -g -u -d /dev/sdb
  2. SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
  3. # /sbin/scsi_id -g -u -d /dev/sdc
  4. SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_
  5. # /sbin/scsi_id -g -u -d /dev/sdd
  6. SATA_VBOX_HARDDISK_VBce8c63bb-ac67a172_
  7. # /sbin/scsi_id -g -u -d /dev/sde
  8. SATA_VBOX_HARDDISK_VB7437a3b7-95b199cd_
  9. #

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.

  1. options=-g

Create UDEV Rules File

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

  1. # vi /etc/udev/rules.d/99-oracle-asmdevices.rules

The file should contain the following lines for Oracle Linux 5. The PROGRAM parameter must match the command you used to retrieve the SCSI ID, and the
RESULT parameter must match the value returned from your disks.

  1. KERNEL=="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"
  2. KERNEL=="sd?
  3.  
  4. 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"
  5. 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"
  6. 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"

The equivalent for Oracle Linux 6 is shown below.

  1. KERNEL=="sd?
  2.  
  3. 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"
  4. KERNEL=="sd?
  5.  
  6. 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"
  7. 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"
  8. 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"

Load Updated Block Device Partitions (/sbin/partprobe)

Load updated block device partition tables.

  1. # /sbin/partprobe /dev/sdb1
  2. # /sbin/partprobe /dev/sdc1
  3. # /sbin/partprobe /dev/sdd1
  4. # /sbin/partprobe /dev/sde1

Test Rules (udevtest)

Test the rules are working as expected.

  1. # #OL5
  2. # udevtest /block/sdb/sdb1
  3. # udevtest /block/sdc/sdc1
  4. # udevtest /block/sdd/sdd1
  5. # udevtest /block/sde/sde1
  6.  
  7. # #OL6
  8. # udevadm test /block/sdb/sdb1
  9. # udevadm test /block/sdc/sdc1
  10. # udevadm test /block/sdd/sdd1
  11. # udevadm test /block/sde/sde1

The output from the first disk should look something like this.

  1. # udevtest /block/sdb/sdb1
  2. main: looking at device '/block/sdb/sdb1' from subsystem 'block'
  3. udev_rules_get_name: add symlink 'disk/by-id/scsi-SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3-part1'
  4. udev_rules_get_name: add symlink 'disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1'
  5. run_program: '/lib/udev/vol_id --export /dev/.tmp-8-17'
  6. run_program: '/lib/udev/vol_id' returned with status 4
  7. run_program: '/sbin/scsi_id -g -u -s /block/sdb/sdb1'
  8. run_program: '/sbin/scsi_id' (stdout) 'SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_'
  9. run_program: '/sbin/scsi_id' returned with status 0
  10. udev_rules_get_name: rule applied, 'sdb1' becomes 'asm-disk1'
  11. udev_device_event: device '/block/sdb/sdb1' already in database, validate currently present symlinks
  12. udev_node_add: creating device node '/dev/asm-disk1', major = '8', minor = '17', mode = '0660', uid = '1100', gid = '1200'
  13. udev_node_add: creating symlink '/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3-part1' to '../../asm-disk1'
  14. udev_node_add: creating symlink '/dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1' to '../../asm-disk1'
  15. main: run: 'socket:/org/kernel/dm/multipath_event'
  16. main: run: 'socket:/org/kernel/udev/monitor'
  17. main: run: '/lib/udev/udev_run_devd'
  18. main: run: 'socket:/org/freedesktop/hal/udev_event'
  19. main: run: '/sbin/pam_console_apply /dev/asm-disk1 /dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3-part1 /dev/disk/by-path/pci-0000:00:0d.0-scsi-1:0:0:0-part1'
  20. #

Restart UDEV Service

Restart the UDEV service.

  1. # #OL5
  2. # /sbin/udevcontrol reload_rules
  3.  
  4. # #OL6
  5. # udevadm control --reload-rules
  6.  
  7. # #OL5 and OL6
  8. # /sbin/start_udev

Check Ownership and Permissions

Check the disks are now available with the "asm-disk*" alias and the correct ownership and permissions.

  1. # cd /dev
  2. # ls -al asm-disk*
  3. brw-rw---- 1 oracle dba 8, 17 Apr 8 22:47 asm-disk1
  4. brw-rw---- 1 oracle dba 8, 33 Apr 8 22:47 asm-disk2
  5. brw-rw---- 1 oracle dba 8, 49 Apr 8 22:47 asm-disk3
  6. brw-rw---- 1 oracle dba 8, 65 Apr 8 22:47 asm-disk4
  7. #

So the ASM_DISKSTRING initialization parameter in the ASM instance can be set to '/dev/asm-disk*' to identify the ASM disks.

UDEV SCSI Rules Configuration for ASM in Oracle Linux 5 and 6的更多相关文章

  1. 如何用udev for asm in oracle linux 6

    大部分在网上可以找到的文档都是在RHEL5或者OEL5中设置udev,udev对于Linux而言最大的作用是防止操作系统重新启动以后,作为ASM磁盘使用的盘符发生变化.比如说Tim Hall的文章:U ...

  2. 在Linux 5/6上使用UDEV SCSI规则配置ASM DISK

    格式化磁盘(略) 识别磁盘(/sbin/scsi_id)  Oracle Linux 5用如下脚本: #!/bin/sh for i in b c d e f g do echo "KERN ...

  3. oracle linux 7使用udev绑盘操作

    参考:Oracle Linux 7: Udev rule for ASM Cannot Place the ASM Disk in a Directory under /dev (Doc ID 221 ...

  4. [置顶] Oracle 11g R2 ASM:了解 Oracle ASM 基本概念

    About Oracle ASM Instances About Oracle ASM Disk Groups About Mirroring and Failure Groups About Ora ...

  5. udev和rules使用规则

    本文以通俗的方法阐述 udev 及相关术语的概念.udev 的配置文件和规则文件,然后以 Red Hat Enterprise Server 为平台演示一些管理设备文件和查询设备信息的实例.本文会使那 ...

  6. ORACLE LINUX 6.3 + ORACLE 11.2.0.3 RAC + VBOX安装文档

    ORACLE LINUX 6.3 + ORACLE 11.2.0.3 RAC + VBOX安装文档 2015-10-21 12:51 525人阅读 评论(0) 收藏 举报  分类: Oracle RA ...

  7. 12c R2 RAC Oracle Linux 7.3 ESXI6.5

    环境:ESXI6.5虚拟化 主机配置:操作系统 Oracle Linux 7.3 CPU:8个VCPU 内存:16G 本地磁盘:50G 全程默认最小化安装Oracle Linux 7.3操作系统 每个 ...

  8. 在 Oracle Linux 6.5 上安装 Oracle 11g 单实例数据库

    Checking the Hardware Requirements 系统必须满足下面最小的硬件要求 Memory Requirements Minimum: 1 GB of RAMRecommend ...

  9. Oracle linux 6.3 安装11g R2 RAC on vbox

    1 安装系统 Virtual box 4.3 Oracle linux 6.3 Oracle 11g r2 Make sure "Adapter 1" is enabled, se ...

随机推荐

  1. Java开发笔记(九十二)文件通道的基本用法

    前面介绍的各色流式IO在功能方面着实强大,处理文件的时候该具备的操作应有尽有,可流式IO在性能方面不尽如人意,它的设计原理使得实际运行效率偏低,为此从Java4开始增加了NIO技术,通过全新的架构体系 ...

  2. mysql若干问题

    一.Host ip is not allowed to connect to this MySql server 解决方法:这是因为你的账号不允许远程登录,只能在localhost.只要在localh ...

  3. 关于java的print()

    print方法是类PrintStream的方法成员,而System类有一个static的PrintStream类型的属性成员,名叫out,我们平时写的System.out.print("he ...

  4. 动态属性ExpandoObject

    1.动态创建对象及其属性ExpandoObject 查看ExpandoObject的定义:

  5. Python批量下载电视剧电影--自己动手丰衣足食

    前言 为了看美剧<天蝎>,在电影天堂找到了,于是就想下载下来好好欣赏. 废话不说了,直接上代码. 代码 import requests,re,os,time url = "htt ...

  6. NGS数据格式介绍

    一般情况下,从Illumina平台上得到的测序,其数据格式是Fastq格式,可以称之为原始数据(Raw data).事实上直接的下机数据是显微拍摄得到的图像信息.但是一般都会用Bcl2Fastq软件将 ...

  7. 执行join_paired_ends.py报错Cannot find fastq-join

    通过 conda 安装 qiime 1后,在执行join_paired_ends.py时报错: burrito.util.ApplicationNotFoundError: Cannot find f ...

  8. 梦想CAD控件系统变量说明

    这里介绍一些常用系统变量有String.double.long.McGePoint3d等类型,其中有部分系统变量是随图纸保存,再次打开时就会读取图纸中的系统变量,有些系统变量不随图纸保存,其作用来控制 ...

  9. JavaScipt30(第七个案例)(主要知识点:数组some,every,findIndex方法)

    承接上文,这是第7个案例,这个案例没什么说的,主要有三个注意点: 附上项目链接: https://github.com/wesbos/JavaScript30 // 1. slice(begin, e ...

  10. 2019西安多校联训 Day4

    T1 大水题!!难度简单,显然的贪心策略即可,but... 思路:首先我们按与i点作战后活下来的士兵排序,然后 若当前剩余兵力足够直接减掉战斗死亡人数,如果不够就加 够再打它,但是!我们在考完试观察测 ...