CMAN and Pacemaker 2-node cluster on CentOS quickstart guide

Configuration has been tested on two CentOS 6.4 VMs.

First step, install the required packages:

yum install pacemaker cman ccs resource-agents pcs

Make sure we have our hosts in /etc/hosts on both nodes:

# backend
192.168.122.31  ccs01
192.168.122.32  ccs02

Set up a password for ricci on both nodes and make sure the service is started:

ccs01# passwd ricci
[...]
ccs01# service ricci restart
Shutting down ricci:                                       [  OK  ]
Starting ricci:                                            [  OK  ]

ccs02# passwd ricci
[...]
ccs02# service ricci restart
Shutting down ricci:                                       [  OK  ]
Starting ricci:                                            [  OK  ]

Then we must create a basic 2-nodes CMAN configuration, with Pacemaker in charge of fencing:

export NODE1=ccs01
export NODE2=ccs02

ccs -h $NODE1 --createcluster pacemaker1
ccs -h $NODE1 --addnode $NODE1
ccs -h $NODE1 --addnode $NODE2
ccs -h $NODE1 --setcman two_node=1 expected_votes=1
ccs -h $NODE1 --addfencedev pcmk agent=fence_pcmk
ccs -h $NODE1 --addmethod pcmk-redirect $NODE1
ccs -h $NODE1 --addmethod pcmk-redirect $NODE2
ccs -h $NODE1 --addfenceinst pcmk $NODE1 pcmk-redirect port=$NODE1
ccs -h $NODE1 --addfenceinst pcmk $NODE2 pcmk-redirect port=$NODE2

The configuration file, /etc/cluster/cluster.conf will be similar to this:

<?xml version="1.0"?>
<cluster config_version="6" name="pacemaker1">
    <clusternodes>
        <clusternode name="ccs01" nodeid="1">
            <fence>
                <method name="pcmk-redirect">
                    <device name="pcmk" port="ccs01"/>
                </method>
            </fence>
        </clusternode>
        <clusternode name="ccs02" nodeid="2">
            <fence>
                <method name="pcmk-redirect">
                    <device name="pcmk" port="ccs02"/>
                </method>
            </fence>
        </clusternode>
    </clusternodes>
    <cman expected_votes="1" two_node="1"/>
    <fencedevices>
        <fencedevice agent="fence_pcmk" name="pcmk"/>
    </fencedevices>
    <rm>
        <failoverdomains/>
        <resources/>
    </rm>
</cluster>

Make sure the cluster can talk to eachother:

ccs01# iptables -I INPUT 1 -p udp -s $NODE2 -m multiport --dports 5404,5405 -j ACCEPT
ccs01# iptables -I INPUT 1 -p tcp -s $NODE2 --dport 11111 -j ACCEPT
ccs01# service iptables save

ccs02# iptables -I INPUT 1 -p udp -s $NODE1 -m multiport --dports 5404,5405 -j ACCEPT
ccs02# iptables -I INPUT 1 -p tcp -s $NODE1 --dport 11111 -j ACCEPT
ccs01# service iptables save

Now we can copy the configuration on the second node (from $NODE1):

ccs01# ccs -h $NODE1 --sync

We must disable quorum wait for CMAN on both nodes, otherwise it will fail while starting:

sed -i "s/.*CMAN_QUORUM_TIMEOUT=.*/CMAN_QUORUM_TIMEOUT=0/g" /etc/sysconfig/cman

Now we can start both CMAN and Pacemaker on both nodes:

chkconfig pacemaker on
service pacemaker start

Check cluster status

pcs status

Last updated: Wed May  8 16:21:34 2013
Last change: Wed May  8 14:59:15 2013 via cibadmin on ccs01
Stack: cman
Current DC: ccs01 - partition with quorum
Version: 1.1.8-7.el6-394e906
2 Nodes configured, unknown expected votes
1 Resources configured.

Online: [ ccs01 ccs02 ]

We can disable fencing and STONITH:

pcs property set stonith-enabled=false
pcs property set no-quorum-policy=ignore

The cluster is ready, you can set up resources, groups and constraints with pcs.

For more informations, check ccs, cman_tool, pcs manuals and these links:

Advertisements

crmsh packages for CentOS 6.x

OpenSuSE kindly provides a repository for pacemaker, crmsh, pssh, etc.

Download the file from http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/network:ha-clustering:Stable.repo (or the link above) and put it in /etc/yum.repos.d/ then you’ll be able to install the packages directly:

yum -y install crmsh