How to setup linux loadbalancer for windows real server using ldirectord-lvs-heartbeat
Required operating system and packages
First of all install centos 5.2 with minimal packages and no gui required.
Packages required for setting up linux server as loadbalancer are as below.
heartbeat-2.1.4-4.1.i386.rpm
heartbeat-devel-2.1.4-4.1.i386.rpm
heartbeat-ldirectord-2.1.4-4.1.i386.rpm
heartbeat-pils-2.1.4-4.1.i386.rpm
heartbeat-stonith-2.1.4-4.1.i386.rpm
libnet-1.1.2.1-2.1.i386.rpm
perl-MailTools-1.76-1.el5.rf.noarch.rpm
There might me some more package dependencies but it can be resolved by installing those packages from cd.
ldirector.conf -- This is main configuration file for loadbalancer. Default location for this file is
/etc/ha.d/
- checktimeout=3
checkinterval=5
autoreload=yes
logfile="/var/log/ldirectord.log"
quiescent=yes
#fork=yes
virtual=10.10.10.214:80
real=10.10.10.225:80 masq
real=10.10.10.226:80 masq
service=http
request="index.html"
receive="Still alive"
scheduler=rr
protocol=tcp
checktype=connect
# persistent = 10
netmask = 255.255.255.255
Virtual IP on loadbalancer.
We need to configure one of the interface with virtual ip on loadbalancer. In this example we have setup eth0:0 with 10.10.10.214 which is a loadbalanced virtual ip for http traffic towards both real servers 10.10.10.225 & 10.10.10.226.
Important Notes:
Steps to configure heartbeat for auto_failover
Default directory which holds all configuration files is /etc/ha.d.
important configuration files for heartbeat configuration is ha.cf, authkeys and haresources.
authkeys : This file holds authentication key and it must be same on both servers. You can generate it on 1 server and then copy over to another server.
To generate authkeys file use following command as root user.
#( echo -ne "auth 1\n1 md5 "; dd if=/dev/urandom bs=512 count=1| openssl md5) > /etc/ha.d/authkeys
ha.cf : It is an important configuration for heartbeat. It holds information about Interface in use for heartbeat, port number, real servers etc ..
- crm on
udpport 696
bcast eth0
node lb01 lb02
auto_failback on
haresources :
It is an important configuration for heartbeat. It holds information about fail over resources. e.g floating IP .
lb01 IPaddr::10.10.10.214/25/eth0
Important Note:
To add another virtual IP (Load Balanced IP) we need to edit 2 configuration files.
IPTables rules linux server. These rules are not mandatory. just for reference only.
iptables -t mangle -A PREROUTING -p tcp -d 10.10.10.214 --dport 80 -j MARK --set-mark 80
iptables -t nat -A POSTROUTING -p tcp -s 10.10.10.225 --sport 80 -j MASQUERADE
iptables -t nat -A POSTROUTING -p tcp -s 10.10.10.226 --sport 80 -j MASQUERADE
Important Note.
On real server default gateway must be ip address of linux load balancer.
- Login to post comments