Setting up Keepalived

install | setup | simple | routing states | check-ha

Warning

logs

the debian build for keepalived was not compiled with --enable-log-file but sending to syslog still works – on debian12 you might consider installing some good old syslog daemon.

kiss

we want to keep the same configuration around the cluster – we define BACKUP as the initial state of the instance on all nodes and with lowest priority.

Requirements

mv -i /etc/sysctl.conf /etc/sysctl.conf.dist
vi /etc/sysctl.conf # new file
# routing
net.ipv4.ip_forward = 1

# vrrp
net.ipv4.ip_nonlocal_bind = 1
sysctl -p

Install

see install

we use a helper script to track events

vi /var/tmp/notify.bash
#!/bin/bash
echo `date` -- $HOSTNAME received $@ >> /var/tmp/notify.log
chmod +x /var/tmp/notify.bash

startup options

cp -pi /etc/default/keepalived /etc/default/keepalived.dist
    vi /etc/default/keepalived

debian

DAEMON_ARGS="--vrrp --log-detail"
# --enable-log-file --log-file=/var/log/keepalived.log

slackware

KEEPALIVED_OPTIONS="-f /etc/keepalived/keepalived.conf --vrrp --log-detail"
# --enable-log-file --log-file=/var/log/keepalived.log

Setup

    cd /etc/keepalived/

    # debian
    ls -lF keepalived.conf.sample

    # slackware
    mv -i keepalived.conf keepalived.conf.dist

    vi keepalived.conf # new file

see simple for basic setup.

see routing states for an active/passive lbs + gateway fail-over setup (with states) – for tracking both inbound and outbound states.

see check-ha for an active/active layer7 lbs setup (without states) – for assuring nodes are ready before a fail-over

Ready to go

check the configuration and populate across the cluster

debian

keepalived -t
systemctl restart keepalived.service
systemctl status keepalived.service

slackware

    keepalived -t
    /etc/rc.d/rc.keepalived restart
pgrep -a keepalived

Resources

manuals

keepalived.conf - configuration file for Keepalived https://www.keepalived.org/manpage.html

keepalived.conf - configuration file for Keepalived https://fossies.org/linux/keepalived/doc/man/man5/keepalived.conf.5

https://manpages.debian.org/bookworm/keepalived/keepalived.conf.5.en.html

guides

16.5 Installing and Configuring Keepalived https://docs.oracle.com/cd/E37670_01/E41138/html/section_ksr_psb_nr.html

16.5.1 About the Keepalived Configuration File https://docs.oracle.com/cd/E37670_01/E41138/html/section_wv3_hjn_pr.html

16.6 Configuring Simple Virtual IP Address Failover Using Keepalived https://docs.oracle.com/cd/E37670_01/E41138/html/section_uxg_lzh_nr.html

16.10 Making HAProxy Highly Available Using Keepalived https://docs.oracle.com/cd/E37670_01/E41138/html/section_sm3_svy_4r.html

Keepalived and high availability: Advanced topics https://www.redhat.com/sysadmin/advanced-keepalived

Deploying Highly Available Virtual Interfaces With Keepalived https://prefetch.net/articles/linuxkeepalivedvrrp.html

https://www.linode.com/docs/products/compute/compute-instances/guides/failover-legacy-keepalived/ ==> nice MWE

ops

Keepalived and Virtual IP: The friends are not always helping! https://www.linkedin.com/pulse/keepalived-virtual-ip-friends-always-helping-angelo-giannattasio/

Setting up a Linux cluster with Keepalived: Basic configuration https://www.redhat.com/sysadmin/keepalived-basics

View Current State of Keepalived https://serverfault.com/questions/560024/view-current-state-of-keepalived

troubles

Keepalived’s virtual_router_id - should it be unique per node? https://serverfault.com/questions/473058/keepaliveds-virtual-router-id-should-it-be-unique-per-node

keepalived: create keepalived_script system user/group #224 https://github.com/hap-wi/roxy-wi/issues/224

moar

Adoption https://wiki.nftables.org/wiki-nftables/index.php/Adoption

nftables support #924 https://github.com/acassen/keepalived/issues/924

netfilter

Re: nftable rule for VRRP traffic https://www.spinics.net/lists/netfilter/msg59869.html

alternatives

carp

https://help.mikrotik.com/docs/display/ROS/VRRP


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun