`

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

 
阅读更多

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

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, 6 and 7, so they will be consistent with RHEL and CentOS 5, 6 and 7.

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.

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.

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.

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

The scsi_id command is located in a different place in Oracle Linux 7, so for that the following test is correct.

PROGRAM=="/usr/lib/udev/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.

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.

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.

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

Or this in Oracle Linux 7.

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

# /sbin/scsi_id -g -u -s /block/sdb
SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
# /sbin/scsi_id -g -u -s /block/sdc
SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_
# /sbin/scsi_id -g -u -s /block/sdd
SATA_VBOX_HARDDISK_VBce8c63bb-ac67a172_
# /sbin/scsi_id -g -u -s /block/sde
SATA_VBOX_HARDDISK_VB7437a3b7-95b199cd_
# 

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

# /sbin/scsi_id -g -u -d /dev/sdb
SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
# /sbin/scsi_id -g -u -d /dev/sdc
SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_
# /sbin/scsi_id -g -u -d /dev/sdd
SATA_VBOX_HARDDISK_VBce8c63bb-ac67a172_
# /sbin/scsi_id -g -u -d /dev/sde
SATA_VBOX_HARDDISK_VB7437a3b7-95b199cd_
# 

The location of the scsi_id command has changed in Oracle Linux 7, so you must use the following syntax.

# /usr/lib/udev/scsi_id -g -u -d /dev/sdb
SATA_VBOX_HARDDISK_VBd306dbe0-df3367e3_
# /usr/lib/udev/scsi_id -g -u -d /dev/sdc
SATA_VBOX_HARDDISK_VB46dec7e0-192e8000_
# /usr/lib/udev/scsi_id -g -u -d /dev/sdd
SATA_VBOX_HARDDISK_VBce8c63bb-ac67a172_
# /usr/lib/udev/scsi_id -g -u -d /dev/sde
SATA_VBOX_HARDDISK_VB7437a3b7-95b199cd_
# 

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

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.

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"
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"

The equivalent for Oracle Linux 6 is shown below.

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

The equivalent for Oracle Linux 7 is shown below.

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

Load Updated Block Device Partitions (/sbin/partprobe)

Load updated block device partition tables.

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

Test Rules (udevtest)

Test the rules are working as expected.

# #OL5
# udevtest /block/sdb/sdb1
# udevtest /block/sdc/sdc1
# udevtest /block/sdd/sdd1
# udevtest /block/sde/sde1

# #OL6 and OL7
# udevadm test /block/sdb/sdb1
# udevadm test /block/sdc/sdc1
# udevadm test /block/sdd/sdd1
# udevadm test /block/sde/sde1

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

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

Restart UDEV Service

Restart the UDEV service.

# #OL5
# /sbin/udevcontrol reload_rules

# #OL6 and OL7
# udevadm control --reload-rules

# #OL5 and OL6 : Not needed for OL7
# /sbin/start_udev

Check Ownership and Permissions

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

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

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

For more information see:

Hope this helps. Regards Tim...

 

参考至:https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux

如有错误,欢迎指正

邮箱:czmcj@163.com

分享到:
评论

相关推荐

    Linux7.6+Oracle 19c+UDEV+ASM.pdf

    本材料的主要知识点围绕在VMware环境下安装配置Linux 7.6操作系统,以及在该环境下部署Oracle 19c数据库,包括使用UDEV和ASM(自动存储管理)进行磁盘管理。 ### Linux 7.6环境安装与配置 Linux 7.6是Red Hat ...

    Red Hat Enterprise Linux 6使用udev配置Oracle ASM总结文档

    在Red Hat Enterprise Linux 6(RHEL6)这样的Linux操作系统环境中部署ASM时,常常会遇到系统重启后设备名发生变化的问题,这主要是因为Linux内核的设备命名机制导致的。在这种情况下,udev这个设备管理器可以帮助...

    RHEL 7环境下19c RAC安装之udev规则配置ASM共享存储.docx

    在RHEL 7环境下搭建Oracle 19c的Real Application Clusters (RAC)时,配置udev规则以确保ASM(Automatic Storage Management)共享存储的稳定性和可预测性至关重要。udev是Linux系统中的设备管理器,它负责管理和命名...

    oracle不使用oracleasm的包配置ASM磁盘配置方法

    ### Oracle 不使用 OracleASM 的包配置 ASM 磁盘配置方法 #### 概述 在 Oracle 数据库系统中,自动存储管理(ASM)是用于管理数据库文件的一种高性能、高可用性的解决方案。通常情况下,ASM 依赖于 Oracle 提供的 ...

    Oracle12c 实战ASM(12.1) 安装配置

    NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules; done; (使用脚本可以自动生成以下内容,具体以实际的虚拟机为主) # more /etc/...

    Linux device-mapper-udev-CRS-ASM_v3.6.pdf

    ### Linux Device Mapper与Udev配置知识点详解 #### 引言 随着Oracle Database 10g以及Linux 2.6版本的推出,用户得以享受到一种成本低廉且高效的计算解决方案。然而,为了实现高可用性(High Availability, HA)...

    编写udev规则中文版-writing_udev_rules

    "编写udev规则中文版-writing_udev_rules" Udev 是 Linux 操作系统中的一种设备管理系统,它可以对设备进行自动检测、加载驱动程序、分配设备文件名等操作。Udev 规则是 udev 系统的核心组件,它定义了设备的行为和...

    Writing_udev_rules.tar.gz

    udev是Linux系统中用于管理设备节点的动态设备管理系统,它替代了传统的devfs。udev规则是udev用来控制设备节点创建、命名以及附加属性的关键机制。这些规则定义在/etc/udev/rules.d目录下的文本文件中,通常以"....

    udev network -70-persistent-net.rules

    标题 "udev network -70-persistent-net.rules" 涉及到的是Linux系统中的设备管理器udev以及网络接口命名规则。udev是Linux内核设备管理器的用户空间部分,负责在系统启动时动态地为硬件设备分配设备节点,并管理...

    suse使用udev管理asm.docx

    总之,SUSE Linux Enterprise Server 11使用udev管理ASM,确保了在Oracle 11gR2 RAC环境中设备的稳定识别和操作,这是成功部署RAC的关键部分。通过正确的配置和依赖包安装,可以保证Oracle RAC在SLES上的高效运行。

    Oracle 10g的ASM裸设备建库 For Linux

    ### Oracle 10g的ASM裸设备建库For Linux知识点详解 #### 一、概述 在Oracle 10g环境下,使用ASM(Automatic Storage Management)进行数据库管理是一种常见且高效的方式。尤其对于Linux操作系统而言,利用裸设备...

    oracle linux7.2 安装oracle 11.2.0.4全过程图文附各种bug解决方案

    1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c2909828cac1b0ed9a17212b4f1f", SYMLINK+="asmdisk1", OWNER="oracle", GROUP="dba", MODE="0660" ``` 最后,...

    Oracle Linux5.8X64

    Oracle Linux 5.8 X64 是一个专为运行Oracle数据库和其他企业级应用设计的Linux发行版。这个版本是基于Red Hat Enterprise Linux (RHEL) 的,并且在稳定性、性能和安全性方面进行了优化,尤其强调对Oracle软件的支持...

    Writing-udev-rules

    - **规则文件和语义**:udev 规则文件通常位于 `/etc/udev/rules.d` 目录下。每个文件都可以包含多条规则,每条规则定义了一个或多个条件和相应的动作。 - **规则语法**:规则语法允许使用各种匹配模式和变量替换,...

    Linux上用udev自动识别并挂载U盘

    1. 在/etc/udev/rules目录下新建11-add-usb.rules和11-add-remove.rules,负责设备监测。 root@am335x-evm:/etc/udev/rules.d# vi 11-add-usb.rules ACTION!="add",GOTO="farsight" KERNEL=="sd[a-z][0-9]",RUN+=...

    centos6安装11g udev+asm单机.docx

    centos6.10系统,安装oracle11gR2版本数据库及用udev方式映射磁盘,并ASM管理设置。包含安装、设置和细节解析。

    CentOS7.5+Oracle 12c+UDEV+ASM.pdf

    在本文中,我们将深入探讨如何在 CentOS 7.5 环境中安装和配置 Oracle 12c 数据库,以及与之相关的 UDEV 和 ASM 技术。首先,让我们从准备 CentOS 7.6 的虚拟机开始。 VMware 是一个流行的虚拟化平台,用于创建和...

    Linux7.6+Oracle 11g+UDEV+ASM.pdf

    VMware下安装Linux7.6环境 Linux常用命令操作 在Linux环境下安装Oracle11g数据库、数据库参数设置、数据库创建,监听创建、客户端连接 VMware下配置ASM磁盘 LVM磁盘管理 Linux环境下对Oracle数据库的运维操作

    【小麦苗高可用课堂】Oracle 11g RAC安装--基于openfiler存储+多路径+udev方式

    小麦苗高可用课堂 Oracle 11g RAC 安装--基于 openfiler 存储+多路径+udev 方式 小麦苗高可用课堂 Oracle 11g RAC 安装是基于 openfiler 存储+多路径+udev 方式的高可用解决方案。该解决方案主要介绍了 Oracle 11g ...

    Oracle下创建ASM磁盘总结.docx

    Oracle 下创建 ASM 磁盘总结 Oracle 中创建 Automatic Storage Management (ASM) 磁盘是数据库管理员常见的一项任务。ASM 磁盘是 Oracle 集群环境中的一个重要组件,用于存储数据库文件、日志文件和控制文件。在...

Global site tag (gtag.js) - Google Analytics