Originally I was using Heartbeat to create two-node Linux clusters with floating IPs, but when Heartbeat stopped being developed I needed to figure out how to use Corosync and Pacemaker for this instead. Somewhat annoyingly, Linux HA stuff has changed yet again in CentOS 6.4, so now it’s necessary to use CMAN and Pacemaker instead.
This is quite a lot more in-depth than the simple configuration that was originally required for Heartbeat. Anyway, based on my recent experiences, here’s a very quick guide for if you find yourself in a similar situation. This works for me on CentOS 6.4 and higher, but it won’t work on earlier versions of CentOS.
If you’re looking for the old instructions for creating a cluster with Pacemaker and Corosync, they’re here.
Installation and initial configuration
Install the required packages on both machines:
yum install pacemaker cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
Set up and configure the cluster on the primary machine, changing newcluster , server1.example.com and server2.example.com as needed:
ccs -f /etc/cluster/cluster.conf --createcluster newcluster ccs -f /etc/cluster/cluster.conf --addnode server1.example.com ccs -f /etc/cluster/cluster.conf --addnode server2.example.com ccs -f /etc/cluster/cluster.conf --addfencedev pcmk agent=fence_pcmk ccs -f /etc/cluster/cluster.conf --addmethod pcmk-redirect server1.example.com ccs -f /etc/cluster/cluster.conf --addmethod pcmk-redirect server2.example.com ccs -f /etc/cluster/cluster.conf --addfenceinst pcmk server1.example.com pcmk-redirect port=server1.example.com ccs -f /etc/cluster/cluster.conf --addfenceinst pcmk server2.example.com pcmk-redirect port=server2.example.com
Copy /etc/cluster/cluster.conf from the primary machine to the secondary machine in the cluster.
It’s necessary to turn off quorum checking, so do this on both machines:
echo "CMAN_QUORUM_TIMEOUT=0" >> /etc/sysconfig/cman
Start the services
Start up the services on both machines:
service cman start service pacemaker start
Make sure both services start on reboot:
chkconfig cman on chkconfig pacemaker on
Configure and create floating IP
Configure the cluster on the primary machine:
pcs property set stonith-enabled=false pcs property set no-quorum-policy=ignore
Create the floating IP on the primary machine, changing the IP address and server name as needed:
pcs resource create livefrontendIP0 ocf:heartbeat:IPaddr2 ip=192.168.100.100 cidr_netmask=32 op monitor interval=30s pcs constraint location livefrontendIP0 prefers server1.example.com=INFINITY
To monitor the status of the cluster:
To show the full cluster configuration: