keepalived (5) - Linux Manuals
keepalived: configuration file for keepalived
Command to display keepalived
manual in Linux: $ man 5 keepalived
NAME
/etc/keepalived/keepalived.conf - configuration file for keepalived
DESCRIPTION
keepalived.conf
is the configuration file which describes all the keepalived keywords.
keywords are placed in hierachies of blocks (and subblocks),
each layer being delimited by '{' and '}' pairs.
Comments start with '#' or '!' to the end of the line and can start
anywhere in a line.
TOP HIERACHY
GLOBAL CONFIGURATION
VRRPD CONFIGURATION
LVS CONFIGURATION
GLOBAL CONFIGURATION
contains subblocks of
Global definitions
and
Static routes
Global definitions
global_defs # Block id
{
notification_email # To:
{
admin [at] example1.com
...
}
# From: from address that will be in header
notification_email_from admin [at] example.com
smtp_server 127.0.0.1 # IP
smtp_connect_timeout 30 # integer, seconds
router_id my_hostname # string identifying the machine,
# (doesn't have to be hostname).
}
Static routes/addresses
keepalived can configure static addresses and routes
with
ip
(ie if addresses are not already on the machine). These addresses are
NOT
moved by vrrpd, they stay on the machine.
If you already have IPs and routes on your machines and
your machines can ping each other, you don't need this section.
The whole string is fed to
ip addr add.
You can truncate the string anywhere you like and let
ip addr add
use defaults for the rest of the string. If you just
feed the string "192.168.1.1", the IP will be 192.168.1.1/32,
which you probably don't want.
This is different to
ifconfig
which will configure the IP with the standard class, here
192.168.1.1/24.
The minimum string then would be the IP/netmask, eg 192.168.1.1/24
static_ipaddress
{
192.168.1.1/24 brd + dev eth0 scope global
...
}
The whole string is fed to
ip route add.
You can truncate the string allowing
ip route add
to use defaults.
static_routes
{
src $SRC_IP to $DST_IP dev $SRC_DEVICE
...
src $SRC_IP to $DST_IP via $GW dev $SRC_DEVICE
}
VRRPD CONFIGURATION
contains subblocks of
VRRP synchronization group(s)
and
VRRP instance(s)
VRRP synchronization group(s)
#string, name of group of IPs that failover together
vrrp_sync_group VG_1 {
group {
inside_network # name of vrrp_instance (below)
outside_network # One for each moveable IP.
...
}
# notify scripts and alerts are optional
#
# filenames of scripts to run on transitions
# can be unquoted (if just filename)
# or quoted (if has parameters)
# to MASTER transition
notify_master /path/to_master.sh
# to BACKUP transition
notify_backup /path/to_backup.sh
# FAULT transition
notify_fault "/path/fault.sh VG_1"
# for ANY state transition.
# "notify" script is called AFTER the
# notify_* script(s) and is executed
# with 3 arguments provided by keepalived
# (ie don't include parameters in the notify line).
# arguments
# $1 = "GROUP"|"INSTANCE"
# $2 = name of group or instance
# $3 = target state of transition
# ("MASTER"|"BACKUP"|"FAULT")
notify /path/notify.sh
# Send email notifcation during state transition,
# using addresses in global_defs above.
smtp_alert
}
VRRP instance(s)
describes the moveable IP for each instance of a group in vrrp_sync_group.
Here are described two IPs (on inside_network and on outside_network),
on machine "my_hostname", which belong to the group VG_1 and
which will transition together on any state change.
#You will need to write another block for outside_network.
vrrp_instance inside_network {
# Initial state, MASTER|BACKUP
# As soon as the other machine(s) come up,
# an election will be held and the machine
# with the highest "priority" will become MASTER.
# So the entry here doesn't matter a whole lot.
state MASTER
# interface for inside_network, bound by vrrp
interface eth0
# Ignore VRRP interface faults (default unset)
dont_track_primary
# optional, monitor these as well.
# go to FAULT state if any of these go down.
track_interface {
eth0
eth1
...
}
#default IP for binding vrrpd is the primary IP
#on interface. If you want to hide location of vrrpd,
#use this IP as src_addr for multicast vrrp packets.
#(since it's multicast, vrrpd will get the reply
#packet no matter what src_addr is used).
#optional
mcast_src_ip <IPADDR>
# Binding interface for lvs syncd
lvs_sync_daemon_interface eth1
# delay for gratuitous ARP after transition to MASTER
garp_master_delay 10 # secs, default 5
# arbitary unique number 0..255
# used to differentiate multiple instances of vrrpd
# running on the same NIC (and hence same socket).
virtual_router_id 51