Home > database >  Keepalived exit with status 2
Keepalived exit with status 2

Time:11-15

Hello I am having problem with my keepalived.

on the logs it's said that check script is exiting with status 2 while

Here is the log

Nov 11 19:54:03 MCX-G2 Keepalived_vrrp[15201]: VRRP_Script(chk_server) failed (exited with status 2)
Nov 11 19:54:03 MCX-G2 Keepalived_vrrp[15201]: VRRP_Script(chk_script) succeeded
Nov 11 19:54:03 MCX-G2 Keepalived_vrrp[15201]: (VRRP1) Entering BACKUP STATE

Below is the part of keepalived config

  vrrp_script chk_server {
  script       "/bin/ping -c 1 100.100.100.1 &> /dev/null"
  interval 10   # check every 10 seconds
  fall 1       # require 1 failures for KO
  rise 1       # require 1 successes for OK
}

while ping is success :

root@MCX-G2 /bin # /bin/ping -c 1 172.20.128.100
PING 172.20.128.100 (172.20.128.100) 56(84) bytes of data.
64 bytes from 172.20.128.100: icmp_seq=1 ttl=63 time=0.319 ms

--- 172.20.128.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.319/0.319/0.319/0.000 ms
root@MCX-G2 /bin #

I don't see any suspicious mis-config or something like that. Is there anything else I should check?

CodePudding user response:

As stated in the keepalived.conf manual page, it looks for a script to be executed periodically.

VRRP script(s)
        # Adds a script to be executed periodically. Its exit code will be
        # recorded for all VRRP instances which are monitoring it.
        vrrp_script <SCRIPT_NAME> {
           script <STRING>|<QUOTED-STRING> # path of the script to execute

So this should solve the issue:

  • adding your command to a script file like chk_nebula.sh.
    • cat /chk_nebula.sh
#!/bin/bash
/bin/ping -c 1 172.20.128.100 &> /dev/null
  • Make the script file executable by running:
    • chmod x /chk_nebula.sh
  • and use the following value for the script parameter in your keepalive configuration file.

script "/chk_nebula.sh"

  • Related