0

I have 2 servers, both running keepalived.

What works well:

  • If I reboot master server, all works well and backup takes over
  • If I kill the web service on either servers, I can see log messages about lowering the priority

What does not work

  • If I kill the web service on master, it will lower the priority, but not switch to backup
  • I see this message on backup received lower priority (150) advert from 192.168.1.122 - discarding
  • So, the backup server sees that master has lower priority, but does nothing

Instance1:

#
# !! Keep this file in sync with git !!
#

global_defs {
  default_interface ens160
  enable_script_security 
  script_user deployer
}

vrrp_script chk_myscript {
  script       "/home/tp/keepalived/checkscript.sh"
  interval 2   # check every 2 seconds
  fall 2       # require 2 failures for KO
  rise 2       # require 2 successes for OK
  weight 2
}

vrrp_instance VI_1 {
    state MASTER
    interface ens160
    virtual_router_id 51
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass d0cker
    }
    virtual_ipaddress {
        192.168.1.128
    }
    unicast_peer {
        192.168.1.123
    }
    track_script {
        chk_myscript
    }
}


Instance 2

#
# !! Keep this file in sync with git !!
#

global_defs {
  default_interface ens160
  enable_script_security 
  script_user deployer
}

vrrp_script chk_myscript {
  script       "/home/tp/keepalived/checkscript.sh"
  interval 2   # check every 2 seconds
  fall 2       # require 2 failures for KO
  rise 2       # require 2 successes for OK
  weight 2
}

vrrp_instance VI_2 {
    state BACKUP
    interface ens160
    virtual_router_id 51
    priority 149
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass d0cker
    }
    virtual_ipaddress {
        192.168.1.128
    }
    unicast_peer {
        192.168.1.122
    }
    track_script {
        chk_myscript
    }
}


Checkscript

#!/bin/bash

curl -sSf -m 1 http://localhost:80/ping > /dev/null 2>&1
if [ $? -ne 0 ]; then
  echo "Failed to ping localhost:80"
  exit 1
fi

Environment:

Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy

Keepalived v2.2.4 (08/21,2021)

I tried tinkering with the priorities and other config parameters, without sucess.

quibusus
  • 396
  • 3
  • 4

0 Answers0