Article
With the increasing need for Five 9 continuity and the advent of virtualization, High Availability (HA) is seen more in the IT community as a necessity instead of a luxury.
SuSE is the choice distribution for HA-Linux (Heartbeat) binaries and is included with SLES 10.
This article describes the process for setting up Apache in a passive/active cluster using Heartbeat. It is assumed that there is a common disk device for the web server.
Cluster Configuration
The cluster consists of two SLES servers running Heartbeat and Apache in a cold standby mode.
Server1 is the active and has a DNS name of server1.mydomain.com
Server2 is the standby and has a DNS name of server2.mydomain.com
The cluster is named hacluster1.mydomain.com – Also the web server's URL.
Configure Heartbeat
There are three main configuration files for HA (Heartbeat):
/etc/ha.d/authkeys
/etc/ha.d/ha.cf
/etc/ha.d/haresources
Lets' take a look at each file what is required for our configuration.
/etc/ha.d/authkeys
There are three types of key methods for HA.
sha1 - SHA1 hash method
md5 - MD5 hash method
crc - CRC hash method - unsecured
The file looks like this:
auth 1 1 md5 AAAAB3NzaC1kc3MAAAEBALhTxBPKGEd1O2zYmDCVWtbaogOLZa+T
Auth 1 - determines with line number the key is located for use.
md5 is the method of encryption
/etc/ha.d/ha.cf
This is the main configuration file for HA and determines how HA will act.
logfacility local0 # Logging
node server1 server2 # List of cluster servers
keepalive 1 # Send one heartbeat each second
deadtime 10 # Declare node dead after 10 seconds
bcast eth0 # Broadcast heartbeats on the eth0 interface
ping 192.168.10.1 # Ping the default gateway to monitor ethernet
# connectivity
auto_failback no # Don't fail back to server1 automatically
respawn hacluster /usr/lib/heartbeat/ipfail # Failover on network failures
Refer to the man pages for more options.
/etc/ha.d/haresouces
This file describes how HA will manage resources. It is basically a collection of scripts to be executed by HA. We will only use Apache for our cluster. Here is the file:
server1 192.168.10.30 apache
We specify server1 (active) the IP address of the cluster and the service httpd (Apache).
HA also stops these resources in reverse order.
/sbin/chkconfig apache off
This will remove it from the runlevels and allow HA to start it.
Configure Apache
Create a mount point for Apache to be accessed on either server. We'll call it /ha
Create the subdirectories for your web site under /ha
md /ha/srv
md /ha/srv/www
md /ha/srv/www/htdocs
Change the permissions for shared directories
chmod 775 /ha/srv/www
chmod 775 /ha/srv/www/htdocs
On each server, create a localname.html in /var/www/local, in this file put
<html> <head></head> <body> Welcome to SLES HA Cluster! The page you are viewing is being served from node server1.mydomain.com from cluster hacluster1.mydomain.com </body> </html>
and make sure you change the name of the server to the relevant server.
Create a symbolic link to the shared directories on both servers.
ln -s /ha/srv/www/htdocs /var/www/local
Create a symbolic link to the localname.html on both servers.
ln -s /var/www/local/localname.html /ha/srv/www/htdocs/index.html
Testing
We can test the setup and fail over by manually failing the primary. First, start the cluster. On the primary server and then on the backup server:
/etc/rc.d/init.d/heartbeat start
If there are any problems, or if you are just curious, look in /var/log/messages and /var/log/ha-log.
Open a browser and enter the URL of your cluster. hacluster1.mydomain.com/index.html
Note the node name in red for server1.mydomain.com
Ok. Let's fail the node and see what happens. Don't close your browser!
One server1, stop Heartbeat:
/etc/rc.d/init.d/heartbeat stop
Now, Refresh your browser page.
Look at the server name! We failed over successfully... Sweet.
Now, more testing. The fail back. Restart the Heartbeat service on the primary and it should stop the service automatically on the backup, server2.
Refresh your browser page one more time.
Server1 is now back in control.
The fail over from the primary to the backup should occur in less than a minute depending on you Apache configurations.
Conclusion
This is just a small example of what resources can be maintained in a High Availability setup using Heartbeat. The main component for this to work in ensuring a homogeneous environment for both nodes.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
Good article
Submitted by DamianMyerscough on 23 February 2008 - 3:19am.
This article is really good :) I think I will try this.
- Be the first to comment! To leave a comment you need to Login or Register
Great article, just one comment.
Submitted by geistc on 3 March 2008 - 2:24pm.
In your example /etc/ha.d/ha.cf file, you have 'auto_failback' set to 'no'. My understanding is this will prevent Heartbeat from failing back resources to the primary node automatically. In your 'Testing' section, you say that starting the Heartbeat service on the primary server will cause the fail back of resources. In order for this to happen, you would have to have the 'auto_failback' option set to 'yes'. Thanks for the the great article.
- Be the first to comment! To leave a comment you need to Login or Register
I need a little direction
Submitted by Q_Element on 28 November 2010 - 9:11pm.
I am running Heartbeat on SLES10 and OpenSuse 11.3. I don't have the directory /var/www/local to create the localname.html file. Do you recommend another location? I am running Apache2.
- Be the first to comment! To leave a comment you need to Login or Register
SLES defaults to
Submitted by mfaris01 on 8 December 2010 - 9:03am.
SLES defaults to /srv/www/htdocs but you can create your DocumentRoot anywhere as long as you specify it in the /etc/apache2/default-server.conf or what ever you call your installation's config file.
Like the install for SLES, I also recommend not making changes to httpd.conf as Novell has implied that the majority of the Apache config files should stay static and recommends creating additional custom ".conf" files in vhosts.d/ or another specified location. If you read the /etc/apache2/httpd.conf file, it has the layout of the install and all the details.
I hope this helps you.
Mike...
- Be the first to comment! To leave a comment you need to Login or Register






4