How To Set Up A Loadbalanced High-Availability Apache Cluster - Page 3
5 Test The Load Balancers
Let's check if both load balancers work as expected:
loadb1/loadb2:
ip addr sh eth0
The active load balancer should list the virtual IP address (192.168.0.105):
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 |
The hot-standby should show this:
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000 |
loadb1/loadb2:
ldirectord ldirectord.cf status
Output on the active load balancer:
ldirectord for /etc/ha.d/ldirectord.cf is running with pid: 1455 |
Output on the hot-standby:
ldirectord is stopped for /etc/ha.d/ldirectord.cf |
loadb1/loadb2:
ipvsadm -L -n
Output on the active load balancer:
IP Virtual Server version 1.2.1 (size=4096) |
Output on the hot-standby:
IP Virtual Server version 1.2.1 (size=4096) |
loadb1/loadb2:
/etc/ha.d/resource.d/LVSSyncDaemonSwap master status
Output on the active load balancer:
master running |
Output on the hot-standby:
master stopped |
If your tests went fine, you can now go on and configure the two Apache nodes.
6 Configure The Two Apache Nodes
Finally we must configure our Apache cluster nodes webserver1.example.com and webserver2.example.com to accept requests on the virtual IP address 192.168.0.105.
webserver1/webserver2:
apt-get install iproute
Add the following to /etc/sysctl.conf:
webserver1/webserver2:
vi /etc/sysctl.conf
# Enable configuration of arp_ignore option |
Then run this:
webserver1/webserver2:
sysctl -p
Add this section for the virtual IP address to /etc/network/interfaces:
webserver1/webserver2:
vi /etc/network/interfaces
auto lo:0 |
Then run this:
webserver1/webserver2:
ifup lo:0
Finally we must create the file ldirector.html. This file is requested by the two load balancer nodes repeatedly so that they can see if the two Apache nodes are still running. I assume that the document root of the main apache web site on webserver1 and webserver2 is /var/www, therefore we create the file /var/www/ldirector.html:
webserver1/webserver2:
vi /var/www/ldirector.html
Test Page |