Installing Corosync on EC2

This post was published 2 years, 4 months ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

The notes for this have been sitting on my computer for almost 6 months, but a comment from today spurred me onto editing, updating, and posting them.

Corosync is a messaging layer used for high-availability. It serves essentially the same purpose as Heartbeat, but appears to be the project that will supersede it. Currently, it supports all the features of Heartbeat as well as adding a few more, and is under active development.

Some points, below, are specific to the installation on Amazon’s Linux AMI, but most should work on other RHEL/CentOS derived operating systems without modification.

Corosync is available from the amzn repository, however, at the current time, the version offered is v1.2.3. Additionally, the ClusterLabs repository is a bit outdated – with their latest version being v1.2.7.

Amazon’s network infrastructure only permits certain packet types, and currently, broadcast and multicast are not permitted. In version 1.3 (Nov. 2010), Corosync added support for UDPU (unicast) packets. As such, only versions above 1.3 are effective on EC2.

This isn’t really meant as a guide for using Corosync, but more to point out a few potential stumbling blocks in getting it setup on EC2.


yum groupinstall "Development Tools"
yum install nss-devel libibverbs-devel librdmacm-devel


Download the source

cd /usr/local/src
tar -xzvf corosync-*.tar.gz


Build the RPMs

./ && ./configure
make rpm

This creates an i686 (or x86_64) folder within the source folder (i.e. /usr/local/src/corosync-1.4.2/i686), containing the following:



Install the RPMs

yum --nogpgcheck install corosync-1.4.2-1.amzn1.i686.rpm corosynclib-1.4.2-1.amzn1.i686.rpm



Run the following to create /etc/corosync/authkey


Sample configuration files are located in /etc/corosync. Copy the example config:

cp /etc/corosync/corosync.conf.example.udpu /etc/corosync/corosync.conf

The defaults should be good to get you going. Just remove the unneeded member blocks, and fill in the correct IP addresses.

The totem block may resemble the following:

totem {
        version: 2
        secauth: off
        interface {
                member {
                member {
                ringnumber: 0
                mcastport: 5405
		ttl: 1
        transport: udpu
		token: 10000

Note the bindnetaddr is the network IP (as is one of the memberaddr, with the subnet mask applied), which you can get with ip and ipcalc:

ipcalc -n `ip addr show eth0 | grep 'inet ' |awk '{print $2}'` | awk -F= '{print $2}'

Of course, you can get your memberaddr address with the following if you need to script it:

/sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'

Copy the authkey and corosync.conf files to each node in the cluster.

Once everything is setup, start corosync with

service corosync start

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>