[Linux7] Centos7 multipath 盤許可權繫結.

tolilong發表於2018-01-29
Centos7 multipath 盤許可權繫結.
[root@centos7 ~]$ more /etc/udev/rules.d/99-oracle.rules
KERNEL=="dm-0",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-1",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-2",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-3",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-4",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-5",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-6",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-7",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-8",OWNER="oragrid",GROUP="dba",MODE="0660"
KERNEL=="dm-9",OWNER="oragrid",GROUP="dba",MODE="0660"

關機前的對應關係
[root@centos7 ~]$ ls -l /dev/mapper/
total 0
crw-------. 1 root root 10, 236 Jan 26 12:18 control
lrwxrwxrwx. 1 root root       7 Jan 29 08:06 data01 -> ../dm-3
lrwxrwxrwx. 1 root root       7 Jan 29 08:06 data02 -> ../dm-0
lrwxrwxrwx. 1 root root       7 Jan 26 11:35 data03 -> ../dm-1
lrwxrwxrwx. 1 root root       7 Jan 29 08:06 data04 -> ../dm-4
lrwxrwxrwx. 1 root root       7 Jan 29 08:06 fra01 -> ../dm-5
lrwxrwxrwx. 1 root root       7 Jan 26 11:35 fra02 -> ../dm-6
lrwxrwxrwx. 1 root root       7 Jan 26 11:35 ocr01 -> ../dm-8
lrwxrwxrwx. 1 root root       7 Jan 26 11:35 ocr02 -> ../dm-7
lrwxrwxrwx. 1 root root       7 Jan 26 11:35 ocr03 -> ../dm-9
lrwxrwxrwx. 1 root root       8 Jan 26 12:18 ocr04 -> ../dm-10
lrwxrwxrwx. 1 root root       7 Jan 26 11:35 virtual -> ../dm-2
lrwxrwxrwx. 1 root root       8 Jan 26 12:18 virtual1 -> ../dm-11

重啟後.對應關係發生了變化。如下:
data01重啟是都要dm-3,重啟後是dm-2
[root@centos7 ~]$ ls -l /dev/mapper/
total 0
crw-------. 1 root root 10, 236 Jan 29  2018 control
lrwxrwxrwx. 1 root root       7 Jan 29  2018 data01 -> ../dm-2
lrwxrwxrwx. 1 root root       7 Jan 29  2018 data02 -> ../dm-4
lrwxrwxrwx. 1 root root       7 Jan 29  2018 data03 -> ../dm-5
lrwxrwxrwx. 1 root root       7 Jan 29  2018 data04 -> ../dm-7
lrwxrwxrwx. 1 root root       7 Jan 29  2018 fra01 -> ../dm-3
lrwxrwxrwx. 1 root root       7 Jan 29  2018 fra02 -> ../dm-0
lrwxrwxrwx. 1 root root       7 Jan 29  2018 ocr01 -> ../dm-1
lrwxrwxrwx. 1 root root       7 Jan 29  2018 ocr02 -> ../dm-8
lrwxrwxrwx. 1 root root       8 Jan 29  2018 ocr03 -> ../dm-10
lrwxrwxrwx. 1 root root       7 Jan 29  2018 ocr04 -> ../dm-9
lrwxrwxrwx. 1 root root       7 Jan 29  2018 virtual -> ../dm-6
lrwxrwxrwx. 1 root root       8 Jan 29  2018 virtual1 -> ../dm-11

所以 KERNEL=="dm-0",OWNER="oragrid",GROUP="dba",MODE="0660"
這種繫結許可權的方式有問題。
如果恰好沒有繫結到...許可權則不能正常賦予了。

採用如下方式,繫結許可權。
[root@centos7 /etc/udev/rules.d]$ more 99-oracle.rules
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/ocr01"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/ocr02"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/ocr03"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/ocr04"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/data01"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/data02"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/data03"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/data04"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/fra01"
PROGRAM="/usr/bin/chown oragrid:dba /dev/mapper/fra02"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/ocr01"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/ocr02"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/ocr03"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/ocr04"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/data01"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/data02"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/data03"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/data04"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/fra01"
PROGRAM="/usr/bin/chmod 0660 /dev/mapper/fra02"

重啟後檢視許可權,給ASM用的盤的許可權正常。
[root@centos7 /etc/udev/rules.d]$ ls -l /dev/mapper/
total 0
crw-------. 1 root root 10, 236 Jan 29  2018 control
lrwxrwxrwx. 1 root root       7 Jan 29 09:47 data01 -> ../dm-3
lrwxrwxrwx. 1 root root       7 Jan 29 09:47 data02 -> ../dm-5
lrwxrwxrwx. 1 root root       7 Jan 29 09:41 data03 -> ../dm-4
lrwxrwxrwx. 1 root root       7 Jan 29 09:47 data04 -> ../dm-2
lrwxrwxrwx. 1 root root       7 Jan 29 09:47 fra01 -> ../dm-6
lrwxrwxrwx. 1 root root       7 Jan 29 09:41 fra02 -> ../dm-0
lrwxrwxrwx. 1 root root       7 Jan 29 09:41 ocr01 -> ../dm-7
lrwxrwxrwx. 1 root root       7 Jan 29 09:41 ocr02 -> ../dm-8
lrwxrwxrwx. 1 root root       8 Jan 29 09:41 ocr03 -> ../dm-10
lrwxrwxrwx. 1 root root       7 Jan 29 09:41 ocr04 -> ../dm-9
lrwxrwxrwx. 1 root root       7 Jan 29  2018 virtual -> ../dm-1
lrwxrwxrwx. 1 root root       8 Jan 29  2018 virtual1 -> ../dm-11
[root@centos7 /etc/udev/rules.d]$ ls -l /dev/dm*
brw-rw----. 1 oragrid dba  253,  0 Jan 29 09:41 /dev/dm-0
brw-rw----. 1 root    disk 253,  1 Jan 29  2018 /dev/dm-1
brw-rw----. 1 oragrid dba  253, 10 Jan 29 09:41 /dev/dm-10
brw-rw----. 1 root    disk 253, 11 Jan 29  2018 /dev/dm-11
brw-rw----. 1 oragrid dba  253,  2 Jan 29 09:47 /dev/dm-2
brw-rw----. 1 oragrid dba  253,  3 Jan 29 09:51 /dev/dm-3
brw-rw----. 1 oragrid dba  253,  4 Jan 29 09:41 /dev/dm-4
brw-rw----. 1 oragrid dba  253,  5 Jan 29 09:51 /dev/dm-5
brw-rw----. 1 oragrid dba  253,  6 Jan 29 09:51 /dev/dm-6
brw-rw----. 1 oragrid dba  253,  7 Jan 29 09:51 /dev/dm-7
brw-rw----. 1 oragrid dba  253,  8 Jan 29 09:51 /dev/dm-8
brw-rw----. 1 oragrid dba  253,  9 Jan 29 09:41 /dev/dm-9


***裡面不能用*代替,*不起作用。chown,chmod加上命令的全路徑。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2150608/,如需轉載,請註明出處,否則將追究法律責任。

相關文章