1

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

3
  • 1
    and what do the log files tell you? – natxo asenjo Mar 27 '15 at 11:43
  • @natxo I updated the question please check edit. – Vighanesh Gursale Mar 27 '15 at 12:03
  • check this site: my.vertica.com/docs/5.0/HTML/Master/12982.htm for debugging tips on keepalived. Something useful is to run the process on the foreground: keepalived -f /path/to/keepalived.conf --dont-fork --log-console --log-detail – natxo asenjo Mar 27 '15 at 15:57
0

You have misconfigured your VRRP instance. You have state MASTER on both nodes, but you can have only one master. Set backup server to state BACKUP and it will work. In general, rules are quite simple:

Same on both servers:

  • virtual_router_id - must be uniq for each group of servers
  • virtual_ip

Different on both servers:

  • Instance name ( vrrp_instance THIS-IS-INSTANCE-NAME { )
  • state (MASTER on one, BACKUP on others)
  • priority (uniq for each node, highest for master)
0

state MASTER can only be set one of the node. Alternatively, both set to state BACKUP, It will be automatically selected in MASTER by priority.

0

It would be useful if you could repost your current config. Maybe give this a try though.

Master server

vrrp_script chk_haproxy {
   script "pidof haproxy"        # check the pid not kill it
   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 150                  # 150 on master, 100 on backup
   unicast_peer {
       <backup ip address>
   }
   virtual_ipaddress {
       192.168.0.54            # the virtual IP
   }
   track_script {
       chk_haproxy
  }
}

Backup server

All the same as the master but change:

state BACKUP
priority 100
unicast_peer {
     <master ip address>
}

ensure you are allowing VRRP protocol (IP proto 112) between master and backup. Check state of each at /var/run/keepalived.INSTANCE.VI_1.state Make sure haproxy starts before keepalived.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.