Setting Up A High-Availability Load Balancer (With Failover and Session Support) With Perlbal/Heartbeat On Debian Etch
|
Submitted by falko (Contact Author) (Forums) on Sun, 2009-01-11 19:32. :: Debian | High-Availability
Setting Up A High-Availability Load Balancer (With Failover and Session Support) With Perlbal/Heartbeat On Debian EtchVersion 1.0 This article explains how to set up a two-node load balancer in an active/passive configuration with Perlbal and heartbeat on Debian Etch. The load balancer sits between the user and two (or more) backend Apache web servers that hold the same content. Not only does the load balancer distribute the requests to the two backend Apache servers, it also checks the health of the backend servers. If one of them is down, all requests will automatically be redirected to the remaining backend server. In addition to that, the two load balancer nodes monitor each other using heartbeat, and if the master fails, the slave becomes the master, which means the users will not notice any disruption of the service. Perlbal is session-aware, which means you can use it with any web application that makes use of sessions (such as forums, shopping carts, etc.). I do not issue any guarantee that this will work for you!
1 Preliminary NoteIn this tutorial I will use the following hosts:
Here's a little diagram that shows our setup: shared IP=192.168.0.99 The shared (virtual) IP address is no problem as long as you're in your own LAN where you can assign IP addresses as you like. However, if you want to use this setup with public IP addresses, you need to find a hoster where you can rent two servers (the load balancer nodes) in the same subnet; you can then use a free IP address in this subnet for the virtual IP address. http1 and http2 are standard Debian Etch Apache setups with the document root /var/www (the configuration of this default vhost is stored in /etc/apache2/sites-available/default). If your document root differs, you might have to adjust this guide a bit.
2 Preparing The Backend Web ServersWe will configure Perlbal as a transparent proxy, i.e., it will pass on the original user's IP address in a field called X-Forwarded-For to the backend web servers. Of course, the backend web servers should log the original user's IP address in their access logs instead of the IP addresses of our load balancers. Therefore we must modify the LogFormat line in /etc/apache2/apache2.conf and replace %h with %{X-Forwarded-For}i: http1/http2: vi /etc/apache2/apache2.conf
Afterwards we restart Apache: /etc/init.d/apache2 restart We are finished already with the backend servers; the rest of the configuration happens on the two load balancer nodes.
3 Installing PerlbalPerlbal is not available as a package for Debian Etch, but we can install it through the Perl shell. Before we do this, we install a few prerequisites: lb1/lb2: apt-get install build-essential unzip lynx ncftp perl Afterwards we invoke the Perl shell as follows: perl -MCPAN -e shell On the Perl shell, we run the following three commands to install Perlbal: force install HTTP::Date install IO::AIO force install Perlbal Type q to leave the Perl shell.
4 Configuring The Load BalancersPerlbal expects its configuration in the file /etc/perlbal/perlbal.conf which we create as follows: lb1/lb2: mkdir /etc/perlbal
You won't find much documentation about the Perlbal configuration on the Internet, so the best way to learn about the Perlbal configuration options is to download the latest Perlbal release from http://code.google.com/p/perlbal/downloads/list (e.g. http://perlbal.googlecode.com/files/Perlbal-1.70.tar.gz). Uncompress it and then take a look at the files in the conf/ and doc/ subdirectories. You will find some configuration examples and a list of configuration options there.
|



Recent comments
1 day 17 hours ago
1 day 19 hours ago
2 days 7 hours ago
2 days 10 hours ago
2 days 14 hours ago
2 days 20 hours ago
3 days 6 hours ago
3 days 7 hours ago
3 days 16 hours ago
3 days 17 hours ago