Friends,
Today I am showing Haproxy setup along with Keepalived. In this blog I will setup Keep alive. HaProxy setup will be done on my next blog.
Keepalived is used to achieve high availability by assigning a VIP to two or more servers.
Installation:-
I am doing this on two ubuntu servers having ip 172.16.1.209 and 172.16.1.211. The virtual IP will be 172.16.1.210.
Install packages
Configuring keepalived
Create the config file on the first server (172.16.1.209):
Create the config file on the second server (172.16.1.211)
Start service
When our Haproxy setup done, We need to start Keepalived on both servers:
Today I am showing Haproxy setup along with Keepalived. In this blog I will setup Keep alive. HaProxy setup will be done on my next blog.
Keepalived is used to achieve high availability by assigning a VIP to two or more servers.
Installation:-
I am doing this on two ubuntu servers having ip 172.16.1.209 and 172.16.1.211. The virtual IP will be 172.16.1.210.
Install packages
apt-get install keepalived
Configuring keepalived
Create the config file on the first server (172.16.1.209):
vim /etc/keepalived/keepalived.confglobal_defs {router_id NM-PRD-HAPROXY-209}vrrp_script haproxy {script "killall -0 haproxy"interval 1weight 2}vrrp_instance 50 {virtual_router_id 50advert_int 1priority 101state MASTERinterface eth0virtual_ipaddress {172.16.1.210}track_script {haproxy}authentication {auth_type PASSauth_pass We$,J)Og&}}
Create the config file on the second server (172.16.1.211)
vim /etc/keepalived/keepalived.confglobal_defs {router_id NM-PRD-HAPROXY-211}vrrp_script haproxy {script "killall -0 haproxy"interval 1weight 2}vrrp_instance 50 {virtual_router_id 50advert_int 1priority 102state MASTERinterface eth0virtual_ipaddress {172.16.1.210}track_script {haproxy}authentication {auth_type PASSauth_pass We$,J)Og&}}
Note :-
We need to enable sysctl setting for no local ip binding allow on the Kernel.
Temporary:
echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
Permanent:
Add this to
/etc/sysctl.conf:net.ipv4.ip_nonlocal_bind = 1
Enable with:
sysctl -p
Start service
When our Haproxy setup done, We need to start Keepalived on both servers:
service keepalived start