RHEL 6.x or 7.x 使用分区绑定ASM 磁盘的方法

 

RHEL 6.x or 7.x 使用分区绑定ASM 磁盘的方法

 

 

 

测试环境 VMware workstation 12

 

 

VMware 启用磁盘uuid的方法: 关闭虚拟机,编辑 XXX.vmx 文件,添加如下内容

 

disk.EnableUUID = "TRUE"

disk.locking=false

 

例如,我需要将/dev/sdc1 和 /dev/sdc5 绑定为ASM 磁盘

 

[root@prim ~]# fdisk -l /dev/sdc

 

Disk /dev/sdc: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x828454c2

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         654     5253223+  83  Linux

/dev/sdc2             655        2610    15711570    5  Extended

/dev/sdc5             655        1960    10490413+  83  Linux

 

可以使用udevadm 命令的 info 参数查看磁盘的udev 信息:

 

[root@prim ~]# udevadm info --query=all --name=sdc1

P: /devices/pci0000:00/0000:00:10.0/host0/target0:0:2/0:0:2:0/block/sdc/sdc1

N: sdc1

W: 76

S: block/8:33

S: disk/by-id/scsi-36000c29bc8bb23487f1d592961d4732a-part1

S: disk/by-path/pci-0000:00:10.0-scsi-0:0:2:0-part1

S: disk/by-id/wwn-0x6000c29bc8bb23487f1d592961d4732a-part1

E: UDEV_LOG=3

E: DEVPATH=/devices/pci0000:00/0000:00:10.0/host0/target0:0:2/0:0:2:0/block/sdc/sdc1

E: MAJOR=8

E: MINOR=33

E: DEVNAME=/dev/sdc1

E: DEVTYPE=partition

E: SUBSYSTEM=block

E: ID_SCSI=1

E: ID_VENDOR=VMware_

E: ID_VENDOR_ENC=VMware\x2c\x20

E: ID_MODEL=VMware_Virtual_S

E: ID_MODEL_ENC=VMware\x20Virtual\x20S

E: ID_REVISION=1.0

E: ID_TYPE=disk

E: ID_SERIAL_RAW=36000c29bc8bb23487f1d592961d4732a

E: ID_SERIAL=36000c29bc8bb23487f1d592961d4732a

E: ID_SERIAL_SHORT=6000c29bc8bb23487f1d592961d4732a

E: ID_WWN=0x6000c29bc8bb2348

E: ID_WWN_VENDOR_EXTENSION=0x7f1d592961d4732a

E: ID_WWN_WITH_EXTENSION=0x6000c29bc8bb23487f1d592961d4732a

E: ID_SCSI_SERIAL=6000c29bc8bb23487f1d592961d4732a

E: ID_BUS=scsi

E: ID_PATH=pci-0000:00:10.0-scsi-0:0:2:0

E: ID_PART_TABLE_TYPE=dos

E: LVM_SBIN_PATH=/sbin

E: DEVLINKS=/dev/block/8:33 /dev/disk/by-id/scsi-36000c29bc8bb23487f1d592961d4732a-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:2:0-part1 /dev/disk/by-id/wwn-0x6000c29bc8bb23487f1d592961d4732a-part1

 

[root@prim ~]# udevadm info --query=all --name=sdc5

P: /devices/pci0000:00/0000:00:10.0/host0/target0:0:2/0:0:2:0/block/sdc/sdc5

N: sdc5

W: 75

S: block/8:37

S: disk/by-id/scsi-36000c29bc8bb23487f1d592961d4732a-part5

S: disk/by-path/pci-0000:00:10.0-scsi-0:0:2:0-part5

S: disk/by-id/wwn-0x6000c29bc8bb23487f1d592961d4732a-part5

E: UDEV_LOG=3

E: DEVPATH=/devices/pci0000:00/0000:00:10.0/host0/target0:0:2/0:0:2:0/block/sdc/sdc5

E: MAJOR=8

E: MINOR=37

E: DEVNAME=/dev/sdc5

E: DEVTYPE=partition

E: SUBSYSTEM=block

E: ID_SCSI=1

E: ID_VENDOR=VMware_

E: ID_VENDOR_ENC=VMware\x2c\x20

E: ID_MODEL=VMware_Virtual_S

E: ID_MODEL_ENC=VMware\x20Virtual\x20S

E: ID_REVISION=1.0

E: ID_TYPE=disk

E: ID_SERIAL_RAW=36000c29bc8bb23487f1d592961d4732a

E: ID_SERIAL=36000c29bc8bb23487f1d592961d4732a

E: ID_SERIAL_SHORT=6000c29bc8bb23487f1d592961d4732a

E: ID_WWN=0x6000c29bc8bb2348

E: ID_WWN_VENDOR_EXTENSION=0x7f1d592961d4732a

E: ID_WWN_WITH_EXTENSION=0x6000c29bc8bb23487f1d592961d4732a

