Initial set up
Setting up LVM to use lvmlockd and a shared VG for the first time
includes some one time set up steps:
1. choose a lock manager
dlm
If dlm (or corosync) are already being used by other cluster
software, then select dlm. dlm uses corosync which requires
additional configuration beyond the scope of this document. See
corosync and dlm documentation for instructions on configuration,
set up and usage.
sanlock
Choose sanlock if dlm/corosync are not otherwise required.
sanlock does not depend on any clustering software or
configuration.
2. configure hosts to use lvmlockd
On all hosts running lvmlockd, configure lvm.conf:
use_lvmlockd = 1
sanlock
Assign each host a unique host_id in the range 1-2000 by setting
/etc/lvm/lvmlocal.conf local/host_id
3. start lvmlockd
Start the lvmlockd daemon.
Use systemctl, a cluster resource agent, or run directly, e.g.
systemctl start lvmlockd
4. start lock manager
sanlock
Start the sanlock and wdmd daemons.
Use systemctl or run directly, e.g.
systemctl start wdmd sanlock
dlm
Start the dlm and corosync daemons.
Use systemctl, a cluster resource agent, or run directly, e.g.
systemctl start corosync dlm
5. create VG on shared devices
vgcreate --shared <vgname> <devices>
The shared option sets the VG lock type to sanlock or dlm
depending on which lock manager is running. LVM commands acquire
locks from lvmlockd, and lvmlockd uses the chosen lock manager.
6. start VG on all hosts
vgchange --lock-start
Shared VGs must be started before they are used. Starting the VG
performs lock manager initialization that is necessary to begin
using locks (i.e. creating and joining a lockspace). Starting
the VG may take some time, and until the start completes the VG
may not be modified or activated.
7. create and activate LVs
Standard lvcreate and lvchange commands are used to create and
activate LVs in a shared VG.
An LV activated exclusively on one host cannot be activated on
another. When multiple hosts need to use the same LV
concurrently, the LV can be activated with a shared lock (see
lvchange options -aey vs -asy.) (Shared locks are disallowed for
certain LV types that cannot be used from multiple hosts.)
Normal start up and shut down
After initial set up, start up and shut down include the
following steps. They can be performed directly or may be
automated using systemd or a cluster resource manager/agents.
• start lvmlockd
• start lock manager
• vgchange --lock-start
• activate LVs in shared VGs
The shut down sequence is the reverse:
• deactivate LVs in shared VGs
• vgchange --lock-stop
• stop lock manager
• stop lvmlockd