我的发行版是 SLES 12 SP 2。
我现在使用 DRBD(分布式复制块设备)。以下是 drbd 资源的配置示例。
resource HA1dat {
device /dev/drbd1;
disk /dev/mqdat/HA1;
meta-disk internal;
on srv0 {
address 192.168.174.10:7000;
node-id 0;
}
on srv1 {
address 192.168.174.11:7000;
node-id 1;
}
on srv9 {
address 192.168.174.19:7000;
node-id 2;
}
connection-mesh {
hosts srv0 srv1 srv9;
}
}
将此资源激活为 drbd 设备后,通常会创建以下对象。
brw-rw---- 1 root disk 147, 1 Feb 13 19:41 /dev/drbd1
lrwxrwxrwx 1 root root 14 Feb 13 19:41 /dev/drbd/by-res/HA1dat/0 -> ../../../drbd1
lrwxrwxrwx 1 root root 14 Feb 13 19:41 /dev/drbd/by-disk/mqdat/HA1 -> ../../../drbd1
这些是块设备本身和它的两个符号链接。
这是正确的行为!
在某些其他服务器(相同的发行版)上,行为有所不同。 drbd 资源的配置非常相似。
resource LN0N001Edat {
device /dev/drbd1;
disk /dev/data1vg/LN0N001E_lv;
meta-disk internal;
on sedcmmwd0030 {
address xxx.yyy.zzz.83:7000;
node-id 0;
}
on sedcmmwd0040 {
address xxx.yyy.zzz.99:7000;
node-id 1;
}
on sedcmmwd0050 {
address xxx.yyy.zzz.100:7000;
node-id 2;
}
connection-mesh {
hosts sedcmmwd0030 sedcmmwd0040 sedcmmwd0050;
}
}
激活该资源后,仅创建块设备和一条链路。
brw-rw---- 1 root disk 147, 1 Mar 2 09:49 /dev/drbd1
lrwxrwxrwx 1 root root 23 Mar 2 09:49 /dev/drbd/by-res/LN0N001Edat/0_drbd/by-disk/data1vg/LN0N001E_lv -> ../../../../../../drbd1
这就是问题!该链接是两个预期链接的串联。我不知道为什么它们被串联起来。
该链接由 udev 创建。以下输出显示了 udev 在这些节点上执行的操作的差异。
行为正确的服务器
juser@srv0:~> udevadm info /dev/drbd1
P: /devices/virtual/block/drbd1
N: drbd1
S: drbd/by-disk/mqdat/HA1
S: drbd/by-res/HA1dat/0
E: DEVICE=drbd1
E: DEVLINKS=/dev/drbd/by-res/HA1dat/0 /dev/drbd/by-disk/mqdat/HA1
E: DEVNAME=/dev/drbd1
E: DEVPATH=/devices/virtual/block/drbd1
E: DEVTYPE=disk
E: MAJOR=147
E: MINOR=1
E: SUBSYSTEM=block
E: SYMLINK=drbd/by-res/HA1dat/0 drbd/by-disk/mqdat/HA1
E: TAGS=:systemd:
E: USEC_INITIALIZED=12263844870
服务器有问题
root@sedcmmwd0030:/root : udevadm info /dev/drbd1
P: /devices/virtual/block/drbd1
N: drbd1
S: drbd/by-res/LN0N001Edat/0_drbd/by-disk/data1vg/LN0N001E_lv
E: DEVICE=drbd1
E: DEVLINKS=/dev/drbd/by-res/LN0N001Edat/0_drbd/by-disk/data1vg/LN0N001E_lv
E: DEVNAME=/dev/drbd1
E: DEVPATH=/devices/virtual/block/drbd1
E: DEVTYPE=disk
E: MAJOR=147
E: MINOR=1
E: SUBSYSTEM=block
E: SYMLINK=drbd/by-res/LN0N001Edat/0 drbd/by-disk/data1vg/LN0N001E_lv
E: TAGS=:systemd:
E: USEC_INITIALIZED=1212108486973
SYMLINK 行仍然正确。差异始于 DEVLINKS 行。
drbd 的规则在这两种情况下是相同的 cat /usr/lib/udev/rules.d/65-drbd.rules # 该文件包含创建命名 DRBD 设备的规则。
SUBSYSTEM!="block", GOTO="drbd_end"
KERNEL!="drbd*", GOTO="drbd_end"
IMPORT{program}="/sbin/drbdadm sh-udev minor-%m"
# Use symlink from the environment if available
ENV{SYMLINK}!="", SYMLINK="$env{SYMLINK}", GOTO="have_symlink"
# Legacy rules for older DRBD 8.3 & 8.4 when drbdadm sh-udev did not yet export SYMLINK
ENV{DISK}!="", SYMLINK+="drbd/by-disk/$env{DISK}"
ENV{RESOURCE}!="", SYMLINK+="drbd/by-res/$env{RESOURCE}"
LABEL="have_symlink"
ENV{DEVICE}=="drbd_?*", SYMLINK+="$env{DEVICE}"
LABEL="drbd_end"
有人对错误链接的创建有解释吗?
答案1
DRBD 的 udev 规则来自 drbd-utils。您安装了哪个版本的 DRBD utils?
最新版本 9.2.2 包含附加规则以及开发人员的评论,看起来可能会解决您的问题:
# This file contains the rules to create named DRBD devices.
SUBSYSTEM!="block", GOTO="drbd_end"
KERNEL!="drbd*", GOTO="drbd_end"
IMPORT{program}="@sbindir@/drbdadm sh-udev minor-%m"
# Use symlink from the environment if available
# some udev version thought it was a good idea to change a long established
# default of string_escape=none to string_escape=replace :-/
# therefore, recent enough drbdadm will no longer export space separated lists.
ENV{SYMLINK_BY_DISK}!="", SYMLINK+="$env{SYMLINK_BY_DISK}"
ENV{SYMLINK_BY_RES}!="", SYMLINK+="$env{SYMLINK_BY_RES}", GOTO="have_symlink"
ENV{SYMLINK}!="", OPTIONS+="string_escape=none", SYMLINK="$env{SYMLINK}", GOTO="have_symlink"
# Legacy rules for older DRBD 8.3 & 8.4 when drbdadm sh-udev did not yet export SYMLINK
ENV{DISK}!="", SYMLINK+="drbd/by-disk/$env{DISK}"
ENV{RESOURCE}!="", SYMLINK+="drbd/by-res/$env{RESOURCE}"
LABEL="have_symlink"
ENV{DEVICE}=="drbd_?*", SYMLINK+="$env{DEVICE}"
LABEL="drbd_end"