I am trying to create load balancer using Virtual IP. I referred this link Load Balancer using Virtual IP. After configuring by mistake I started the backup server's keepalived service first and then I started master server's keepalived. The problem is the backup server's keepalived is working fine but I can't start the master server's keepalived. I tried uninstall the keepalived and installed again but that didn't work. Here is the config files
Master Server
vrrp_script chk_haproxy {
script "killall -0 haproxy" # verify the pid existance
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}
vrrp_instance VI_1 {
interface eth0 # interface to monitor
state MASTER
virtual_router_id 51 # Assign one ID for this route
priority 101 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.0.54 # the virtual IP
}
track_script {
chk_haproxy
}
}
Backup Server
vrrp_script chk_haproxy {
script "killall -0 haproxy" # verify the pid existance
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}
vrrp_instance VI_1 {
interface eth0 # interface to monitor
state MASTER
virtual_router_id 51 # Assign one ID for this route
priority 100 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.0.54 # the virtual IP
}
track_script {
chk_haproxy
}
}
Output of Master Server while starting the keepalived service
$ sudo service keepalived start
* Starting keepalived keepalived [fail]
Output of Backup Server while starting the keepalived service
$ sudo service keepalived start
* Starting keepalived keepalived [Ok]
Is anyone having suggestion what I am doing wrong here??
Update according to comments: Master Server Log:
cat /var/log/syslog | grep VRRP_Instance
Here it does not prints anything which mean that the keepalived does not start on Master server
Backup servers log:
cat /var/log/syslog | grep VRRP_Instance
Mar 27 02:39:22 ubuntu keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 27 02:39:23 ubuntu keepalived_vrrp: VRRP_Instance(VI_1) Entering to MASTER STATE
Mar 27 02:39:38 ubuntu keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Mar 27 02:39:39 ubuntu keepalived_vrrp: VRRP_Instance(VI_1) Entering to MASTER STATE
Mar 27 02:52:16 ubuntu keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advert
Mar 27 02:52:16 ubuntu keepalived_vrrp: VRRP_Instance(VI_1) Entering to BACKUP STATE
Also one more thing after referring to a website I changed the state in keepalived.conf file of backup server to state BACKUP