
158
|
Chapter 7: Load-Balanced Clusters
3. Add these lines to /etc/sysctl.conf:
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
4. Get the changes into the kernel:
# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
5. Assuming that your realserver is a Debian system, edit the /etc/network/interfaces
file, associating the VIP (70.253.15.42) with the loopback alias
lo:0:
auto lo:0
iface lo:0 inet static
address 70.253.15.42
netmask 255.255.255.255
pre-up sysctl -p > /dev/null
6. Enable the loopback alias:
# ifup lo:0
7. Create the file /var/www/ldirector.html with the contents:
I'm alive!
8. On web1:
# echo "I'm web1" > /var/www/which.html
9. On web2:
# echo "I'm web2" > /var/www/which.html
10. Start Apache, or restart it if it’s already running:
# /etc/init.d/apache2 restart
The Apache access logs should not yet show any activity, because lb is not talking to
them yet.
Configuring the Load Balancer
On lb, create the load balancer configuration file, /etc/ha.d/ldirectord.cf:
checktimeout=10
checkinterval=2
autoreload=no
logfile="local0"
quiescent=no
virtual=70.253.158.42:80
real=70.253.158.41:80 gate
real=70.253.158.45:80 gate
service=http
request="director.html"
receive="I'm alive!"