wulinggo

Oracle OCP+AIX+Linux+Weblogic 安装升级,容灾备份,故障分析,异常修复,数据恢复! 私We-Chat- 同博客号!

oracle linux 7使用udev绑盘操作

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

适用于:

Linux OS - Version Oracle Linux 7.0 and later
Oracle Cloud Infrastructure - Version N/A and later
Linux x86-64

现象:

asm磁盘配置在/dev/asm下,用以下的udev规则,但是主机重启后,asm磁盘没有创建在/dev/asm下。

使用规则 :

KERNEL=="emcpower*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="360060160da5031005e5c4dab3230e311", RUN+="/bin/sh -c 'mknod /dev/asm/ASP_DATA12C b $major $minor; chown oracle:oinstall /dev/asm/ASP_DATA12C; chmod 0660 /dev/asm/ASP_DATA12C'"
 

原因:

The udev rule is triggered but it fails to create the disk under /dev/asm because the directory asm is not present under /dev.

In OL7, the /dev is a tmpfs and generated dynamically when the system comes up and hence the asm directory is not present under /dev after a reboot.

Test case:

There is no directory /dev/asm

<HOSTNAME>@ ~]# udevadm control --reload-rules
<HOSTNAME>@ ~]# udevadm trigger --type=devices --action=change
<HOSTNAME>@ ~]# ll /dev/asm/
total 0
brw-rw---- 1 oracle oinstall 8, 32 Oct 18 22:51 ASP_DATA12C

Check the udev Rules

<HOSTNAME>@ ~]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
ACTION=="add|change", KERNEL=="sdc", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1", RUN+="/bin/sh -c 'mknod /dev/asm/ASP_DATA12C b $major $minor; chown oracle:oinstall /dev/asm/ASP_DATA12C; chmod 0660 /dev/asm/ASP_DATA12C'"
<HOSTNAME>@ ~]# udevadm control --reload-rules
<HOSTNAME>@ ~]# udevadm trigger --type=devices --action=change'mknod /dev/asm/ASP_DATA12C b $major $minor
<HOSTNAME>@ ~]# ll /dev/sdc
sdc sdc1
<HOSTNAME>@ ~]# ll /dev/sdc1
brw-rw---- 1 root disk 8, 33 Oct 18 22:48 /dev/sdc1

Created 'asm' directory manually but after the reboot directory will be deleted

<HOSTNAME>@ ~]# mkdir /dev/asm                                              <<<< Created Directory 'asm'
<HOSTNAME>@ ~]# mknod /dev/asm/ASP_DATA12C b 8 33            <<<<<<< 8 33 are major and minor numbers .
<HOSTNAME>@ ~]# udevadm control --reload-rules
<HOSTNAME>@ ~]# udevadm trigger --type=devices --action=change
<HOSTNAME>@ ~]# ll /dev/asm/
total 0
brw-r--r-- 1 root root 8, 33 Oct 18 22:50 ASP_DATA12C 


But after the reboot this directory will be deleted . 

解决:

The solution is to create the directory using the udev rule before the asm disk is created.

    1.  Add the line highlighted in Bold (/usr/bin/mkdir /dev/asm) : 

      <HOSTNAME> ~]# vi /etc/udev/rules.d/96-asmmultipath.rules
      ACTION=="add|change", KERNEL=="sdb", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="1ATA_VBOX_HARDDISK_VB4e42ee2e-c26ef95f", RUN+="/bin/sh -c '/usr/bin/mkdir/dev/asm; mknod /dev/asm/ASP_DATA12C b $major $minor; chown oracle:oinstall /dev/asm/ASP_DATA12C; chmod 0660 /dev/asm/ASP_DATA12C'"
    2. Try to run udevadm 'reload' and 'trigger' command once the rule is set : 

      <HOSTNAME> ~]# udevadm control --reload-rules 
      <HOSTNAME> ~]# udevadm trigger --type=devices --action=change


    3. Check by Rebooting the server and check if the directory are present .

      <HOSTNAME> ~]# ll /dev/asm/
      total 0
      brw-rw----. 1 oracle oinstall 8, 16 Oct 19 10:42 ASP_DATA12C
    4. 例子:

  

KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b43600d8200000080", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/ocr01 b 8 16; chown grid:asmadmin /dev/asm/ocr01; chmod 0660 /dev/asm/ocr01'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b436039e900000081", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/ocr02 b 8 32; chown grid:asmadmin /dev/asm/ocr02; chmod 0660 /dev/asm/ocr02'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b4360540300000082", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/ocr03 b 8 48; chown grid:asmadmin /dev/asm/ocr03; chmod 0660 /dev/asm/ocr03'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b43606e9e00000083", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/data01 b 8 64; chown grid:asmadmin /dev/asm/data01; chmod 0660 /dev/asm/data01'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b4360875b00000084", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/data02 b 8 80; chown grid:asmadmin /dev/asm/data02; chmod 0660 /dev/asm/data02'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b4360c84500000087", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/data03 b 8 96; chown grid:asmadmin /dev/asm/data03; chmod 0660 /dev/asm/data03'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b4360af1000000086", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/data04 b 8 112; chown grid:asmadmin /dev/asm/data04; chmod 0660 /dev/asm/data04'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="363c7843100ba123b4360ea7600000088", RUN+="/bin/sh -c '/usr/bin/mkdir /dev/asm; mknod /dev/asm/fra01 b 8 128; chown grid:asmadmin /dev/asm/fra01; chmod 0660 /dev/asm/fra01'"

  

posted on 2019-06-20 09:58  wulinggo  阅读(4592)  评论(0编辑  收藏  举报

导航