Prevent VRRP Master from becoming Master once it has failed

18,552

Solution 1

According to this relatively old thread on the keepalived developer list, it can be done. You set both servers to be equal priority (or none at all), and do not declare the state for either as MASTER or BACKUP, and instead set the state to EQUAL for both.

EDIT (07-Dec-2017):

It appears that EQUAL is not actually a valid state, despite it appearing to provide the desired effect at the time this answer was posted. Please note the comments below, in particular the link to the current issues list for keepalived provided by @cristi.

Solution 2

The way we solved this is by adding the nopreempt flag to our keepalived config file. Didn't have to change anything else (still left one as MASTER and one as BACKUP and so on). Basically this tells it to not switch masters just because a new server came online, only switch when the current master fails.

Share:
18,552

Related videos on Youtube

MrMahgu
Author by

MrMahgu

Updated on September 17, 2022

Comments

  • MrMahgu
    MrMahgu almost 2 years

    I have two machines (A and B, A is Master) running VRPP (from keepalived) for a Virtual IP.

    How can I prevent A from becoming Master again if it has failed and come back up (for whatever reason)?

    I'm doing this so that we have a single fail-over to the second box, and going back to normal would require manual intervention.

    • MrMahgu
      MrMahgu almost 15 years
      I'm too new to create tag "VRRP"
  • MrMahgu
    MrMahgu almost 15 years
    Thank you -- Also worth a note, using above configuration (of equal priority and using "EQUAL") if no master has taken over, the VRRP instance with lowest IP will become MASTER.
  • davr
    davr almost 15 years
    There is a config flag of doing this, so this answer is wrong.
  • chris
    chris almost 15 years
    The voted answer is correct for a general deployment of vrrp where you don't want a master to take over when it returns to service. As you say, there is also a keepalived way of doing this which is probably more correct for when doing linux HA stuff instead of just using vrrp to provide L3 redundancy for a default route (the more traditional reason for using vrrp).
  • MrMahgu
    MrMahgu almost 15 years
    from "article.gmane.org/gmane.linux.keepalived.devel/1537" If "state" is set to MASTER, "nopreempt" is basically ignored since when the machine with "state MASTER" returns it will just grab the IP from the machine with "state BACKUP" without even holding an election. I had to set both my machines to state BACKUP with one having higher priority in order for "nopreempt" to function as intended.
  • cristi
    cristi over 6 years
    This is wrong. See this message from the developers: github.com/acassen/keepalived/issues/707
  • James Sneeringer
    James Sneeringer over 6 years
    @cristi - It was a working solution at the time it was posted (2009), which in turn was based on information I clearly acknowledged was old even then (2003). I've updated the link in my answer to a working one since osdir.com no longer seems to have the keepalived-devel archives. I would guess that, at the time, the software silently ignored the invalid EQUAL directive and treated it as though no priority was set at all (which just happened to have the desired effect).
  • Rihard  Novozhilov
    Rihard Novozhilov almost 5 years
    Deleted priority and state and added nopreempt. Works well for me