HA Cluster – Configuration Software
Hosting-Related System Services
Since the software responsible for the HA cluster will manage the system services like Plesk, nginx, etc., we need to disable all these services as they should not be started automatically by the system. With the following command, we disable the automatic start of these services, which must be executed on 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; \
made
As a result, you may see lines like “Error disabling drive: drive file bind9.service does not exist.” This is not a critical error because the command contains a different name of the same services for different operating systems like CentOS and Ubuntu or the name of different services that provide similar functionality (like MySQL and MariaDB). If you have installed any additional component with Plesk such as “php80”, you should also disable a service for that component if the Plesk component added a service to the server.
You can run `ps ax` to check that there are no other running services related to Plesk or any of its components.
Plesk files
In the above blog post, you can see how it is possible to copy Plesk “vhosts” directory to NFS storage. For the HA cluster, we need to do the same and some additional steps for the rest of the Plesk directories to make them available to the HA cluster nodes.
On the NFS server, configure the export of “/var/nfs/plesk-ha/plesk_files” in the same way as “/var/nfs/plesk-ha/vhosts”. After the configuration, you should see that 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 the export is configured, we will need to copy Plesk to NFS. For that, we have to previously create a directory on each node to mount the NFS storage:
ha-node1 and ha-node2# mkdir -p /nfs/plesk_files
Files: vhosts
Since we previously decided to imagine ha-node1 as an active node, the following commands should be executed on ha-node1. To copy the existing vhosts directory, run the following commands:
ha-node1# mount -t nfs -o “hard,timeo=600,retrans=2,_netdev” 10.0.0.12:/var/nfs/plesk-ha/vhosts /mntha-node1# cp -aRv /var/www/ vhosts/* /mntha-node1# unmount /mnt
Files: Plesk Related
Also, since we previously decided to imagine ha-node1 as an active node, the following commands should be executed on 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/apache2ha-node1# cp -aR /etc/nginx/. /nfs/plesk_files/etc/nginxha-node1# cp -aR /etc/psa/. /nfs/plesk_files/etc/psaha-node1# cp -aR /etc/sw/. /nfs/plesk_files/etc/swha-node1# cp -aR /etc/sw-cp-server/. /nfs/plesk_files/etc/sw-cp-serverha-node1# cp -aR /etc/sw-engine/. /nfs/plesk_files/etc/sw-engineha-node1# cp -aR /etc/domainkeys/. /nfs/plesk_files/etc/domainkeysha-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/namedha-node1# cp -aR /var/spool/. /nfs/plesk_files/var/spool
ha-node1# mkdir -p /nfs/plesk_files/opt/plesk/php/{7.4,8.2}/etcha-node1# cp -aR /opt/plesk/php/7.4/etc/. /nfs/plesk_files/opt/plesk/php/7.4/etcha-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/confha-node1# cp -aR /usr/local/psa/admin/plib/modules/. /nfs/plesk_files/usr/local/psa/admin/plib/modulesha-node1# cp -aR /usr/local/psa/etc/modules/. /nfs/plesk_files/usr/local/psa/etc/modulesha-node1# cp -aR /usr/local/psa/var/modules/. /nfs/plesk_files/usr/local/psa/var/modulesha-node1# cp -aR /usr/local/psa/var/certificates/. /nfs/plesk_files/usr/local/psa/var/certificates
ha-node1# unmount /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 Plesk updates the system users. For that, we’ll create some event handlers for scenarios like domain creation, subscription update, etc. Event handlers are stored in a Plesk database, which means we need to run the following command only on the active node.
Since we previously decided to imagine ha-node1 as an active node, the following commands should be executed on 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_createha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd” -priority 50 -user root -event phys_hosting_updateha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/ plesk_files/etc/passwd” -priority 50 -root user -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_createha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd” -priority 50 -root user -event ftpuser_updateha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/ plesk_files/etc/passwd” -priority 50 -root user -ftpuser_delete event
ha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd” -priority 50 -user root -event site_subdomain_createha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd” -priority 50 -root user -event site_subdomain_updateha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/ plesk_files/etc/passwd” -priority 50 -root user -event site_subdomain_deleteha-node1# plesk bin event_handler –create -command “/bin/cp /etc/passwd /nfs/plesk_files/etc/passwd” -priority 50 -root user -event site_subdomain_move