Move Elasticsearch data to dedicated LV

# create lvm
pvcreate /dev/disk/by-id/ata-INTEL_SSDSC2KB076T8_*
vgcreate data /dev/disk/by-id/ata-INTEL_SSDSC2KB076T8_*
lvcreate --name elasticsearch --size 2T data
mkfs.ext4 /dev/data/elasticsearch
 
# pre-sync data
mount /dev/data/elasticsearch /mnt/
rsync -aHAXx --numeric-ids /var/lib/docker/volumes/elasticsearch/ /mnt/
 
# sync data
docker stop elasticsearch
rsync --delete -aHAXxv --numeric-ids /var/lib/docker/volumes/elasticsearch/ /mnt/
rsync --delete -aHAXxv --numeric-ids /var/lib/docker/volumes/elasticsearch/ /mnt/
umount /mnt
 
# mount new LV
mv /var/lib/docker/volumes/elasticsearch{,.org}
mkdir /var/lib/docker/volumes/elasticsearch
echo "/dev/mapper/data-elasticsearch   /var/lib/docker/volumes/elasticsearch    ext4    defaults    0    2" >> /etc/fstab 
mount -a
 
# restart elasticsearch container
docker start elasticsearch
# docker logs elasticsearch
 
# visudo -f /etc/sudoers.d/nagios
echo "nagios ALL=(root) NOPASSWD: /usr/lib/nagios/plugins/check_disk *" >> /etc/sudoers.d/nagios
 
# allow NRPE access to volume
vi /etc/nagios/nrpe.cfg
command[check_disk]=/usr/bin/sudo /usr/lib/nagios/plugins/check_disk -w "10%" -c "5%" -l -X devtmpfs -X sysfs -X tmpfs -X cgroup -X proc -X udev -X debugfs -X overlay -X cgmfs -X tracefs -A -I lxc -I nsfs
service nagios-nrpe-server restart
 
# Debug
journalctl _COMM=sudo -f