I have configured gluserfs on a pair of servers and I'm able to mount this on my client machines. I want to also be able to mount the glusterfs filesystem on both of the glusterfs servers on boot when I take both machines offline and start them from scratch.
These servers are set up as a cluster using pacemaker. In addition to a shared database, pacemaker is also providing a virtual IP address to mount the gluster filesystem from.
I can manually mount the filesystem on each after both servers are up with the command:
mount -t glusterfs nodea:/gv0 /data
Which is great. But I want this to happen automatically at boot.
So I've tried adding an entry to the fstab:
nodea:/gv0 /data glusterfs _netdev 0 0
Which works when I run the "mount -a" command after the cluster is up and running. However, it does not work at boot. (This is how the client machines mount the glusterfs on boot, but the cluster is up and running. So of course it works on boot for them.)
I have also tried creating a systemd unit file to handle the mounting of the glusterfs at boot. My unit file is in /etc/systemd/system named "data.mount" and looks like:
# Mounting gluster fs at /data [Unit] Description = Automount gluster filesystem After=pcsd.service [Mount] What=nodea:/gv0 Where=/data Type=glusterfs [Install] WantedBy = pcsd.service
Again, this works when both servers are up and running by running the command "systemctl start data.mount". It also works if I only reboot one of the machines in the cluster. But it doesn't work on a reboot of both servers.
If both nodes in the cluster go down, or if I feel like rebooting both at the same time for whatever reason, I want to be sure that when both machines come back up, that the glusterfs is mounted on /data.
As a work around, I've added the following lines to root's crontab on both machines:
@reboot sleep 60 && mount -t glusterfs nodea:/gv0 /data @reboot sleep 300 && mount -t glusterfs nodea:/gv0 /data
This works if I start both severs up from scratch. But my concern is that if the pacemaker service ever takes longer than 5 minutes to start up, then I still don't have the gluster filesystem mounted on the server at /data.
Is there a way to have the systemd unit file check if it actually mounted the filesystem and if not to retry until it does?
Is there some other way to have the glusterfs mount at boot and to check that it's actually mounted?