redhat 7.x 、redhat 6.x查看硬盘UUID方法

1、查看磁盘分区UUID:

[root@rac01 ~]# blkid
/dev/sdb1: UUID="6bba92c4-0b25-4cc4-9442-ca87c563720a" TYPE="xfs"
/dev/sda1: UUID="21b2b922-fcb7-461f-bdc6-3bd92259f8d7" TYPE="xfs"
/dev/sda2: UUID="WC12Xe-0neg-Kmhp-u691-8bxn-8PpF-PuGgHH" TYPE="LVM2_member"
/dev/mapper/rhel-root: UUID="774aa4fa-2bbe-4636-a3ce-3a8aec9cdb40" TYPE="xfs"
/dev/mapper/rhel-swap: UUID="01075670-9314-4899-8d0f-23af11882416" TYPE="swap"
/dev/sr0: UUID="2016-10-19-18-32-06-00" LABEL="RHEL-7.3 Server.x86_64" TYPE="iso9660" PTTYPE="dos"
[root@rac01 ~]#
[root@rac01 ~]# ls -l /dev/disk/by-uuid/
total
lrwxrwxrwx. root root 9月 : ---8d0f-23af11882416 -> ../../dm-
lrwxrwxrwx. root root 9月 : ------ -> ../../sr0
lrwxrwxrwx. root root 9月 : 21b2b922-fcb7-461f-bdc6-3bd92259f8d7 -> ../../sda1
lrwxrwxrwx. root root 9月 : 6bba92c4-0b25-4cc4--ca87c563720a -> ../../sdb1
lrwxrwxrwx. root root 9月 : 774aa4fa-2bbe--a3ce-3a8aec9cdb40 -> ../../dm-
[root@rac01 ~]#

2、查看磁盘UUID

 

[root@rac01 ~]# lsscsi -i
[:::] disk VMware, VMware Virtual S 1.0 /dev/sda -
[:::] disk VMware, VMware Virtual S 1.0 /dev/sdb -
[:::] cd/dvd NECVMWar VMware SATA CD01 1.00 /dev/sr0 -
[:::] disk VMware, VMware Virtual S 1.0 /dev/sdc 36000c29cd6841d61d151f17cfaae37c1
[:::] disk VMware, VMware Virtual S 1.0 /dev/sdd 36000c29981370abb4b6dbf6101ad8e9f
[:::] disk VMware, VMware Virtual S 1.0 /dev/sde 36000c29b71c709b99b63547534028558
[:::] disk VMware, VMware Virtual S 1.0 /dev/sdf 36000c29bbaf58c22dcb92b6f6e4c67e9
[:::] disk VMware, VMware Virtual S 1.0 /dev/sdg 36000c2942fbfb7d286d52d2e7fa5cf05
[:::] disk VMware, VMware Virtual S 1.0 /dev/sdh 36000c29ac6f46745dccdcb2e623064da
[root@rac01 ~]#
[root@rac01 ~]# ls -l /dev/disk/by-id
total
lrwxrwxrwx. root root 9月 : ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001 -> ../../sr0
lrwxrwxrwx. root root 9月 : dm-name-rhel-root -> ../../dm-
lrwxrwxrwx. root root 9月 : dm-name-rhel-swap -> ../../dm-
lrwxrwxrwx. root root 9月 : dm-uuid-LVM-J1i1Vn6zXoJbfabPIPfJB0QKwuIkbSBEardSvOvgmlN05wDrG9PJHoxdW4m1RPwc -> ../../dm-
lrwxrwxrwx. root root 9月 : dm-uuid-LVM-J1i1Vn6zXoJbfabPIPfJB0QKwuIkbSBEqNT9omSEi4skcnWqN8lfzMLPGqezyZhm -> ../../dm-
lrwxrwxrwx. root root 9月 : lvm-pv-uuid-WC12Xe-0neg-Kmhp-u691-8bxn-8PpF-PuGgHH -> ../../sda2
lrwxrwxrwx. root root 9月 : scsi-36000c2942fbfb7d286d52d2e7fa5cf05 -> ../../sdg
lrwxrwxrwx. root root 9月 : scsi-36000c29981370abb4b6dbf6101ad8e9f -> ../../sdd
lrwxrwxrwx. root root 9月 : scsi-36000c29ac6f46745dccdcb2e623064da -> ../../sdh
lrwxrwxrwx. root root 9月 : scsi-36000c29b71c709b99b63547534028558 -> ../../sde
lrwxrwxrwx. root root 9月 : scsi-36000c29bbaf58c22dcb92b6f6e4c67e9 -> ../../sdf
lrwxrwxrwx. root root 9月 : scsi-36000c29cd6841d61d151f17cfaae37c1 -> ../../sdc
lrwxrwxrwx. root root 9月 : wwn-0x6000c2942fbfb7d286d52d2e7fa5cf05 -> ../../sdg
lrwxrwxrwx. root root 9月 : wwn-0x6000c29981370abb4b6dbf6101ad8e9f -> ../../sdd
lrwxrwxrwx. root root 9月 : wwn-0x6000c29ac6f46745dccdcb2e623064da -> ../../sdh
lrwxrwxrwx. root root 9月 : wwn-0x6000c29b71c709b99b63547534028558 -> ../../sde
lrwxrwxrwx. root root 9月 : wwn-0x6000c29bbaf58c22dcb92b6f6e4c67e9 -> ../../sdf
lrwxrwxrwx. root root 9月 : wwn-0x6000c29cd6841d61d151f17cfaae37c1 -> ../../sdc
[root@rac01 ~]#

