What is the correct way to disable preempt for keepalived in RHEL 7.3?

Posted on

Hello.

I am using keepalived 1.2.13 downloaded from RHEL repository and would like to know the correct way to disable preemption when master node comes online after FAULT state.

My environment is

Node 1
IP : 192.168.11.14

Node 2
IP : 192.168.11.14

VIP is 192.168.11.250

Looks like there are couple of ways to implement this.

  1. (Without nopreempt) Set state to EQUAL and set same priority on both instances. Ref

  2. Use nopreempt option

           # VRRP will normally preempt a lower priority
           # machine when a higher priority machine comes
           # online.  "nopreempt" allows the lower priority
           # machine to maintain the master role, even when
           # a higher priority machine comes back online.
           # NOTE: For this to work, the initial state of this
           # entry must be BACKUP.
           nopreempt

However, in scenario2 vip is not switching into second node although first node goes fault state . States are tracked by track_script in my case.
Below is my configuration

Node 1

       global_defs {
   notification_email {
     root@localhost.localdomain
   }

   notification_email_from root@localhost.localdomain
}

vrrp_script check_service {
  script "/usr/bin/netstat -atunp | grep '0.0.0.0:514' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}

vrrp_instance RSYSLOG_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 10
    advert_int 1
    nopreempt
    virtual_ipaddress {
        192.168.11.250/24
    }

    track_script {
      check_service

    }
}

Node2

global_defs {
   notification_email {
     root@localhost.localdomain
   }

   notification_email_from root@localhost.localdomain

}

vrrp_script check_service {
  script "/usr/bin/netstat -atunp | grep '0.0.0.0:514' &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK
}


vrrp_instance RSYSLOG_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 9
    advert_int 1
    nopreempt
    virtual_ipaddress {
        192.168.11.250/24
    }

    track_script {
      check_service
    }
}

Does anybody know the proper way to prevent the preemption? Any advice is appreciated!

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.