Load-Balanced Clusters - Load-Balancing Software (Page 2 of 4 )
The simplest form of load balancing is round-robin DNS, where multiple A records are defined for the same name; this results in the servers taking turns responding to any incoming requests. This doesn’t work well if a server fails, though, and it doesn’t take into account any special needs the service may have. With HTTP, for example, we might need to maintain session data such as authentication or cookies and ensure that the same client always connects to the same server. To meet these needs, we’ll get a little more sophisticated and use two tools:
- IP Virtual Server (IPVS), a transport-level (TCP) load-balancer module that is now a standard Linux component
- ldirectord, a utility that monitors the health of the load-balanced physical servers
The installation instructions are based on the Debian 3.1 (Sarge) Linux distribution.
IPVS on the Load Balancer Since IPVS is already in the Linux kernel, we don’t need to install any software, but we do need to configure it.
On lb, add these lines to /etc/modules.
ip_vs_dh
ip_vs_ftp
ip_vs
ip_vs_lblc
ip_vs_lblcr
ip_vs_lc
ip_vs_nq
ip_vs_rr
ip_vs_sed
ip_vs_sh
ip_vs_wlc
ip_vs_wrr
Then load the modules into the kernel:
# modprobe ip_vs_dh
# modprobe ip_vs_ftp
# modprobe ip_vs
# modprobe ip_vs_lblc
# modprobe ip_vs_lblcr
# modprobe ip_vs_lc
# modprobe ip_vs_nq
# modprobe ip_vs_rr
# modprobe ip_vs_sed
# modprobe ip_vs_sh
# modprobe ip_vs_wlc
# modprobe ip_vs_wrr
To enable packet forwarding in the Linux kernel on lb, edit the file /etc/sysctl.conf and add this line:
net.ipv4.ip_forward = 1
Then load this setting into the kernel:
# sysctl -p
net.ipv4.ip_forward =1
Next: ldirectord >>
More Administration Articles
More By O'Reilly Media
|
This article is excerpted from chapter seven of Linux System Administration, written by Tom Adelstein and Bill Lubanovic (O'Reilly, 2007; ISBN: 0596009526). Check it out today at your favorite bookstore. Buy this book now.
|
|