Clustering cron daemon with pacemaker on Cent OS 7
node1.example.com
node2.example.com
Add the following to the /etc/hosts file in both nodes so that they are able to reach each other
X.X.X.X node1.example.com node1
X.X.X.X node2.example.com node2
Now install the pre-requisites on both nodes
#systemctl start pcsd.service
#systemctl enable pcsd.service
Now authorize the cluster nodes. Will ask for username and password. Use "hacluster"
#pcs cluster auth node1 node2
Now create the cluster
#pcs cluster setup --name MYCLUSTER node1 node2
#pcs cluster start --all
Now disable STONITH and quorum as it is not required for a two node setup
#pcs property set stonithpcs resource create CRON systemd:crond-enabled=false
#pcs property set no-quorum-policy=ignore
Now add the resources. We need a virtual IP and tomcat resource
#pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=x.x.x.x cidr_netmask=24 op monitor interval=30s
#pcs resource create CRON systemd:crond
Now to make both resources run in the same node we must have a constraint as follows
# pcs constraint colocation set VirtualIP CRON
This is a two node cluster with virtual IP and cron daemon as resources. The crontab has to be edited manually in both nodes to have the same task scheduled in it
node1.example.com
node2.example.com
Add the following to the /etc/hosts file in both nodes so that they are able to reach each other
X.X.X.X node1.example.com node1
X.X.X.X node2.example.com node2
Before starting with the cluster stop and disable the cron service in both nodes
#systemstl stop crond,service
#systemctl disable crond.service
Now install the pre-requisites on both nodes
#yum install -y pcs pacemaker corosync cman wget
Now set password for the hacluster user on both nodes
#passwd hacluster
Now start pcsd service and enable it on both nodes.
Now set password for the hacluster user on both nodes
#passwd hacluster
Now start pcsd service and enable it on both nodes.
#systemctl start pcsd.service
#systemctl enable pcsd.service
Now authorize the cluster nodes. Will ask for username and password. Use "hacluster"
#pcs cluster auth node1 node2
Now create the cluster
#pcs cluster setup --name MYCLUSTER node1 node2
#pcs cluster start --all
Now disable STONITH and quorum as it is not required for a two node setup
#pcs property set stonithpcs resource create CRON systemd:crond-enabled=false
#pcs property set no-quorum-policy=ignore
Now add the resources. We need a virtual IP and tomcat resource
#pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=x.x.x.x cidr_netmask=24 op monitor interval=30s
#pcs resource create CRON systemd:crond
Now to make both resources run in the same node we must have a constraint as follows
# pcs constraint colocation set VirtualIP CRON
Set the order in which the resources has to load
#pcs constraint order set VirtualIP CRON
All done. Now stop the cluster and start it.
#pcs cluster stop --all
#pcs cluster start --all
#pcs status
#pcs cluster stop --all
#pcs cluster start --all
#pcs status