How To Set Up A Loadbalanced High-Availability Apache Cluster Based On Ubuntu 8.04 LTS - Page 4

Want to support HowtoForge? Become a subscriber!
 
Submitted by msghaleb (Contact Author) (Forums) on Tue, 2008-06-03 10:14. ::

12 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,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:4e:67:1a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.101/24 brd 192.168.0.255 scope global eth0
    inet 192.168.0.105/24 brd 192.168.0.255 scope global secondary eth0

The hot-standby should show this:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:34:d7:7e brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.102/24 brd 192.168.0.255 scope global eth0

loadb1/loadb2:

ldirectord ldirectord.cf status

Output on the active load balancer:

ldirectord for /etc/ha.d/ldirectord.cf is running with pid: 5321

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)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.0.105:80 rr
  -> 192.168.0.103:80               Route   1      0          0         
  -> 192.168.0.104:80               Route   0      0          0         

Output on the hot-standby:

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

loadb1/loadb2:

/etc/ha.d/resource.d/LVSSyncDaemonSwap master status

Output on the active load balancer:

master running
(ipvs_syncmaster pid: 5470)

Output on the hot-standby:

master stopped

If your tests went fine, you can now go on and configure the two Apache nodes.

 

13 Configure The Two Apache Nodes

Finally we must configure our Apache cluster nodes webserver1.tm.local and webserver2.tm.local 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
net.ipv4.conf.all.arp_ignore = 1

# When an arp request is received on eth0, only respond if that address is
# configured on eth0. In particular, do not respond if the address is
# configured on lo
net.ipv4.conf.eth0.arp_ignore = 1

# Ditto for eth1, add for all ARPing interfaces
#net.ipv4.conf.eth1.arp_ignore = 1


# Enable configuration of arp_announce option
net.ipv4.conf.all.arp_announce = 2

# When making an ARP request sent through eth0 Always use an address that
# is configured on eth0 as the source address of the ARP request. If this
# is not set, and packets are being sent out eth0 for an address that is on
# lo, and an arp request is required, then the address on lo will be used.
# As the source IP address of arp requests is entered into the ARP cache on
# the destination, it has the effect of announcing this address. This is
# not desirable in this case as adresses on lo on the real-servers should
# be announced only by the linux-director.
net.ipv4.conf.eth0.arp_announce = 2

# Ditto for eth1, add for all ARPing interfaces
#net.ipv4.conf.eth1.arp_announce = 2

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
iface lo:0 inet static
 address 192.168.0.105
 netmask 255.255.255.255
 pre-up sysctl -p > /dev/null

Then run this:

Please Note after the following step you will probably get this error: SIOCSIFFLAGS: Cannot assign requested address

That is a normal bug and you can ignore it.

webserver1/webserver2:

ifup lo:0

If you change the IP at a later stage its recommended to do ifup lo:0 then ifdown lo:0 then again 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

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.