Quantcast
Viewing all articles
Browse latest Browse all 2

Creating a two-node CentOS 6 cluster with floating IP using Pacemaker and Corosync

Up until recently I was using Heartbeat to create two-node Linux clusters with floating IPs, but now Heartbeat is no longer being developed I needed to figure out how to use Corosync and Pacemaker for this instead. Unfortunately this is quite a lot more in-depth than the simple configuration that was required for Heartbeat. Anyway, based on my recent experiences, here’s a quick guide for if you find yourself in a similar situation. This works for me on CentOS 6. Whether it works on CentOS 5 and/or other Linux distributions I don’t currently know as I haven’t tried it.

Installation and initial configuration

Install the required packages and prepare the configuration file:

yum install pacemaker
cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf

Change bindnetaddr to your network address (e.g. 192.168.1.0) in /etc/corosync/corosync.conf.

Create /etc/corosync/service.d/pcmk and put the Pacemaker startup config into it:

service {
        name: pacemaker
        ver: 1 
}

Start corosync and pacemaker:

service corosync start
service pacemaker start

Make sure they start on boot:

chkconfig corosync on
chkconfig pacemaker on

Repeat all of the above on the second node.

Then disable STONITH on the primary node:

crm configure property stonith-enabled=false

Add a floating IP on the primary node (change IP address and netmask as needed):

crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 params ip=192.168.1.110
  cidr_netmask=24 op monitor interval=30s

Disable quorum on the primary node (necessary for running only two nodes):

crm configure property no-quorum-policy=ignore

Prevent resources from moving back after a node recovers:

crm configure rsc_defaults resource-stickiness=100

Use the commands in the Administration section below to ensure that the floating IP is on the correct machine – if this is not the case then temporarily shut down Pacemaker on whichever machine has the floating IP so that it moves across to the desired node:

service pacemaker stop

Administration

Display the current configuration:

crm configure show

Status monitor:

crm status

Show which node has the cluster IP:

crm resource status ClusterIP

Reset the config to default:

cibadmin -E --force

Verify that there are no problems with the current config:

crm_verify -L

Viewing all articles
Browse latest Browse all 2

Trending Articles