How To: Install CoroSync + Pacemaker on CentOS 5.6
In this post we will be setting up CoroSync and Pacemaker on CentOS to create an easily managed cluster for different resources. There are many options available to create a cluster, Hearbeat being one of the oldest, but the development team I am a part of have settled on this combination as it is the most likely to receive security and feature updates as clustering systems change. It also takes advantage of some of the items that Heartbeat does a good job of managing currently while adding far easier management and scalability that wasn’t possible with only Heartbeat 2.
Install EPEL repository for packages that don’t exist in vanilla Redhat/CentOS.
1 2 |
|
Add Cluster Labs repo for Pacemaker
1
|
|
Install Pacemaker 1.0+ and CoroSync 1.2+
1
|
|
Configure CoroSync
Create /etc/corosync/authkey for authentication within cluster communication. This file MUST be copied to each node in the cluster. If a message “Invalid digest” appears from the corosync executive, the keys are not consistent between processors.
1 2 3 4 5 6 |
|
Open the example CoroSync configuration:
- Change the bindnetaddr
to the IP for each server.
- Change mcastaddr
and mcastport
to be unique for each cluster.
- Change secauth
to on
if encryption is desired or on an insecure network.
The defaults beyond those changes are usually acceptable.
1 2 |
|
Add in section to tell CoroSync to run as root for resource management. If not clustering resources, leave this out!
1 2 3 4 5 |
|
Add in values to start PaceMaker
1 2 3 4 5 6 7 |
|
Once familiarized with the simple structure of it, read the man page. It will explain the up-to-date options and what everything means.
1
|
|
Copy the configuration to each node in the cluster
1 2 3 |
|
One last thing, as of this writing the RPM packages don’t create the necessary folders for the default log file. Create them now on all nodes.
1 2 3 4 |
|
Now, start up CoroSync on the first node.
1
|
|
Check to see CoroSync is running as expected
1 2 3 |
|
Since the dark ages of Pacemaker, many changes and advances have been implemented. Take a look at Cluster from Scratch and page #27 and on. It explains everything very well.
1
|
|
With one node active and functional it is safe to start the second node.
1 2 |
|
Configure an Active/Passive Cluster [Cluster From Scratch, page 28 and on]
Before we continue we should check if the configuration is correct
1
|
|
As you can see, the tool has found a few errors.
This is due to Pacemaker’s use of STONITH. We will configure this later but will disable it for now:
1 2 |
|
The configuration is now valid.
Adding a resource: ClusterIP [Cluster From Scratch, page 32]
The first thing we need to do for a cluster is add a resource like an IP address so we can always contact and communicate with the cluster without regardless of where the cluster services are running. This must be a NEW address not associated with ANY node.
1 2 3 |
|
Verify that the IP address has been added to the configuration.
1 2 |
|
We also want to disable autofailback as our machines are generally identical so there is no reason to failback to a specific node.
1 2 |
|
Since we normally use a 2 node cluster which is mathematically unable to attain quorum, we need to tell Pacemaker to ignore it.
1 2 |
|
Now, if a node goes down the resources will be transitioned appropriately instead of the cluster failing.
Adding a resource: Apache2 [Cluster From Scratch, page 38]
Install the Apache 2 webserver and wget
for the cluster to check the status of apache.
1
|
|
Let’s create a default index page for Apache to show what server is currently processing requests.
1 2 3 4 5 6 7 8 |
|
Update Apache configuration to allow /server-status which is what Pacemaker uses to check if Apache is alive.
- Uncomment ExtendedStatus on
- Uncomment </Location /server-status>
- Update All from .example.com
to Allow from 172.25
1
|
|
Update the configuration so Apache is clustered
1 2 3 4 5 6 |
|
Configure Pacemaker to keep multiple resources together. In this case, Apache can only run on the system with the ClusterIP.
1 2 3 |
|
Configure Pacemaker to start the ClusterIP before WebSite and stop it after WebSite is stopped.
1 2 |
|
We’re done! You now have a fully clustered dual or multi node cluster. Some helpful commands are:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
References:
ClusterLabs Cluster From Scratch
1 2 |
|