[Oracle] oracle udev配置


本文总阅读量

1、添加裸设备

增加磁盘vda,vdb,vdc
在节点1上分别对vda,vdb,vdc三块盘分区

1
2
3
fdisk /dev/vda
fdisk /dev/vdb
fdisk /dev/vdc

节点1查看设备信息:

1
2
3
4
5
6
7
8
9
10
[root@rac1 ~]# ll /dev/vd*
brw-rw---- 1 root disk 252, 0 Dec 14 10:56 /dev/vda
brw-rw---- 1 root disk 252, 1 Dec 14 10:56 /dev/vda1
brw-rw---- 1 root disk 252, 2 Dec 14 10:56 /dev/vda2
brw-rw---- 1 root disk 252, 16 Dec 14 11:41 /dev/vdb
brw-rw---- 1 root disk 252, 17 Dec 14 11:41 /dev/vdb1
brw-rw---- 1 root disk 252, 32 Dec 14 11:34 /dev/vdc
brw-rw---- 1 root disk 252, 33 Dec 14 11:34 /dev/vdc1
brw-rw---- 1 root disk 252, 48 Dec 14 11:34 /dev/vdd
brw-rw---- 1 root disk 252, 49 Dec 14 11:34 /dev/vdd1

节点2查看设备信息:

1
2
3
4
5
6
7
[root@rac2 ~]# ll /dev/vd*
brw-rw---- 1 root disk 252, 0 Dec 14 10:56 /dev/vda
brw-rw---- 1 root disk 252, 1 Dec 14 10:56 /dev/vda1
brw-rw---- 1 root disk 252, 2 Dec 14 10:56 /dev/vda2
brw-rw---- 1 root disk 252, 16 Dec 14 10:56 /dev/vdb
brw-rw---- 1 root disk 252, 32 Dec 14 10:56 /dev/vdc
brw-rw---- 1 root disk 252, 48 Dec 14 10:56 /dev/vdd

major device number可以看作是设备驱动程序,被同一设备驱动程序管理的设备有相同的major device number.这个数字实际是Kernel中device driver table 的索引,这个表保存着不同设备驱动程序。(kvm虚拟机virto的驱动对应的major device number值为252,scsi的驱动对应的major device number值为8,裸设备为162)
minor device number用来代表被访问的具体设备。就是说Kernel根据major device number 找到设备驱动程序,然后再从minor device number 获得设备位置等属性。

2、修改配置文件

节点1
vim /etc/udev/rules.d/60-raw.rules

1
2
3
4
5
6
7
8
ACTION=="add", KERNEL=="/dev/vdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="252",ENV{MINOR}=="17",RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="/dev/vdc1",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", ENV{MAJOR}=="252",ENV{MINOR}=="33",RUN+="/bin/raw /dev/raw/raw2 %M %m"
ACTION=="add", KERNEL=="/dev/vdd1",RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", ENV{MAJOR}=="252",ENV{MINOR}=="49",RUN+="/bin/raw /dev/raw/raw3 %M %m"

KERNEL=="raw[1-3]", OWNER="grid", GROUP="oinstall", MODE="640"

节点2
vim /etc/udev/rules.d/60-raw.rules

1
2
3
4
5
6
7
8
ACTION=="add", KERNEL=="/dev/vdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="252",ENV{MINOR}=="17",RUN+="/bin/raw /dev/raw/raw1 %M %m"
ACTION=="add", KERNEL=="/dev/vdc1",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", ENV{MAJOR}=="252",ENV{MINOR}=="33",RUN+="/bin/raw /dev/raw/raw2 %M %m"
ACTION=="add", KERNEL=="/dev/vdd1",RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", ENV{MAJOR}=="252",ENV{MINOR}=="49",RUN+="/bin/raw /dev/raw/raw3 %M %m"

KERNEL=="raw[1-3]", OWNER="grid", GROUP="oinstall", MODE="640"

上述操作需要在双节点执行!且确保在双节点均可以看到裸设备文件,以及grid(或者oracle)用户具有对裸设备的权限

3、启动udev

1
2
3
4
5
6
7
8
9
10
centos6使用start_udev

centos7之后使用
/sbin/udevadm control --reload-rules
/sbin/udevadm trigger
或者
/sbin/udevadm trigger --type=devices --action=change
查看设备状态:
ll /dev/raw/raw*
在配置过程中,启动udev之后没有看到设备,重启服务器后才生效。

4、使用scis驱动方式添加磁盘,用udev根据uuid方式绑定磁盘:

添加sda,sdb,sdc三块盘,获取共享磁盘的uuid