E: ID_SCSI_SERIAL=6000c29bc8bb23487f1d592961d4732a

E: ID_BUS=scsi

E: ID_PATH=pci-0000:00:10.0-scsi-0:0:2:0

E: ID_PART_TABLE_TYPE=dos

E: LVM_SBIN_PATH=/sbin

E: DEVLINKS=/dev/block/8:37 /dev/disk/by-id/scsi-36000c29bc8bb23487f1d592961d4732a-part5 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:2:0-part5 /dev/disk/by-id/wwn-0x6000c29bc8bb23487f1d592961d4732a-part5

 

 

我们可以使用上面标记的属性来做个udev策略,重新绑定ASM磁盘

 

vi /etc/udev/rules.d/99-oracle-asmdevices.rules

 

添加如下内容:

ACTION=="add|change", KERNEL=="sdc[1-9]",ENV{MAJOR}=="8", ENV{MINOR}=="33",ENV{ID_SERIAL}=="36000c29bc8bb23487f1d592961d4732a",NAME="asm-disk1", OWNER="grid", GROUP="dba", MODE="0660"

ACTION=="add|change", KERNEL=="sdc[1-9]",ENV{MAJOR}=="8", ENV{MINOR}=="37",ENV{ID_SERIAL}=="36000c29bc8bb23487f1d592961d4732a",NAME="asm-disk2", OWNER="grid", GROUP="dba", MODE="0660"

 

重新加载udev规则,重新启动udev服务

 

udevadm  control --reload-rules

start_udev 或者udevadm trigger --subsystem-match=block

 

 

检查ASM磁盘绑定结果,如下:

 

[root@prim rules.d]# ll /dev/asm-disk*

brw-rw---- 1 grid dba 8, 33 Aug 17 09:24 /dev/asm-disk1

brw-rw---- 1 grid dba 8, 37 Aug 17 09:24 /dev/asm-disk2

 

 

RHEL 7.X 环境

 

[root@dbhost ~]# fdisk -l /dev/sdb

 

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x06295d7d

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048    10487807     5242880   83  Linux

/dev/sdb2        10487808    41943039    15727616    5  Extended

/dev/sdb5        10489856    31461375    10485760   83  Linux

 

 

 

 

[root@dbhost ~]# udevadm info --query=all  --name=sdb1

P: /devices/pci0000:00/0000:00:10.0/host0/target0:0:1/0:0:1:0/block/sdb/sdb1

N: sdb1

S: disk/by-id/scsi-36000c2992700177f54863a9424df7060-part1

S: disk/by-id/wwn-0x6000c2992700177f54863a9424df7060-part1

S: disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1

E: DEVLINKS=/dev/disk/by-id/scsi-36000c2992700177f54863a9424df7060-part1 /dev/disk/by-id/wwn-0x6000c2992700177f54863a9424df7060-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1

E: DEVNAME=/dev/sdb1

E: DEVPATH=/devices/pci0000:00/0000:00:10.0/host0/target0:0:1/0:0:1:0/block/sdb/sdb1

E: DEVTYPE=partition

E: ID_BUS=scsi

E: ID_MODEL=VMware_Virtual_S

E: ID_MODEL_ENC=VMware\x20Virtual\x20S

E: ID_PART_ENTRY_DISK=8:16

E: ID_PART_ENTRY_NUMBER=1

E: ID_PART_ENTRY_OFFSET=2048

E: ID_PART_ENTRY_SCHEME=dos

E: ID_PART_ENTRY_SIZE=10485760

E: ID_PART_ENTRY_TYPE=0x83

E: ID_PART_TABLE_TYPE=dos

E: ID_PATH=pci-0000:00:10.0-scsi-0:0:1:0

E: ID_PATH_TAG=pci-0000_00_10_0-scsi-0_0_1_0

E: ID_REVISION=1.0

E: ID_SCSI=1

E: ID_SCSI_SERIAL=6000c2992700177f54863a9424df7060

E: ID_SERIAL=36000c2992700177f54863a9424df7060

E: ID_SERIAL_SHORT=6000c2992700177f54863a9424df7060

E: ID_TYPE=disk

E: ID_VENDOR=VMware_

E: ID_VENDOR_ENC=VMware\x2c\x20

E: ID_WWN=0x6000c2992700177f

E: ID_WWN_VENDOR_EXTENSION=0x54863a9424df7060

E: ID_WWN_WITH_EXTENSION=0x6000c2992700177f54863a9424df7060

E: MAJOR=8

E: MINOR=17

E: SUBSYSTEM=block

E: TAGS=:systemd:

E: USEC_INITIALIZED=4962256

 

 

[root@dbhost ~]# udevadm info --query=all  --name=sdb5

P: /devices/pci0000:00/0000:00:10.0/host0/target0:0:1/0:0:1:0/block/sdb/sdb5

N: sdb5

S: disk/by-id/scsi-36000c2992700177f54863a9424df7060-part5