使用/lib/udev/scsi_id查看磁盘UUID

[root@rac01 ~]# /lib/udev/scsi_id --help
Usage: scsi_id [OPTION...] DEVICE
SCSI device identification.
-h --help Print this message
--version Print version of the program
-d --device= Device node for SG_IO commands
-f --config= Location of config file
-p --page=0x80|0x83|pre-spc3- SCSI page (0x80, 0x83, pre-spc3-)
-s --sg-version=| Use SGv3 or SGv4
-b --blacklisted Treat device as blacklisted
-g --whitelisted Treat device as whitelisted
-u --replace-whitespace Replace all whitespace by underscores
-v --verbose Verbose logging
-x --export Print values as environment keys
[root@rac01 ~]#

命令:/lib/udev/scsi_id --whitelisted --device=/dev/sd*

[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdc
36000c29cd6841d61d151f17cfaae37c1
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdd
36000c29981370abb4b6dbf6101ad8e9f
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sde
36000c29b71c709b99b63547534028558
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdf
36000c29bbaf58c22dcb92b6f6e4c67e9
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdg
36000c2942fbfb7d286d52d2e7fa5cf05
[root@rac01 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/sdh
36000c29ac6f46745dccdcb2e623064da
[root@rac01 ~]#

******************************************************************************

注:

redhat 6.x命令为:

scsi_id --whitelisted --device=/dev/sd*

******************************************************************************

3、使用脚本输入磁盘UUID

符号“c d e f g h”为磁盘名

linux 7.x脚本为

[root@rac01 ~]# for i in c d e f g h;
> do
> echo "sd$i" "`/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i` ";
> done
sdc 36000c29cd6841d61d151f17cfaae37c1
sdd 36000c29981370abb4b6dbf6101ad8e9f
sde 36000c29b71c709b99b63547534028558
sdf 36000c29bbaf58c22dcb92b6f6e4c67e9
sdg 36000c2942fbfb7d286d52d2e7fa5cf05
sdh 36000c29ac6f46745dccdcb2e623064da
[root@rac01 ~]#

******************************************************************************

注:

linux 6.x脚本为

> do
> echo "sd$i" "`scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i` ";
> done
sdc 36000c29cd6841d61d151f17cfaae37c1
sdd 36000c29981370abb4b6dbf6101ad8e9f
sde 36000c29b71c709b99b63547534028558
sdf 36000c29bbaf58c22dcb92b6f6e4c67e9
sdg 36000c2942fbfb7d286d52d2e7fa5cf05
sdh 36000c29ac6f46745dccdcb2e623064da
[root@rac01 ~]#

******************************************************************************

4、Oracle ASM配置

生成文件内容的脚本

for i in c d e f g h;
do
echo "KERNEL==\"sd*\",BUS==\"scsi\", PROGRAM==\"/lib/udev/scsi_id --whitelisted --replace-whitespace--device=/dev/\$name\", RESULT==\"`/lib/udev/scsi_id --whitelisted--replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\",OWNER=\"grid\", GROUP=\"asmadmin\",MODE=\"0660\""
done [root@rac01 ~]# for i in c d e f g h;
> do
> echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""
> done
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29cd6841d61d151f17cfaae37c1", NAME="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE=""
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29981370abb4b6dbf6101ad8e9f", NAME="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE=""
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29b71c709b99b63547534028558", NAME="asm-diske", OWNER="grid", GROUP="asmadmin", MODE=""
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29bbaf58c22dcb92b6f6e4c67e9", NAME="asm-diskf", OWNER="grid", GROUP="asmadmin", MODE=""
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c2942fbfb7d286d52d2e7fa5cf05", NAME="asm-diskg", OWNER="grid", GROUP="asmadmin", MODE=""
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29ac6f46745dccdcb2e623064da", NAME="asm-diskh", OWNER="grid", GROUP="asmadmin", MODE=""
[root@rac01 ~]#

编写/etc/udev/rules文件,添加ASM块设备

将生成的内容保存在99-oracle-asmdevices.rules文件中。

修改磁盘名,便于识别:asm-grid1……

vim /etc/udev/rules.d/-oracle-asmdevices.rules

linux .x

#linux .x
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29cd6841d61d151f17cfaae37c1", NAME="asm-grid1", OWNER="grid", GROUP="asmadmin", MODE="" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29981370abb4b6dbf6101ad8e9f", NAME="asm-grid2", OWNER="grid", GROUP="asmadmin", MODE="" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29b71c709b99b63547534028558", NAME="asm-dgsystem", OWNER="grid", GROUP="asmadmin", MODE="" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29bbaf58c22dcb92b6f6e4c67e9", NAME="asm-dgrecovery", OWNER="grid", GROUP="asmadmin", MODE="" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c2942fbfb7d286d52d2e7fa5cf05", NAME="asm-dgdata1", OWNER="grid", GROUP="asmadmin", MODE="" KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="36000c29ac6f46745dccdcb2e623064da", NAME="asm-dgdata2", OWNER="grid", GROUP="asmadmin", MODE=""

linux7.x

#linux .x
KERNEL=="sdc",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29cd6841d61d151f17cfaae37c1",SYMLINK+="asm-grid1",OWNER="grid",GROUP="asmadmin",MODE="" KERNEL=="sdd",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29981370abb4b6dbf6101ad8e9f",SYMLINK+="asm-grid2",OWNER="grid",GROUP="asmadmin",MODE="" KERNEL=="sde",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29b71c709b99b63547534028558",SYMLINK+="asm-dgsystem",OWNER="grid",GROUP="asmadmin",MODE="" KERNEL=="sdf",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29bbaf58c22dcb92b6f6e4c67e9",SYMLINK+="asm-dgrecovery",OWNER="grid",GROUP="asmadmin",MODE="" KERNEL=="sdg",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c2942fbfb7d286d52d2e7fa5cf05",SYMLINK+="asm-dgdata1",OWNER="grid",GROUP="asmadmin",MODE="" KERNEL=="sdh",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id-g -u -d /dev/$name",RESULT=="36000c29ac6f46745dccdcb2e623064da",SYMLINK+="asm-dgdata2",OWNER="grid",GROUP="asmadmin",MODE=""

5、重启udev设备

/sbin/udevadm control --reload-rules

/sbin/start_udev

udevadm trigger

systemctl restartsystemd-udevd.service

[root@rac01 ~]# partprobe

[root@rac01 ~]# ll /dev/a*

crw-rw----.  root video ,  9月    : /dev/agpgart

lrwxrwxrwx.  root root         9月    : /dev/asm-dgdata1 -> sdg

lrwxrwxrwx.  root root         9月    : /dev/asm-dgdata2 -> sdh

lrwxrwxrwx.  root root         9月    : /dev/asm-dgrecovery -> sdf

lrwxrwxrwx.  root root         9月    : /dev/asm-dgsystem -> sde

lrwxrwxrwx.  root root         9月    : /dev/asm-grid1 -> sdc

lrwxrwxrwx.  root root         9月    : /dev/asm-grid2 -> sdd

crw-------.  root root  ,  9月    : /dev/autofs

[root@rac01 ~]#

6、重新生成

# rm -rf /dev/asm-dgsystem 

/sbin/udevadm control --reload-rules

/sbin/start_udev

udevadm trigger

systemctl restartsystemd-udevd.service

ll /dev/a*

***************************************************************************************

RestartUDEV 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

***************************************************************************************

参考:

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

http://www.zhongweicheng.com/?p=1608

上一篇:Linux命令——blkid


下一篇:MongoDB学习笔记-游标