1
2
3
4
5
6
[root@rac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sda
0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-0
[root@rac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb
0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-2
[root@rac1 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1

5、按以下格式写入[/etc/udev/rules.d/99-my-asmdevices.rules]文件,每个设备一行,中间不允许换行

节点1:
vim /etc/udev/rules.d/99-my-asmdevices.rules

1
2
3
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",  PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode",  RESULT=="0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-0", RUN+="/bin/sh -c 'mknod /dev/asmdisk-vote b  $major $minor; chown grid:asmadmin /dev/asmdisk-vote; chmod 0660 /dev/asmdisk-vote'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-2", RUN+="/bin/sh -c 'mknod /dev/asmdisk-arch b $major $minor; chown grid:asmadmin /dev/asmdisk-arch; chmod 0660 /dev/asmdisk-arch'"
KERNEL=="sd*[!0-9]", 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/asmdisk-data b $major $minor; chown grid:asmadmin /dev/asmdisk-data; chmod 0660 /dev/asmdisk-data'"

节点2:
vim /etc/udev/rules.d/99-my-asmdevices.rules

1
2
3
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block",  PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode",  RESULT=="0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-0", RUN+="/bin/sh -c 'mknod /dev/asmdisk-vote b  $major $minor; chown grid:asmadmin /dev/asmdisk-vote; chmod 0660 /dev/asmdisk-vote'"
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-2", RUN+="/bin/sh -c 'mknod /dev/asmdisk-arch b $major $minor; chown grid:asmadmin /dev/asmdisk-arch; chmod 0660 /dev/asmdisk-arch'"
KERNEL=="sd*[!0-9]", 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/asmdisk-data b $major $minor; chown grid:asmadmin /dev/asmdisk-data; chmod 0660 /dev/asmdisk-data'"

6、启动udev

1
2
3
4
5
6
7
centos6使用start_udev

centos7之后使用
/sbin/udevadm control --reload-rules
/sbin/udevadm trigger
或者
/sbin/udevadm trigger --type=devices --action=change

查看设备状态

1
2
3
4
[root@rac1 ~]# ll /dev/asmdisk-*
brw-rw---- 1 grid asmadmin 8, 16 Dec 14 14:18 /dev/asmdisk-arch
brw-rw---- 1 grid asmadmin 8, 32 Dec 14 14:18 /dev/asmdisk-data
brw-rw---- 1 grid asmadmin 8, 0 Dec 14 14:18 /dev/asmdisk-vote

7、使用udevadm查看设备信息

udevadm info -a -p /sys/block/sda

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device '/devices/pci0000:00/0000:00:0d.0/virtio5/host2/target2:0:0/2:0:0:0/block/sda':
KERNEL=="sda"
SUBSYSTEM=="block"
DRIVER==""
ATTR{ro}=="0"
ATTR{size}=="41943040"
ATTR{stat}==" 521604 4 820941 5583621 355886 1462 1263929 7839050 0 9373468 13420933"
ATTR{range}=="16"
ATTR{discard_alignment}=="0"
ATTR{events}==""
ATTR{ext_range}=="256"
ATTR{events_poll_msecs}=="-1"
ATTR{alignment_offset}=="0"
ATTR{inflight}==" 0 0"
ATTR{removable}=="0"
ATTR{capability}=="50"
ATTR{events_async}==""

looking at parent device '/devices/pci0000:00/0000:00:0d.0/virtio5/host2/target2:0:0/2:0:0:0':
KERNELS=="2:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{rev}=="1.5."
ATTRS{type}=="0"
ATTRS{scsi_level}=="6"
ATTRS{model}=="QEMU HARDDISK "
ATTRS{state}=="running"
ATTRS{unpriv_sgio}=="0"
ATTRS{queue_type}=="none"
ATTRS{iodone_cnt}=="0xd660c"
ATTRS{iorequest_cnt}=="0xd664c"
ATTRS{device_busy}=="0"
ATTRS{evt_capacity_change_reported}=="0"
ATTRS{timeout}=="30"
ATTRS{evt_media_change}=="0"
ATTRS{ioerr_cnt}=="0x18"
ATTRS{queue_depth}=="128"
ATTRS{vendor}=="QEMU "
ATTRS{evt_soft_threshold_reached}=="0"
ATTRS{device_blocked}=="0"
ATTRS{evt_mode_parameter_change_reported}=="0"
ATTRS{evt_lun_change_reported}=="0"
ATTRS{evt_inquiry_change_reported}=="0"
ATTRS{dh_state}=="detached"
ATTRS{iocounterbits}=="32"
ATTRS{inquiry}==""
ATTRS{vpd_pg83}==""
ATTRS{eh_timeout}=="10"

looking at parent device '/devices/pci0000:00/0000:00:0d.0/virtio5/host2/target2:0:0':
KERNELS=="target2:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:0d.0/virtio5/host2':
KERNELS=="host2"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:0d.0/virtio5':
KERNELS=="virtio5"
SUBSYSTEMS=="virtio"
DRIVERS=="virtio_scsi"
ATTRS{device}=="0x0008"
ATTRS{features}=="0110000000000000000000000000110000000000000000000000000000000000"
ATTRS{status}=="0x00000007"
ATTRS{vendor}=="0x1af4"

looking at parent device '/devices/pci0000:00/0000:00:0d.0':
KERNELS=="0000:00:0d.0"
SUBSYSTEMS=="pci"
DRIVERS=="virtio-pci"
ATTRS{irq}=="10"
ATTRS{subsystem_vendor}=="0x1af4"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x010000"
ATTRS{driver_override}=="(null)"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{dma_mask_bits}=="64"
ATTRS{local_cpus}=="ff"
ATTRS{device}=="0x1004"
ATTRS{enable}=="1"
ATTRS{msi_bus}==""
ATTRS{local_cpulist}=="0-7"
ATTRS{vendor}=="0x1af4"
ATTRS{subsystem_device}=="0x0008"
ATTRS{numa_node}=="-1"
ATTRS{d3cold_allowed}=="0"

looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
目录
  1. 1. 1、添加裸设备
  2. 2. 2、修改配置文件
  3. 3. 3、启动udev
  4. 4. 4、使用scis驱动方式添加磁盘,用udev根据uuid方式绑定磁盘:
  5. 5. 5、按以下格式写入[/etc/udev/rules.d/99-my-asmdevices.rules]文件,每个设备一行,中间不允许换行
  6. 6. 6、启动udev
  7. 7. 7、使用udevadm查看设备信息

Proudly powered by Hexo and Theme by Lap
本站访客数人次
© 2020 zeven0707's blog