keepalived — high availability with VRRP
cheat sheet · Ubuntu 24.04 · keepalived https://lab.dimsanych.ru/en/wiki/keepalived/Cheat sheet
-
ip a | grep VIPwhich node is MASTER right now -
journalctl -u keepalived -fstate 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):
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 |