it is possible to configure keepalived so that only the master server are running an active service from haproxy?

Currently LB1 and LB2 (both with keepalived and haproxy) works great. But sometimes some requests is taken from LB2 (which is backup and the logs show it also) which results in an connection error in the browser

I deactivated haproxy on LB2 (service haproxy stop) and everything works fine. But now when LB1 goes down LB2 is going into master with an not started haproxy service.

I'm using Ubuntu Server 14.04.


The method is notify named. You have to put example in keepalived.conf (on both servers:

notify /etc/keepalived/notify-keepalived.sh

And in the notfiy-keepalived.sh following code:

case $STATE in
        "MASTER") /usr/sbin/service haproxy start
        "BACKUP") /usr/sbin/service haproxy stop
        "FAULT")  /usr/sbin/service haproxy stop
                  exit 0
        *)        /sbin/logger "haproxy unknown state"
                  exit 1

Now keepalived will do the commands when its entering in one of the three states.

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.