Oracle Rac如何配置Udev Rules文件

Linux: How To Setup UDEV Rules For RAC OCR And Voting Devices On SLES10, RHEL5, OEL5, OL5 (文档 ID 414897.1)


In this Document (该文档的目录结构如下)

Goal

Solution

  1.  Create The New UDEV Rules

  1.1  Create UDEV Permission Rule Prior Up-To Version 11.1.0.7

  1.2  Create UDEV Permission Rule For Version 11.2 And Later

  2. Restart The UDEV Service

  3. Additional UDEV information

References

Applies to:

Oracle Database - Enterprise Edition - Version 10.1.0.2 and later Generic Linux

***Checked for relevance on 2011-01-22*** 

Linux Kernel - Version: 2.6.18-8 to 2.6.21

Goal

Real Application Clusters (RAC) requires special ownership (owner, group and permissions) for the OCR (Oracle Cluster Registry) and Voting devices on Linux.

In the 2.6 kernel, the UDEV system is the default method through which the kernel controls the creation of the special files that represent resources such as block devices.  

In Oracle 10g RAC, where raw devices are a mandatory requirement for use by CRS, raw devices require specific ownership and permissions.  Prior to UDEV, device nodes

could be created and their access permissions persistently set using the mknod(1) utility; the UDEV facility dynamically recreates the /dev content each reboot, preventing this approach.  

The solution is to add UDEV rules to set these attributes automatically.   The configuration file syntax for UDEV in SLES10, RHEL5 and OEL5 have vary slightly compared depending on the software version.

For SuSE Linux Enterprise Server 10 (SLES10), UDEV rules for raw device permission setting should be placed into rule files under the/etc/udev/rules.d/ directory.  

The files are processed in ls(1) order, with default system rules contained in the 50-udev-default.rules file.


UDEV Filename Rules (UDEV文件名规则,比较有意思的,大家可以学习一下)
·	Filenames begin with two decimal digits, to sequence the rules into ascending numerical order.
·	After a dash, filenames contain descriptive words.
·	The filename must end with ".rules" to be recognized.
·	Rule clauses using a double equal sign (==) are predicate matching patterns, to determine if the rest of the line should be processed.
·	Rule clauses are separated by a comma.
·	Rule clauses with only a single equal sign (=) are actions to be performed.
·	Content after a sharp sign / hash mark / octothorpe (#) is ignored as a comment.
·	Blank lines are OK.

 From SLES10, there is no separation between rules for creating devices and rules for device permissions - both  are now set from the same rule file. 

In order to alter the permissions for raw devices, create a permission rule file that sets the appropriate device permissions in the rules.d/directory,

so that it is processed before the default rules:

Caution About Changing Files Owned By The Distribution
Do not change the default 50-udev-default.rules file.  This file will be over-written should the UDEV package be updated.  
On RHEL5/OEL5, the UDEV rules file is called 50-udev.rules, otherwise the behavior is the same.   Always use a separate, custom file.

 

Solution

1.  Create The New UDEV Rules

Choose one of the following methods, depending upon your RAC version.

1.1  Create UDEV Permission Rule Prior Up-To Version 11.1.0.7  (Oracle 11.1.0.7之前的版本关于UDEV的配置)

Create a custom UDEV permission rule file (for example, /etc/udev/rules.d/99-raw.rules) and ensure the file name lists after the default 50-xxx.rules file.  

The filename must end in ".rules" to be recognized.

Add the required raw device ownership and permissions, for example:

# /bin/cat /etc/udev/rules.d/99-raw.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/%P", RESULT=="3600805f30016c0e0ad41ffa8e6d90001", NAME="raw1", ACTION=="add|change",OWNER="root", GROUP="oinstall", MODE="0640"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/%P", RESULT=="3600805f30016c0e0ae51efbfb2930002", NAME="raw2", ACTION=="add|change",OWNER="oracle", GROUP="oinstall", MODE="0660"


1.2  Create UDEV Permission Rule For Version 11.2 And Later (Oracle 11.2以后的版本关于UDEV的配置)

Create a UDEV rules file for the Oracle ASM devices, setting permissions to read/write for the group and owner (0660) for the installation 

owner and the group whose members are to be administrators of the grid infrastructure software.

For example, using the installation owner grid and using a role-based group configuration, with the OSASM group asmadmin:


 For RHEL5/OL5/OEL5,

# /bin/cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/%P", RESULT=="350002ac000010b52", NAME="vote1", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/%P", RESULT=="350002ac000020b52", NAME="vote2", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s /block/%P", RESULT=="350002ac000030b52", NAME="vote3", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660" 


 For RHEL6/OL6:   ---注意这里用$符号

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="350002ac000010b52", NAME="vote1", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="350002ac000020b52", NAME="vote2", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id i --whitelisted --device=/dev/$name", RESULT=="350002ac000030b52", NAME="vote3", ACTION=="add|change", OWNER="grid",GROUP="asmadmin", MODE="0660"

良心备注:

用心的用户会发这里有的地方用双等号,有的地方用的是一个等号。如果熟悉开发的就会理解,==用于判断,=用于赋值。那么每一行语句的意思就是满足KERNEL、BUS、PROGRAM、RESULT、ACTION的条件的设备就他赋上NAME、OWNER、GROUP的值。


KERNEL代表设备标识符,sd就是硬盘,sd*匹配所有以sd开头的硬盘;

BUS代表总线类型,如果不清楚,这个条件就不要加了;

PROGRAM是一条命令,$name为变量,其实就是KERNEL的值;

[root@RAC1 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sde  
201d1a3c69673ab30

RESULT是设备的唯一ID,也叫wwid,就是上面命令输出的ID;

ACTION为动作类型;

NAME就是给等于该ID的设备起个名字;

OWNER就是指定该ID的设备的拥有者;

GROUP就是指定该ID的设备所属组;


Copy this rules.d/file to all other nodes on the cluster. For example:

# /usr/bin/scp 99-oracle-asmdevices.rules root@node2:/etc/udev/rules.d/99-oracle-asmdevices.rules

2. Restart The UDEV Service

Restart the UDEV service as follows. Then verify the devices now reflect their intended ownership and permissions:

On SLES10:

# /etc/init.d/boot.udev stop
# /etc/init.d/boot.udev start

On RHEL5/OEL5/OL5:

# /sbin/udevcontrol reload_rules
# /sbin/start_udev

On RHEL6/OL6:

#/sbin/udevadm control --reload-rules
#/sbin/start_udev

3. Additional UDEV information

For additional information on UDEV, including how to manage multiple partitions, refer to the following article:   

Using udev with Oracle Architecture (RAC & ASM) - Red Hat 4.0 Note:371814.1

References (以下是可以参考的文档,需要metalink账号)

NOTE:465001.1 - Configuring raw devices (singlepath) for Oracle Clusterware 10g Release 2 (10.2.0) on RHEL5/OEL5

NOTE:371814.1 - Using udev with Oracle Architecture (RAC & ASM) - Red Hat 4.0

NOTE:564580.1 - Configuring raw devices (multipath) for Oracle Clusterware 10g Release 2 (10.2.0) on RHEL5/OL5

0

热门评论