LVM + lvmlockd (clvm replacement)
source code
1 | https://sourceware.org/git/?p=lvm2.git |
🚨prepare
❗操作之后需要把之前冗余的
activate的 lv 都设置成inactive1
2
3
4
5flite
lvscan | grep '/csi-lvm/' | grep -v inactive
deactivate duplicate pv
lvchange -an /dev/csi-lvm/pvc-xxx
install
1 | sanlock and lvmlocked |
lvmlocked
enable locked
1
2vim /etc/lvm/lvm.conf
use_lvmlockd = 1check
1
lvmconfig --type current global/use_lvmlockd
restart lvmlockd
1
systemctl restart lvmlockd
sanlock
config host id
1
2
3
4
5vim /etc/lvm/lvmlocal.conf
local {
# Replace <nodeNum> with the unique integer for this node (e.g., 1, 2, 3...)
host_id = <nodeNum>
}Restart
1
2
3systemctl restart sanlock
sleep 8
systemctl restart lvmlockd
first node
Convert VG to sanlock
config sanlock
1
(optional) lvchange -an csi-lvm
skip global lockspace
1
2
3
4
5
6
7vgchange --lock-type sanlock --lockopt skipgl csi-lvm
print
WARNING: skipping global lock in lvmlockd.
Logical volume "lvmlock" created.
device-mapper: remove ioctl on (253:9) failed: Device or resource busy
Volume group "csi-lvm" successfully changed
Start the Lockspace
Activate the lockspace for newly converted VG.This allows the local lvmlockd to manage it.
1 | vgchange --lock-start csi-lvm |
Enable the Global Lock
1 | enable |
other node
Start the Lockspace
1 | vgchange --lock-start csi-lvm |
init lock
1 | lvcreate -L 10G -n lv-temp-1 csi-lvm |
best practices
查看当前节点持有的锁
1 | sanlock client status |
check lvmlockd status
1 | systemctl status lvmlockd |