A lot inspired of another thread
https://forum.proxmox.com/threads/p...-lvm-lv-with-msa2040-sas-partial-howto.57536/
i did a doc for our internal needs :
Prior to configure block device, you may know if you want to use iscsi or fc to connect on storage array. On our lab, we have done test using primera for storage array and san switch using FC for transport protocol.
Install multipath-tool and configure multipath.conf according to storage array vendor best practice
code_language.shell:
apt-get install multipath-tools -y
you need to do same on all nodes where you want to see block devices
Add multipath.conf file to /etc of all nodes
As an example for Primera storage with one lun shared on lab
code_language.shell:
cat /etc/multipath.conf
defaults {
polling_interval 10
retain_attached_hw_handler 0
user_friendly_names yes
}
devices {
device {
vendor "3PARdata"
product "VV"
path_grouping_policy "group_by_prio"
uid_attribute "ID_SERIAL"
prio "alua"
path_selector "service-time 0"
path_checker "tur"
hardware_handler "1 alua"
failback "immediate"
rr_weight "uniform"
no_path_retry 18
rr_min_io_rq 1
fast_io_fail_tmo 10
dev_loss_tmo "infinity"
}
}
blacklist {
wwid .*
}
blacklist_exceptions {
wwid "360002ac000000000000002a400027b43"
}
multipaths {
multipath {
wwid "360002ac000000000000002a400027b43"
alias mpatha
}
}
Wwid can be find using:
code_language.shell:
/lib/udev/scsi_id -g -u -d /dev/mapper/mpathX
there're four proxmox boxes on our lab pvirtocbhpewd01..pvirtocbhpewd04
commands should be issued on one of the boxes
code_language.shell:
for i in $(seq 1 4); do ssh pvirtocbhpewd0$i apt install lvm2-lockd dlm-controld gfs2-utils -y; done
for i in $(seq 1 4); do ssh pvirtocbhpewd0$i 'echo DLM_CONTROLD_OPTS="--enable_fencing 0 --post_join_delay 10 --log_debug 1 --protocol sctp" >> /etc/default/dlm; systemctl restart dlm'; done
We use sctp like corosync when multihomed corosync is used (best practice), then we need to postconfigure some part on lvm by modifying /etc/lvm/lvm.conf and uncomment.
code_language.shell:
use_lvmlockd = 1
lvmlockd_lock_retries = 3
To allow a proper restart of lvm after a reboot we add a sleep on daemon start, adding a file sleep.conf on /etc/systemd/system/lvmlockd.service.d
File content:
code_language.shell:
[Service]
ExecStartPre=/usr/bin/sleep 20
Then we can start properly dlm on all nodes prior to lvmlockd, to ensure that we execute
code_language.shell:
for i in $(seq 1 4); do ssh pvirtocbhpewd0$i "systemctl stop dlm; rmmod gfs2; rmmod dlm; sleep 3; systemctl restart udev; sleep 3; systemctl start dlm"; done
After that we will create gfs2 filesystem, prior to this we init physical extend and create shared volume group
code_language.shell:
pvcreate /dev/mapper/XXX
vgcreate san_vg /dev/mapper/XXX
XXX must be replace by multipath device needed like /dev/mapper/mpatha on our lab, after creating vg, we need to modify back again /etc/lvm/lvm.conf and add entry on activation section for this vg, example on lab :
code_language.shell:
activation {
volume_list = [ "san_vg","san_vg/san_datastore" ]
}
Recopy /etc/lvm/lvm.conf on all nodes.
After, we need to find cluster name of pve node using
code_language.shell:
pve_cluster_name=`grep cluster_name /etc/pve/corosync.conf | awk '{print $2}'`
You can verify pve_cluster_name using
After that we create gfs2 file-sytem
code_language.shell:
mkfs.gfs2 -t pve_cluster_name:fs_name -j 4 -J 64 blockdevice
pve_cluster_name is the one found previously, fs_name is the name of fs you want to create, -j is to create X journal , X is same as number of node that will use this filesystem (on our lab 4 nodes), -J is size of journal here 64Mbytes, /dev/vg/lv is the blockdevice to use, on our example blockdevice is /dev/san_vg/san_datastore and fs_name is san-lun0-gfs2
You can now test mounting gfs2 filesystem on one node using below commands
code_language.shell:
vgchange --lock-start san_vg
lvchange -asy /dev/san_vg/san_datastore
mkdir -p /mnt/pve/san-lun0-gfs2
mount -t gfs2 /dev/san_vg/san_datastore /mnt/pve/san-lun0-gfs2/
if all is ok you shall see mounted volume, you can then umount /mnt/pve/san-lun0-gfs2
Now we need to prepare environment to reboot properly, meaning on start , first dlm than lvmlockd, then activate lock on vg and finally activate lv and mount it, revert when we stop, to do that we will prepare unit files for systemd, we don’t modify lvmlockd.services it shall remain unchanged in case of upgrade of packages, we create two differents unit files to manage proper start and stop
First one will be responsible to lock vgs, we create lvmlocks.service on /etc/system/system/multi-user.target.wants
code_language.shell:
[Unit]
Description=LVM locking start and stop
Documentation=man:lvmlockd(8)
Requires=lvmlockd.service dlm.service corosync.service
After=lvmlockd.service dlm.service corosync.service
[Service]
Type=oneshot
RemainAfterExit=yes
# start lockspaces and wait for them to finish starting
ExecStart=/usr/bin/bash -c "/sbin/lvm vgchange --lock-start --lock-opt auto"
# stop lockspaces and wait for them to finish stopping
ExecStop=/usr/bin/bash -c "/sbin/lvm vgchange --lock-stop"
[Install]
WantedBy=multi-user.target
We add also a file sleep.conf on /etc/systemd/system/lvmlocks.service.d
code_language.shell:
[Service]
ExecStartPre=/usr/bin/sleep 20
Then second unit file to activate lv and mount it and vice versa, we create an unit file on /etc/systemd/system/ named lvmshared.service :
code_language.shell:
[Unit]
Description=LVM locking LVs and mount LVs start and stop
Documentation=man:lvmlockd(8)
After=lvmlocks.service lvmlockd.service dlm.service
Before=pve-ha-lrm.service pve-guests.service
[Service]
Type=oneshot
RemainAfterExit=Yes
# start lockspaces LVs and mount LVs
ExecStart=/usr/bin/bash -c "/usr/sbin/vgs --noheadings -o name -S vg_shared=yes | xargs /usr/sbin/lvchange -asy && /usr/sbin/lvs --noheadings -o lv_path -S vg_shared=yes | xargs mount"
# stop lockspaces LVs after umount LVs
ExecStop=/usr/bin/bash -c "/usr/sbin/lvs --noheadings -o lv_path -S vg_shared=yes | xargs umount && /usr/sbin/lvs --noheadings -o name -S vg_shared=yes | xargs /usr/bin/lvchange -an"
[Install]
WantedBy=multi-user.target
You can copy this file on all nodes needed, then we add this service to systemd on all nodes concern, using
code_language.shell:
systemctl enable lvmlocks
systemctl enable lvmshared
Last we need to add entry in /etc/fstab to mount filesystem at boot time, again for each node, on our lab we added one line at the end of fstab like that :
code_language.shell:
/dev/san_vg/san_datastore /mnt/pve/san-lun0-gfs2 gfs2 noatime,nodiratime,noauto 1 2
Now we can test automounter by starting service lvmshared
code_language.shell:
systemctl start lvmlocks
systemctl start lvmshared
Again you shall be able to see mount on shell.
Now we need to add on pve gui , on cluster we go to Storage, Add Directory, fill id with a human readable name, tick Shared, complete directory path that is the mount point, and restrict if needed nodes lists allowed to use this storage, content type allow to use all type of content