1

I am trying to create a small 3 node ha cluster with apache2, php, mariadb with galera, glusterfs, haproxy and keepalived on debian 11. I want to sync the majority of config files (which are the same in their content) and use systemd.path unit to restart a particular service on other nodes when the content of monitored directory is changed. In this particular case it's apache2 service and its config folder.

/etc/apache2 directory was moved to glusterfs brick which is mounted on all nodes at /mnt/apache2. /etc/apache2 directory is then deleted on all nodes and symlink is created on all the nodes from /mnt/apache2 to /etc/apache2. Systemd monitors the /mnt/apache2 directory for changes.

If I create a file on lets say node1 in /mnt/apache2 the apache2 service is restarted on node1 only, although the changes are replicated on all nodes. The service will restart only on the node that made the change in monitored directory although the content changed an all the nodes and I don't know why the service wont restart on other nodes.

I have tried csync2 with lsyncd to achieve realtime sync but often csync2 would report some files or directories "dirty" and the sync wont happen, also service restart with csync2 on content change I could not make that work either.

Here are unit files content:

#/etc/systemd/system/apache2monitor.path

[Unit]
Description="Monitor /mnt/apache2 folder for changes"

[Path]
PathChanged=/mnt/apache2
Unit=apache2monitor.service

[Install]
WantedBy=multi-user.target

#/etc/systemd/system/apache2monitor.service

[Unit]
Description="Restarts apache2 service based on .path unit"

[Service]
ExecStart=/etc/init.d/apache2 restart

0

You must log in to answer this question.

Browse other questions tagged .