Date created: Monday, April 8, 2013 2:13:52 PM. Last modified: Wednesday, January 4, 2023 9:57:29 PM
keepalived
Install:
wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz
gunzip keepalived-1.2.7.tar.gz
tar -xf keepalived-1.2.7.tar
cd keepalived-1.2.7/
sudo apt-get install libpopt-dev snmp snmpd libnl1 libnl-dev libssl-dev make libsnmp-dev
./configure --enable-snmp
make
sudo make install
System Conig:
To allow services to bind to IPs that aren't always running on this machine (i.e. a keepalived backup machine);
echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
vi /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind=1
Example Config:
This basic config is simply for sharing IPs amoungst two servers. Using the same config on both servers (except setting the state to BACKUP for the other server!) will give a no preempt behaviour, as they both have the same priority (100). This means that if the master enters the failed state and the backup takes over, upon restoration of the master it won't take over again, causing more downtime/disruption.
vrrp_sync_group VRRP_SYNCS { group { public_http_ips private_http_ips } } vrrp_instance public_http_ips { state MASTER interface eth0 track_interface { #eth1 } virtual_router_id 10 priority 100 advert_int 1 nopreempt virtual_ipaddress { 10.0.0.65/28 dev eth0 10.0.0.66/28 dev eth0 10.0.0.67/28 dev eth0 10.0.0.68/28 dev eth0 } authentication { auth_type PASS auth_pass S5iAoTGJDLgW } } vrrp_instance private_http_ips { state MASTER interface eth1 track_interface { #eth0 } virtual_router_id 20 priority 100 advert_int 1 nopreempt virtual_ipaddress { 192.168.0.250 # you don't have to specify mask and dev } authentication { auth_type PASS auth_pass bxUcbz52FE38 } }
Errors:
Infinite loop trying to spawn child process;
Apr 11 16:16:49 basil Keepalived[5345]: Starting Keepalived v1.2.7 (04/08,2013) Apr 11 16:16:49 basil Keepalived[5345]: Starting Healthcheck child process, pid=5346 Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5347 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Initializing ipvs 2.6 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Interface queue is empty Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: No such interface, eth0 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: No such interface, eth1.116 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: No such interface, br1116 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: No such interface, eth1.118 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: No such interface, br1118 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP 10.0.115.69 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP 10.0.116.249 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP 89.21.226.74 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP fe80::220:edff:fe9f:9774 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Registering Kernel netlink reflector Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Registering Kernel netlink command channel Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Opening file '/etc/keepalived/keepalived.conf'. Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5347) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5348 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Configuration is using : 4853 Bytes Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: ------< Global definitions >------ Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Router ID = basil Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Smtp server connection timeout = 30 Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Email notification from = root@basil Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: SNMP Trap disabled Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: ------< SSL definitions >------ Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Using autogen SSL context Apr 11 16:16:49 basil Keepalived_healthcheckers[5346]: Using LinkWatch kernel netlink reflector... Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5348) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5349 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5349) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5350 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5350) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5351 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5351) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5352 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5352) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5353 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5353) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5354 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5354) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5355 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5355) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5356 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5356) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5357 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5357) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5358 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5358) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5359 Apr 11 16:16:49 basil Keepalived[5345]: VRRP child process(5359) died: Respawning Apr 11 16:16:49 basil Keepalived[5345]: Starting VRRP child process, pid=5360
This can occur for one of two reasons; the kernel module ip_vs isn't loaded;
lsmod | grep ip_vs
sudo modprobe -a ip_vs
lsmod | grep ip_vs
Or, there is an error in the keepalived.conf file.
keepalived starts but nothing happens, no IPs are added, sync groups come up etc;
Apr 11 17:25:33 basil Keepalived[8047]: Starting Keepalived v1.2.7 (04/08,2013) Apr 11 17:25:33 basil Keepalived[8048]: Starting Healthcheck child process, pid=8051 Apr 11 17:25:33 basil Keepalived[8048]: Starting VRRP child process, pid=8052 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Initializing ipvs 2.6 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Interface queue is empty Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: No such interface, eth0 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: No such interface, eth1.116 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: No such interface, br1116 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: No such interface, eth1.118 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: No such interface, br1118 Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP 10.0.115.69 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP 10.0.116.249 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP 192.168.0.250 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP fe80::220:edff:fe9f:9774 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Netlink reflector reports IP fe80::2a0:c9ff:fe8f:4164 added Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Registering Kernel netlink reflector Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Registering Kernel netlink command channel Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Configuration is using : 2777 Bytes Apr 11 17:25:33 basil Keepalived_healthcheckers[8051]: Using LinkWatch kernel netlink reflector...
This happens because there is a problem in the keepalived.conf file or it hasn't been loaded (invalid path for example)
Previous page: Monitor URI with Backend ACL
Next page: Kickstart Example