S: disk/by-id/wwn-0x6000c2992700177f54863a9424df7060-part5

S: disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part5

E: DEVLINKS=/dev/disk/by-id/scsi-36000c2992700177f54863a9424df7060-part5 /dev/disk/by-id/wwn-0x6000c2992700177f54863a9424df7060-part5 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part5

E: DEVNAME=/dev/sdb5

E: DEVPATH=/devices/pci0000:00/0000:00:10.0/host0/target0:0:1/0:0:1:0/block/sdb/sdb5

E: DEVTYPE=partition

E: ID_BUS=scsi

E: ID_MODEL=VMware_Virtual_S

E: ID_MODEL_ENC=VMware\x20Virtual\x20S

E: ID_PART_ENTRY_DISK=8:16

E: ID_PART_ENTRY_NUMBER=5

E: ID_PART_ENTRY_OFFSET=10489856

E: ID_PART_ENTRY_SCHEME=dos

E: ID_PART_ENTRY_SIZE=20971520

E: ID_PART_ENTRY_TYPE=0x83

E: ID_PART_TABLE_TYPE=dos

E: ID_PATH=pci-0000:00:10.0-scsi-0:0:1:0

E: ID_PATH_TAG=pci-0000_00_10_0-scsi-0_0_1_0

E: ID_REVISION=1.0

E: ID_SCSI=1

E: ID_SCSI_SERIAL=6000c2992700177f54863a9424df7060

E: ID_SERIAL=36000c2992700177f54863a9424df7060

E: ID_SERIAL_SHORT=6000c2992700177f54863a9424df7060

E: ID_TYPE=disk

E: ID_VENDOR=VMware_

E: ID_VENDOR_ENC=VMware\x2c\x20

E: ID_WWN=0x6000c2992700177f

E: ID_WWN_VENDOR_EXTENSION=0x54863a9424df7060

E: ID_WWN_WITH_EXTENSION=0x6000c2992700177f54863a9424df7060

E: MAJOR=8

E: MINOR=21

E: SUBSYSTEM=block

E: TAGS=:systemd:

E: USEC_INITIALIZED=4962296

 

 注: RHEL 7.X 之后 不能再使用NAME了,而是 SYMLINK+ 来做个链接

 

vi /etc/udev/rules.d/99-oracle-asmdevices.rules

 

ACTION=="add|change", KERNEL=="sdb[1-9]",ENV{MAJOR}=="8", ENV{MINOR}=="17",ENV{ID_SERIAL}=="36000c2992700177f54863a9424df7060",SYMLINK+="asm-disk1", OWNER="grid", GROUP="dba", MODE="0660"

ACTION=="add|change", KERNEL=="sdb[1-9]",ENV{MAJOR}=="8", ENV{MINOR}=="21",ENV{ID_SERIAL}=="36000c2992700177f54863a9424df7060",SYMLINK+="asm-disk2", OWNER="grid", GROUP="dba", MODE="0660"

 

 

注: RHEL 7.X udev 多了ID_PART_ENTRY_NUMBER 属性,因此也可以用ID_PART_ENTRY_NUMBER属性来替换(MAJOR,MINOR)绑定磁盘,如下:

 

 

 

ACTION=="add|change", KERNEL=="sdb[1-9]",ENV{ID_PART_ENTRY_NUMBER}=="1",ENV{ID_SERIAL}=="36000c2992700177f54863a9424df7060",SYMLINK+="asm-disk1", OWNER="grid", GROUP="dba", MODE="0660"

ACTION=="add|change", KERNEL=="sdb[1-9]",ENV{ID_PART_ENTRY_NUMBER}=="5",ENV{ID_SERIAL}=="36000c2992700177f54863a9424df7060",SYMLINK+="asm-disk2", OWNER="grid", GROUP="dba", MODE="0660"

 

 

 

udevadm  control --reload-rules

 

systemctl restart systemd-udevd.service  

或者:

udevadm trigger --subsystem-match=block

 

 

验证结果如下:

 

[root@dbhost rules.d]# ll /dev/asm*

lrwxrwxrwx. 1 root root 4 Aug 17 10:01 /dev/asm-disk1 -> sdb1

lrwxrwxrwx. 1 root root 4 Aug 17 10:01 /dev/asm-disk2 -> sdb5

[root@dbhost rules.d]#

[root@dbhost rules.d]#

[root@dbhost rules.d]# ll /dev/sdb*

brw-rw----. 1 root disk 8, 16 Aug 17 10:01 /dev/sdb

brw-rw----. 1 grid dba  8, 17 Aug 17 10:01 /dev/sdb1

brw-rw----. 1 root disk 8, 18 Aug 17 10:01 /dev/sdb2

brw-rw----. 1 grid dba  8, 21 Aug 17 10:01 /dev/sdb5

 

上一篇:实验2 汇编源程序编写与汇编、调试


下一篇:Java IO流经典练习题