150 likes | 314 Views
Load balanced High-Availability Apache Cluster. Advantage Of Load Balancing. Load balancers takes care of the load on a web server nodes and tried to direct request to the node with least amount on load
E N D
Advantage Of Load Balancing Load balancers takes care of the load on a web server nodes and tried to direct request to the node with least amount on load Many web applications make use of sessions, and if you are in a session on Apache node 1, you would lose that session if suddenly node 2 served your requests. If an Apache nodes goes down, the load balancer realizes that and directs all incoming requests to the remaining node.
Requirements For Setup • Four nodes( two apache nodes and two load balancer nodes) • Five IP Addresses • One for each node • One for virtual IP address that will be shared by the load balancer.
IP Address Schema Apache node 1: webserver1.radford.edu(webserver1) - IP address: 192.168.0.101; Apache document root: /var/www Apache node 2: webserver2.radford.edu(webserver2) - IP address: 192.168.0.102; Apache document root: /var/www Load Balancer node 1: loadb1.radford.edu (loadb1) - IP address: 192.168.0.103 Load Balancer node 2: loadb2.radford.edu (loadb2) - IP address: 192.168.0.104 Virtual IP Address: 192.168.0.105 (used for incoming requests)
Enable IPVS On The Load Balancers • Loadb1 / Loadb2 • echo ip_vs_dh >> /etc/modulesecho ip_vs_ftp >> /etc/modulesecho ip_vs >> /etc/modulesecho ip_vs_lblc >> /etc/modulesecho ip_vs_lblcr >> /etc/modulesecho ip_vs_lc >> /etc/modulesecho ip_vs_nq >> /etc/modulesecho ip_vs_rr >> /etc/modulesecho ip_vs_sed >> /etc/modulesecho ip_vs_sh >> /etc/modulesecho ip_vs_wlc >> /etc/modulesecho ip_vs_wrr >> /etc/modules
modprobeip_vs_dhmodprobeip_vs_ftpmodprobeip_vsmodprobeip_vs_lblcmodprobeip_vs_lblcrmodprobeip_vs_lcmodprobeip_vs_nqmodprobeip_vs_rrmodprobeip_vs_sedmodprobeip_vs_shmodprobeip_vs_wlcmodprobeip_vs_wrrmodprobeip_vs_dhmodprobeip_vs_ftpmodprobeip_vsmodprobeip_vs_lblcmodprobeip_vs_lblcrmodprobeip_vs_lcmodprobeip_vs_nqmodprobeip_vs_rrmodprobeip_vs_sedmodprobeip_vs_shmodprobeip_vs_wlcmodprobeip_vs_wrr
Install Ultra Monkey On The Load Balancers • vi /etc/apt/sources.list • Lines must be added • deb http://www.ultramonkey.org/download/3/ sarge main • deb-src http://www.ultramonkey.org/download/3 sarge main • apt-get update • apt-get install ultramonkey
UltraMonkey Setup Do you want to automatically load IPVS rules on boot?<-- No Select a daemon method.<-- none
Enable Packet Forwarding On Load Balancers • vi /etc/sysctl.conf • Add the following lines to sysct1.conf file • Net.ipv4.ip_forward = 1 • sysctl -p
Configure heartbeat And Idirectord • vi /etc/ha.d/ha.cf • Add to config file • logfacility local0 • bcast eth0 # Linux • mcast eth0 225.0.0.1 694 1 0 • auto_failback off • node loadb1 • node loadb2 • respawnhacluster /usr/lib/heartbeat/ipfail • apiauthipfailgid=haclientuid=hacluster
uname -n • vi /etc/ha.d/haresources • loadb1 \ • ldirectord::ldirectord.cf \ • LVSSyncDaemonSwap::master \ • IPaddr2::192.168.0.105/24/eth0/192.168.0.255
uname –n • vi /etc/ha.d/authkeys • auth 3 • 3 md5 somerandomstring • chmod 600 /etc/ha.d/authkeys
vi /etc/ha.d/ldirectord.cf • checktimeout=10checkinterval=2autoreload=nologfile="local0"quiescent=yesvirtual=192.168.0.105:80real=192.168.0.101:80 gatereal=192.168.0.102:80 gatefallback=127.0.0.1:80 gateservice=httprequest="ldirector.html"receive="Test Page"scheduler=rrprotocol=tcpchecktype=negotiate
update-rc.d heartbeat start 75 2 3 4 5 . stop 05 0 1 6 . update-rc.d -f ldirectord remove /etc/init.d/ldirectord stop /etc/init.d/heartbeat start