Article by Aashish
keepalived provides a strong and robust health checking for LVS clusters. It nginx implements a framework of health checking on multiple layers for server failover, and VRRPv2 stack to handle director failover. How do I install and configure Keepalived for reverse proxy server such as nginx or lighttpd?
If your are using a LVS director to loadbalance a server pool in a production environment, you may want to have a robust solution for healthcheck & failover. This will also work with reverse proxy server such as nginx.
lb0 – Linux box directly connected to the Internet via eth1. This is master load balancer.
lb1 – Linux box directly connected to the Internet via eth1. This is backup load balancer. This will become active if master networking failed.
202.54.1.1 – This ip moves between lb0 and lb1 server. It is called virtual IP address and it is managed by keepalived.
eth0 is connected to LAN and all other backend software such as Apache, MySQL and so on.
You need to install the following softwares on both lb0 and lb1:
keepalived for IP failover.
iptables to filter traffic
nginx or lighttpd revers proxy server.
DNS settings should be as follows:
hackadmin.in – Our sample domain name.
lb0.hackadmin.in – 202.54.1.11 (real ip assigned to eth1)
lb1.hackadmin.in – 202.54.1.12 (real ip assigned to eth1)
www.hackadmin.com – 202.54.1.1 (VIP for web server) do not assign this IP to any interface.
Install Keepalived
Visit keepalived.org to grab latest source code. You can use the wget command to download the same (you need to install keepalived on both lb0 and lb1):
# cd /opt
# wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz
# tar -zxvf keepalived-1.1.19.tar.gz
# cd keepalived-1.1.19
Install Kernel Headers
You need to install the following packages:
Kernel-headers – includes the C header files that specify the interface between the Linux kernel and userspace libraries and programs. The header files define structures and constants that are needed for building most standard programs and are also needed for rebuilding the glibc package.
kernel-devel – this package provides kernel headers and makefiles sufficient to build modules against the kernel package.
Make sure kernel-headers and kernel-devel packages are installed. If not type the following install the same:
Compile keepalived
Type the following command:
# ./configure –with-kernel-dir=/lib/
Sample outputs:
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
…
…..
..
config.status: creating keepalived/check/Makefile
config.status: creating keepalived/libipvs-2.6/Makefile
Keepalived configuration
————————
Keepalived version : 1.1.19
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
Use VRRP Framework : Yes
Use Debug flags : No
Compile and install the same:
# make && make install
Create Required Softlinks
Type the following commands to create service and run it at RHEL / CentOS run level #3 :
# cd /etc/sysconfig
# ln -s /usr/local/etc/sysconfig/keepalived .
# cd /etc/rc3.d/
# ln -s /usr/local/etc/rc.d/init.d/keepalived S100keepalived
# cd /etc/init.d/
# ln -s /usr/local/etc/rc.d/init.d/keepalived .
Configuration
Your main configuration directory is located at /usr/local/etc/keepalived and configuration file name is keepalived.conf. First, make backup of existing configuration:
# cd /usr/local/etc/keepalived
# cp keepalived.conf keepalived.conf.bak
Edit keepalived.conf as follows on lb0:
vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 101
authentication {
auth_type PASS
auth_pass Add-Your-Password-Here
}
virtual_ipaddress {
202.54.1.1/29 dev eth1
}
}
Edit keepalived.conf as follows on lb1 (note priority set to 100 i.e. backup load balancer):
vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 100
authentication {
auth_type PASS
auth_pass Add-Your-Password-Here
}
virtual_ipaddress {
202.54.1.1/29 dev eth1
}
}
Save and close the file. Finally start keepalived on both lb0 and lb1 as follows:
# /etc/init.d/keepalived start
Verify: Keepalived Working Or Not
/var/log/messages will keep track of VIP:
# tail -f /var/log/messages
Sample outputs:
Feb 21 04:06:15 lb0 Keepalived_vrrp: Netlink reflector reports IP 202.54.1.1 added
Feb 21 04:06:20 lb0 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 202.54.1.1
Verify that VIP assigned to eth1:
# ip addr show eth1
Sample outputs:
3: eth1: mtu 1500 qdisc pfifo_fast qlen 10000
link/ether 00:30:48:30:30:a3 brd ff:ff:ff:ff:ff:ff
inet 202.54.1.11/29 brd 202.54.1.254 scope global eth1
inet 202.54.1.1/29 scope global secondary eth1
ping failover test
Open UNIX / Linux / OS X desktop terminal and type the following command to ping to VIP:
# ping 202.54.1.1
Login to lb0 and halt the server or take down networking:
# halt
Within seconds VIP should move from lb0 to lb1 and you should not see any drops in ping. On lb1 you should get the following in /var/log/messages:
Feb 21 04:10:07 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) forcing a new MASTER election
Feb 21 04:10:08 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Feb 21 04:10:09 lb1 Keepalived_healthcheckers: Netlink reflector reports IP 202.54.1.1 added
Feb 21 04:10:09 lb1 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 202.54.1.1
49 Responses to IP Failover For Web Cluster
DUSTIN
July 29th, 2011 at 4:51 am
Get@Coral.Calcium.Online” rel=”nofollow”>..…
Buygeneric drugs…
PERRY
July 29th, 2011 at 6:30 am
Order@Abana.Online” rel=”nofollow”>……
Buywithout prescription…
BRANDON
July 29th, 2011 at 5:24 pm
pictures@of.abilify” rel=”nofollow”>..…
Buyno prescription…
LEWIS
July 29th, 2011 at 6:11 pm
Order@Abilify.Without.Prescription” rel=”nofollow”>..…
Buynow it…
RICARDO
July 30th, 2011 at 4:01 am
Buy@Cheap.Acai” rel=”nofollow”>..…
Buydrugs without prescription…
CHARLIE
July 30th, 2011 at 5:52 am
Buy@Discount.Acai” rel=”nofollow”>..…
Buynow it…
WALLACE
July 31st, 2011 at 12:10 am
Buy@Generic.Acai.Without.Prescription” rel=”nofollow”>……
Buygeneric drugs…
ENRIQUE
July 31st, 2011 at 7:55 pm
Order@Cheap.Abana” rel=”nofollow”>.…
Buynow it…
TERRENCE
August 1st, 2011 at 6:31 am
..…
Buyit now…
BRANDON
October 16th, 2011 at 10:54 pm
hiv research being conducted in usa…
Buy_generic pills…
EDWIN
October 18th, 2011 at 2:53 pm
alberta alcohol and drug abuse commission…
Buy_generic meds…
FREDDIE
October 18th, 2011 at 9:33 pm
advair and contraindications…
Buy_generic meds…
MICHAEL
October 18th, 2011 at 11:13 pm
canine heat cycles…
Buy_without prescription…
ALBERTO
October 20th, 2011 at 1:34 am
apo amitriptyline…
Buy_generic pills…
TIMOTHY
October 20th, 2011 at 3:15 am
recipes for gastric bypass patients…
Buy_now…
ZACHARY
October 20th, 2011 at 2:54 pm
citalopram length of use…
Buy_drugs without prescription…
ALFREDO
October 21st, 2011 at 9:45 am
conquer online hacking tools…
Buy_generic drugs…
KYLE
October 21st, 2011 at 2:45 pm
symptoms of prescription drug abuse…
Buy_drugs without prescription…
HERMAN
October 21st, 2011 at 11:05 pm
weight gain stories feeders…
Buy_drugs without prescription…
LEO
October 22nd, 2011 at 7:25 am
accutane birth defects…
Buy_it now…
HENRY
October 23rd, 2011 at 4:01 am
menstrual patterns in menopause…
Buy_no prescription…
HUBERT
October 24th, 2011 at 4:07 pm
dependent disorder anxiety…
Buy_generic pills…
RANDY
October 26th, 2011 at 8:06 am
herbal flee collars for dogs…
Buy_generic pills…
MANUEL
October 26th, 2011 at 4:26 pm
working and twin pregnancy…
Buy_now it…
JOSHUA
October 27th, 2011 at 4:06 am
statistics on pregnancy in high school…
Buy_generic meds…
FRANCIS
October 27th, 2011 at 7:26 am
how to embed pictures ms office…
Buy_drugs without prescription…
RAMON
October 28th, 2011 at 8:26 am
adult survivors of childhood cancer…
Buy_generic pills…
DOUGLAS
October 29th, 2011 at 2:02 am
singapore secure psychiatric forensic unit…
Buy_no prescription…
ALFREDO
October 29th, 2011 at 11:58 am
mini insulin fridge…
Buy_generic drugs…
PERRY
October 29th, 2011 at 9:58 pm
high calorie diet for babies…
Buy_generic drugs…
TOM
October 29th, 2011 at 11:38 pm
cheap fetal heart rate monitor…
Buy_generic meds…
BEN
October 30th, 2011 at 1:19 am
cures for fingernail fungi…
Buy_generic meds…
ANDREW
October 30th, 2011 at 7:04 am
avelox treats for bacteria…
Buy_drugs without prescription…
SERGIO
October 30th, 2011 at 1:42 pm
drug treatment for bipolar disorder…
Buy_generic pills…
PETER
October 31st, 2011 at 9:43 am
bacterial staphylococcus aureus meningitis symptoms…
Buy_without prescription…
KIRK
November 1st, 2011 at 5:43 am
st joseph aspirin coupon…
Buy_generic pills…
DALE
November 5th, 2011 at 8:07 am
hot spots or cancer…
Buy_without prescription…
ROSS
November 5th, 2011 at 2:47 pm
build muscle mass diet…
Buy_drugs without prescription…
PETER
November 6th, 2011 at 12:47 am
south beach diet foods to avoid…
Buy_no prescription…
LUTHER
November 9th, 2011 at 1:21 am
free diabetes logbooks to print…
Buy_generic drugs…
MICHEAL
November 9th, 2011 at 9:41 am
glucophage powered by vbulletin version 2.2.1…
Buy_generic pills…
DAVE
November 10th, 2011 at 9:01 am
hiv quality of life survey tools…
Buy_drugs without prescription…
PATRICK
November 10th, 2011 at 2:01 pm
obesity in moorhead minnesota…
Buy_now…
DAN
November 11th, 2011 at 4:41 pm
medical nebulizer…
Buy_generic meds…
JORGE
November 12th, 2011 at 12:41 pm
breast cancer site is having trouble…
Buy_drugs without prescription…
JIM
November 15th, 2011 at 12:39 pm
boost metabolism foods…
Buy_now…
STEVE
November 15th, 2011 at 10:39 pm
drug citalopram side effects…
Buy_generic drugs…
JORGE
November 16th, 2011 at 1:39 pm
air purifiers for allergies…
Buy_generic meds…
nathaniel
December 10th, 2011 at 5:43 pm
Download@alternative.Rock” rel=”nofollow”>.…
Search rock UK Charts…