7

I want to use nopreempt option with keepalived vrrp setting to run backup node as master when master goes down and again reback into network.

I setup nopreempt option in both servers and set state as backup in both servers but due to high priority nopreempt is not working.

Please guide to resolve it?

  Master Machine: 
  ! Configuration File for keepalived
   vrrp_instance VI_1 {
   state BACKUP
   nopreempt
   interface eth0
   virtual_router_id 1
   priority 250
   advert_int 1
   virtual_ipaddress {
    192.168.1.2/24
    } 
  }

  Backup Machine :
  ! Configuration File for keepalived
   vrrp_instance VI_1 {
   state BACKUP
   nopreempt
   interface eth0
   virtual_router_id 1
   priority 200
   advert_int 1
   virtual_ipaddress {
     192.168.1.2/24
   }

}

Regards, Ben

6 Answers 6

6

Changed both server state as BACKUP. Primary having higher priority and with nopreempt, both having the same router ID. This works for me.

0
2

I have tried many configurations to achieve this and the only one that works was setting both servers to state BACKUP, one server with priority 51, the othe one with 50 and setting nopreempt. Here is the example configuration:

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 51
    nopreempt
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass XXXXXXXX
    }
    virtual_ipaddress {
        192.168.69.100/28
    }
}

Just set priority to 50 on the second server and all should work.

2

First of all: I'm using CentOS 6 and keepalived 1.2.7 (02/21,2013)

I tried nopreempt as well and after some testing it works as expected.

Running master and backup with the same vrrp priority is a bad idea because there is a bug (AFAICT) which leads to a situation were both keepalived server start the VIP. according to https://www.rfc-editor.org/rfc/rfc5798#page-26 the keepalived with the highest IP should stay/become master. I could not observe this behavior!

(AFAICT again) You have to remove the statement "state" from the config file if you intend to see nopreempt working. If the keepalived with "state MASTER" in config file starts up it starts as master and advertises it self as such = bad. If there is no "state" statement in the config file keepalived starts in state BACKUP and listens to vrrp. because of "nopreempt" it will not become MASTER even if it runs with highest priority. this is contrary to the man 5 keepalived.conf page, whereupon state does not matter much.

The keepalived with prio 255 always becomes master - regardless of nopreempt option on or off.

If you test keepalived have a close look at firewall/nat rules. it's always a good idea to run something like tcpdump to check if the vrrp advertisements get through and have the correct sender IP (the one from the other keepalived(s), not the standard gw!) This is especially true if you use kvm/qemu guests as there are default nat rules which change vrrp advertisements.

nopreempt only works for keepalived in state BACKUP. (RTFM) if keepalived (1.2.7) is running and the network link goes down keepalived changes to state FAULT. when network link comes back keepalived becomes MASTER if prio is high enough. I don't know if this is a bug but it makes nopreempt somehow useless. I'll send a question to the mailing list.

0

This may or may not be the correct solution for you, but I only have two keepalived servers.

If you don't want one server to pre-empt the other, one server having a higher priority than the other doesn't really matter in a two server scenario like mine. It works for me if I enable nopreempt and set both servers to have the same priority.

UPDATE

Config example as requested:

vrrp_sync_group VRRP_SYNCS {
    group {
        public_http_ips
    }
}

vrrp_instance public_http_ips {
    state MASTER
    interface eth0
    virtual_router_id 18
    priority 100
    advert_int 1
    nopreempt
    virtual_ipaddress {
        192.168.0.254/24 dev eth0
    }
}

The backup is exactly the same but it says "state BACKUP".

2
  • Hi Javano, Can you share your config to resolve nopreempt problem?
    – Ben
    May 13, 2013 at 17:11
  • @Ben Added as requested :)
    – Baldrick
    May 13, 2013 at 17:18
0

You must set "fall" and "rise" options in vrrp script. Example running configuration:

vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 1
    fall 2
    rise 2
}

vrrp_instance VI_1 {
    interface eth0

    track_interface {
        eth0
        eth1
    }

    state BACKUP # same as other node
    priority 101 # your choice
    virtual_router_id 53
    advert_int 1
    nopreempt

    authentication {
        auth_type PASS
        auth_pass 8CHARPASS
    }

    unicast_src_ip 172.31.10.11 # other node: 172.31.10.12
    unicast_peer {
        172.31.10.12 # other node: 172.31.10.11
    }

    virtual_ipaddress {
        172.31.20.20 dev eth1
    }

    track_script {
        chk_haproxy
    }
}
0

I think the same param "virtual_router_id" in two configs is the key here, with different "virtual_router_id" values the nopreempt doesn't work. Try to set the same "virtual_router_id".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .