DRBD can use any block device as it's backing disk; LVM or the physical disk itself will work with DRBD. Also, DRBD creates a new virtual block device, which you will be able to use as a Physical Volume for LVMs if you wish. Any LV or VG created on DRBD can be activated on the peer node after DRBD has been promoted to Primary there.
You will need to tweak your LVM filter to pick up the LVM signatures on DRBD devices, and disable LVM filter caching in /etc/lvm/lvm.conf
.
filter = ["a|/dev/sd.*|", "a|/dev/drbd.*|", "r|.*|"]
write_cache_state = 0
After doing that, you should be able to use LVM "above and below" DRBD. Create the LVM to be used as DRBD's backing disk (example assumes sdb1 is the physical drive); perform these steps on both nodes:
# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
# vgcreate vg_drbd_back /dev/sdb1
Volume group "vg_drbd_back" successfully created
# lvcreate --name r0 --size 100G vg_drbd_back
Logical volume "r0" created
Create your DRBD configuration for r0
on both nodes:
resource r0 {
device /dev/drbd0;
disk /dev/vg_drbd_back/r0;
meta-disk internal;
on host-a { address x.x.x.x:7789; }
on host-b { address x.x.x.x:7789; }
}
Initialize DRBD by creating the metadata and bringing the device up on both nodes, and then choose a single node to promote to Primary (--force only for the initial sync).
Then, on the Primary node, create the PV, VG, and LVM signatures on top of the DRBD device:
# pvcreate /dev/drbd0
Physical volume "/dev/drbd0" successfully created
# vgcreate vg_drbd_front /dev/drbd0
Volume group "vg_drbd_front" successfully created
# lvcreate --name drbd_lvm0 --size 30G vg_drbd_front
Logical volume "drbd_lvm0" created
# lvcreate --name drbd_lvm1 --size 40G vg_drbd_front
Logical volume "drbd_lvm1" created
To failover the LVM manually, you will need to deactivate the Volume Group on the Primary before you can demote it to Secondary:
# vgchange -a n vg_drbd_front
0 logical volume(s) in volume group "vg_drbd_front" now active
# drbdadm secondary r0
Then on the peer, promote DRBD and activate the Volume Group:
# drbdadm primary r0
# vgchange -a y vg_drbd_front
2 logical volume(s) in volume group "vg_drbd_front" now active
Of course, if you want to do this automatically with Pacemaker you will need to use the LVM resource agent which will handle the activation/deactivation of a specified VG:
# pcs resource describe ocf:heartbeat:LVM
Also, there are a lot of good (and free) technical guides and other resources at LINBIT's website that might be helpful in your clustering: http://www.linbit.com
EDIT: Added the section below regarding disabling 'lvmmetad'.
CentOS 7 enables the use of 'lvmetad' by default. You will need to disable that on both nodes for the filters to work as configured above.
In the /etc/lvm/lvm.conf
set use_lvmetad = 0
, and then stop lvm2-lvmmetad
's service and socket via systemd:
# systemctl stop lvm2-lvmetad.service
# systemctl stop lvm2-lvmetad.socket