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.
Prerequisites
yum groupinstall "Development Tools" yum install nss-devel libibverbs-devel librdmacm-devel
Download the source
cd /usr/local/src wget ftp://ftp:downloads@ftp.corosync.org/downloads/corosync-1.4.2/corosync-1.4.2.tar.gz tar -xzvf corosync-*.tar.gz
Build the RPMs
./autogen.sh && ./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:
corosync-1.4.2-1.amzn1.i686.rpm corosync-debuginfo-1.4.2-1.amzn1.i686.rpm corosynclib-1.4.2-1.amzn1.i686.rpm corosynclib-devel-1.4.2-1.amzn1.i686.rpm
Install the RPMs
yum --nogpgcheck install corosync-1.4.2-1.amzn1.i686.rpm corosynclib-1.4.2-1.amzn1.i686.rpm
Configure
Run the following to create /etc/corosync/authkey
corosync-keygen
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 { memberaddr: 10.xxx.xxx.xxa } member { memberaddr: 10.xxx.xxx.xxb } ringnumber: 0 bindnetaddr: 10.xxx.xxx.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