Where to start First steps track · 15 stages
Linux Labs

keepalived — high availability with VRRP

cheat sheet · Ubuntu 24.04 · keepalived https://lab.dimsanych.ru/en/wiki/keepalived/

Cheat sheet

  • ip a | grep VIP which node is MASTER right now
  • journalctl -u keepalived -f state transitions
  • conf: state MASTER/BACKUP · virtual_router_id (same on all nodes) · priority · virtual_ipaddress
  • service check: vrrp_script + track_script (a negative weight)
  • split-brain → firewall VRRP through (proto 112, 224.0.0.18) or use unicast_peer

Configuration

/etc/keepalived/keepalived.conf (on the MASTER):

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51        # SAME on every node in the group, unique on the L2 segment
    priority 100                # higher = preferred MASTER
    advert_int 1
    authentication { auth_type PASS; auth_pass secret }
    virtual_ipaddress { 10.0.0.10/24 }
}

On the BACKUP — the same, but state BACKUP and priority 90.

Directive Meaning
priority weight in the MASTER election (higher wins)
nopreempt don't take the VIP back on return (avoid extra flips)
unicast_peer VRRP over unicast (clouds/networks without multicast)
vrrp_script + track_script check a service → lower priority on failure
Loading…