Our goal is to setup a pair of RackSpace Cloud Servers in a redundant cluster using a shared IP address. We’ll use the “heartbeat” package from Linux-HA (http://www.linux-ha.org) for the cluster messaging layer and “pacemaker” package from ClusterLabs (http://clusterlabs.org) for the cluster resource manager.
Before starting this procedure you’ll need to:
a. Create the two cloud servers. These instructions are specific to CentOS for the operating system.
b. Open a ticket with RackSpace Cloud support and request a public IP address to be shared between the servers.
You can use the instructions for other situations but you’ll need to make the appropriate adjustments.
1. Setup hosts file entries. On each server, edit /etc/hosts and add entries for each servers public and private interfaces. You’ll also find it convenient to setup ssh keys between the servers for easy access.
2. Now use yum to install some prerequisite packages:
yum install net-snmp perl-libwww-perl libesmtp perl-Net-SSLeay perl-MailTools ipvsadm OpenIPMI libibverbs librdmacm openhpi PyXML
Repeat this step on the second server.
Note: Several of these packages are not available on the standard RHEL yum channels. If you’re working on something other then a RackSpace Cloud server then you might need to install the EPEL channel. Just go to:
Then download and install the appropriate package to add EPEL.
3. The version of heartbeat available in the standard yum repositories is outdated. So we’ll install a more recent version of heartbeat, pacemaker and supporting components from:
Start by creating a working folder:
Then use wget to download the latest version of each of the following package:
Finally install the packages:
rpm -i *.rpm
Repeat this step on the second server.
5. Next step is to configure heartbeat.
a. Setup keys for authentication between the instances.
Edit /etc/ha.d/authkeys and add:
1 sha1 [PASSWORD]
Replace [PASSWORD] with a long random string.
b. Set permissions on the authkeys file:
chmod 600 /etc/ha.d/authkeys
c. Next edit /etc/ha.d/ha.cf and add the following:
ucast eth1 [INTERNAL IP OF HOST2]
Set [HOST1] and [HOST2] to the hostnames of the servers.
Set [INTERNAL IP OF HOST2] to the private IP address of the second server.
Repeat these steps on the second server. When you create the ha.cf file for the second server, you’ll use the internal IP of the first server in the ucast line.
d. Setup logd for automatic startup:
/sbin/chkconfig --level 345 logd on
Now repeat this procedure on the second server but make sure you set the internal IP of the first server in the ha.cf file.
6. Finally start the heartbeat and logd service on both servers:
/sbin/service logd start
/sbin/service heartbeat start
7. The next step is to configure pacemaker.
Run the pacemaker configuration tool. It is called “crm”. You’ll use it to configure “resources” which in this case is a shared IP.
If you get an error like “cibadmin not available, check your installation” when trying to run crm, then make sure that the “which” package is installed and that /usr/sbin is in your path.
Now enter the following into the pacemaker shell:
primitive shared_ip_one IPaddr params ip=[SHARED_IP] cidr_netmask="255.255.255.0" nic="eth0"
location share_ip_one_master shared_ip_one 100: [HOST1]
monitor shared_ip_one 20s:10s
Where [SHARED_IP] is the IP address to be shared between the servers and [HOST1] is the hostname of the primary server.
Once this is done then you should be able to monitor the status of the cluster from either node using the crm_mon command. You’ll get output like this:
Last updated: Sun Feb 6 14:00:42 2011
Current DC: node01 (cad6f81e-f772-4add-b5e2-c9a78b4ae430) - partition with quorum
2 Nodes configured, 2 expected votes
1 Resources configured.
Online: [ node02 node01 ]
shared_ip_one (ocf::heartbeat:IPaddr): Started node01
8. Next step is to test failover on the servers.
a. Run crm_mon on the second server.
b. Reboot the first server:
c. Monitor the second server and notice that when the first goes offline, the “shared_one_ip” is switched to the second server. After the first server finishes rebooting then you should see it come back online and “shared_one_ip” return to it’s original location on the first server.
d. Repeat this test but reboot the second server and monitor the first.
And that completes the setup process. You now have an HA Linux cluster on the cloud!