LVS
This text is a DRAFT, do not use it, base any work on it or anything else.
Needed:
Linux kernel 2.6.10+ (for IPVS patch) heartbeat ipvsadm keepalived ldirectord
We can use IP, 207.142.131.213 which is free. All clients will be sent on this IP which is assigned to a director box on a virtual interface (eth0:1). In case of failure (detected by heartbeat, the ip is switched on the other director box). That IP is know as the virtual ip (VIP).
So bascily we handle everything on our side, no more dns load balancing.
Contents |
Hearbeat
Configuration file (/etc/heartbeat/ha.cf) sample in ha.cf.
We will use it on the two ldirector box, if the main one fail, the other one will detect the failure and takeover the IP address automaticly. It is probably much better than the actual way of doing things: manually reassigning ip between squids.
Squid failure is handled directly by ldirectord.
ldirectord
Configuration file (/etc/ha.d/ldirectord.cf) sample in ldirectord.cf.
ldirectord is a daemon to that will set up LVS for you, much better to edit the configuration file than editing the table with ipvsadm :o)
ipvsadm
ipvsadm is the tool to configure and check the virtual table. The table itself is set up by ldirectord so you probably do not want to mess things.
IP assignment
VIP 207.142.131.213 LVS 192.168.0.1 LVS_back 192.168.0.2
# squids will 10.0.0.243 browne 10.0.0.229 srv10 10.0.0.194 srv9 10.0.0.195 srv8 10.0.0.196 srv7 10.0.0.197 srv6 10.0.0.198
Network configuration
ldirector server(s) and squids need to be in the SAME broadcast network. They all share the VIP so the squids should not honour arp requests directed to the virtual VIP.
The only server that should answer on the VIP is the ldirector box, so you have to stop squids from answering arp requests that does not match their real ip. This is done by editing /etc/sysctl.conf:
net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2
Now add VIP on the squid loopback:
/sbin/ip addr add 207.142.131.213/32 dev lo brd + scope host
Eventually apply /etc/sysctl changes:
echo '2' > /proc/sys/net/ipv4/conf/lo/arp_announce echo '1' > /proc/sys/net/ipv4/conf/lo/arp_ignore
scope host directive makes the address only valid on this host.
The squid daemon is then set to listen on VIP (wich is on lo:0).