HA Cluster: Configuring Software
Hosting-related system services
Since the software responsible for HA cluster will manage system services like Plesk, nginx, etc, we should disable all these services as they should not be started automatically with system. With the next command, we disable auto-starting for these services, which should be executed on the both nodes.
ha-node1 and ha-node2# for i in \
plesk-ip-remapping \
plesk-php74-fpm.service \
plesk-php82-fpm.service \
plesk-web-socket.service \
plesk-task-manager.service \
plesk-ssh-terminal.service \
plesk-repaird.socket \
sw-engine.service \
sw-cp-server.service \
psa.service \
cron.service \
xinetd.service \
nginx.service \
apache2.service httpd.service \
mariadb.service mysql.service postgresql.service \
named.service bind9.service named-chroot.service \
postfix.service; \
do systemctl disable $i && systemctl stop $i; \
done
As an output, you may see lines like “Failed to disable unit: Unit file bind9.service does not exist”. This is not a critical error because the command contains different name of the same services for different OSes like CentOS and Ubuntu or name of different services that provides similar functionality (like MySQL and MariaDB). If you have installed any additional component with Plesk like “php80”, you also need to disable a service for that component if a service was added to the server by the Plesk component.
You may run `ps ax` to double check that there are no more running services related to Plesk or any of its component.
Plesk Files
In the previous blog post, you can see how it is possible to copy the Plesk “vhosts” directory to the NFS storage. For HA cluster, we need to do the same and a few additional steps for the rest of the Plesk directories to make them available for nodes of the HA cluster.
On the NFS server, configure exporting of “/var/nfs/plesk-ha/plesk_files” the same way as “/var/nfs/plesk-ha/vhosts”. After configuring, you should see the directories are available for remote mounting from the internal network.
ha-nfs# exportfs -v
/var/nfs/plesk-ha/vhosts
10.0.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
/var/nfs/plesk-ha/plesk_files
10.0.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
When exporting is configured, we will need to copy Plesk to the NFS. For that, we have to pre-create a directory on each node for mounting NFS storage:
ha-node1 and ha-node2# mkdir -p /nfs/plesk_files
Files: vhosts
As we previously have decided to imagine the ha-node1 as an active node, the next commands should be executed on the ha-node1. To copy existing vhosts directory, run the next commands:
ha-node1# mount -t nfs -o "hard,timeo=600,retrans=2,_netdev" 10.0.0.12:/var/nfs/plesk-ha/vhosts /mnt
ha-node1# cp -aRv /var/www/vhosts/* /mnt
ha-node1# umount /mnt
Files: Plesk-related
Also, as we previously have decided to imagine the ha-node1 as an active node, the next commands should be executed on the ha-node1.
ha-node1# mount -t nfs -o "hard,timeo=600,retrans=2,_netdev" 10.0.0.12:/var/nfs/plesk-ha/plesk_files /nfs/plesk_files
ha-node1# mkdir -p /nfs/plesk_files/etc/{apache2,nginx,psa,sw,sw-cp-server,domainkeys,psa-webmail}
ha-node1# cp -a /etc/passwd /nfs/plesk_files/etc/
ha-node1# cp -aR /etc/apache2/. /nfs/plesk_files/etc/apache2
ha-node1# cp -aR /etc/nginx/. /nfs/plesk_files/etc/nginx
ha-node1# cp -aR /etc/psa/. /nfs/plesk_files/etc/psa
ha-node1# cp -aR /etc/sw/. /nfs/plesk_files/etc/sw
ha-node1# cp -aR /etc/sw-cp-server/. /nfs/plesk_files/etc/sw-cp-server
ha-node1# cp -aR /etc/sw-engine/. /nfs/plesk_files/etc/sw-engine
ha-node1# cp -aR /etc/domainkeys/. /nfs/plesk_files/etc/domainkeys
ha-node1# cp -aR /etc/psa-webmail/. /nfs/plesk_files/etc/psa-webmail
ha-node1# mkdir -p /nfs/plesk_files/var/{spool,named}
ha-node1# cp -aR /var/named/. /nfs/plesk_files/var/named
ha-node1# cp -aR /var/spool/. /nfs/plesk_files/var/spool
ha-node1# mkdir -p /nfs/plesk_files/opt/plesk/php/{7.4,8.2}/etc
ha-node1# cp -aR /opt/plesk/php/7.4/etc/. /nfs/plesk_files/opt/plesk/php/7.4/etc
ha-node1# cp -aR /opt/plesk/php/8.2/etc/. /nfs/plesk_files/opt/plesk/php/8.2/etc
ha-node1# mkdir -p /nfs/plesk_files/usr/local/psa/{admin/conf,admin/plib/modules,etc/modules,var/modules,var/certificates}
ha-node1# cp -aR /usr/local/psa/admin/conf/. /nfs/plesk_files/usr/local/psa/admin/conf
ha-node1# cp -aR /usr/local/psa/admin/plib/modules/. /nfs/plesk_files/usr/local/psa/admin/plib/modules
ha-node1# cp -aR /usr/local/psa/etc/modules/. /nfs/plesk_files/usr/local/psa/etc/modules
ha-node1# cp -aR /usr/local/psa/var/modules/. /nfs/plesk_files/usr/local/psa/var/modules
ha-node1# cp -aR /usr/local/psa/var/certificates/. /nfs/plesk_files/usr/local/psa/var/certificates
ha-node1# umount /nfs/plesk_files
Event Handler to keep /etc/passwd up2date
We need to update the passwd and group file on the NFS storage every time when Plesk updates the system users. For that, we will create a few event handlers for scenarios like domain creating, subscription updating, etc. Event handlers are saved in a Plesk database, which means we need to run the next command only on active node.
As we previously have decided to imagine the ha-node1 as an active node, the next commands should be executed on the ha-node1.
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event phys_hosting_create
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event phys_hosting_update
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event phys_hosting_delete
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event ftpuser_create
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event ftpuser_update
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event ftpuser_delete
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event site_subdomain_create
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event site_subdomain_update
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event site_subdomain_delete
ha-node1# plesk bin event_handler --create -command "/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd" -priority 50 -user root -event site_subdomain_move