Thursday 29 October 2015

Cron with Pacemaker

Clustering cron daemon with pacemaker on Cent OS 7

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.

#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

No comments:

Post a Comment

High Availability with IREDMAIL Integrated with Active Directory

This is step by step guide for Centos 7. Server1 will be the Active node and Server2 will be the failover node. After failover when ...