Keepalived for Ubuntu 16

Posted August 8, 2016 16.2k views
Load BalancingHigh AvailabilityUbuntu 16.04

Hello Everyone,

I was wondering if anyone might be able to help me out with setting up Keepalived on Ubuntu 16. I went ahead and followed the tutorial here on Digital Ocean but when I run sudo start keepalived I get an error saying that start isnt a recognized command.

I am having a hard time finding other resources but I suspect that I either need to use different command to start keepalived, or I need to modify the tutorial in some way.

Any help or advice would greatly be appreciated!

  • So it looks like I have one remaining problem. The keepalived service is up and running on both of my droplets now. They recognize and change their state when I turn on and off my servers, but neither of them seem to run the notify_master script.

    When I run the script manually the floating IP is successfully transferred over. From that I am guessing that the script itself is not the issue.

  • Hi,

    Have you found a solution to this?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers

So I finally got things working. I wanted to write down what it was I needed to do to get things to running so hopefully anyone with a similar issue doesn’t have to sink in as much time as I did.

1) I thought all you needed to do to enable private networking on my droplets was just click on the button in the control panel. Turns out there is a bit more work involved, you can see what you need to do here:

2) Make sure you are downloading the latest version of keepalived. The version currently listed in the tutorial has a bug in it that prevents it from running the script. As of me writing this the newest version is 1.2.23. Just check here to see what latest version is:

3) The python script that the tutorial uses to change the floating IP requires the requests module, which does not come standard with python that is bundled with Ubuntu 16. If you haven’t already, install python pip, and then use pip to install the requests module. I also ran into an error trying to install requests involving my locale. Here are the commands I used to get the python script to work

apt-get install python-pip
export LC_ALL=C
pip install requests

4) With changes that came along with Ubuntu 16, upstart doesn’t apply anymore. I needed to create a new service on each of my droplets so that I could run them with systemctl. Doing the following set up things correctly on my droplets

sudo nano /etc/systemd/system/keepalived.service

Then I copied the following into the file, saved and closed it on both droplets

# keepalived control files for systemd
# Incorporates fixes from RedHat bug #769726.

Description=LVS and VRRP High Availability monitor

# Ubuntu/Debian convention:
ExecStart=/usr/local/sbin/keepalived --dont-fork
ExecReload=/bin/kill -s HUP $MAINPID
# keepalived needs to be in charge of killing its own children.


I then used the following commands to set up the keepalived service
systemctl preset keepalived.service
systemctl start keepalived.service

after that I was all good to go.

Keepalived outputs to syslog. I found it very useful to check those logs to help me debug a few of these issues that I had. You can view those logs via the following command:
sudo cat /var/log/syslog

this will also include other processes as well so just keep an eye out for Keepalived or Keepalived_vrrp

Well I hope this is useful to anyone else out there in the future!

Ah, Ubuntu 16.04 uses systemd instead of upstart, so “start” isn’t a thing anymore. Instead, you can use:

sudo service keepalived start


sudo systemctl start keepalived.service

both will do the same. :)

Oh great that worked!

I am still having some issues with keepalived working but that is because my setup is a bit more involved than the one in the tutorial. I’ll figure it out eventually.

Thanks so much for your help

I am trying to run this on Ubuntu Bionic and keep seeing this :

killall5[somenumber]: only one argument, a signal number, allowed

Because of this, vrrp is not actually working and lb1 holds onto the Floating IP even if nginx is not running locally.

Here is my /etc/systemd/system/ file :
Description=Keepalive Daemon (LVS and VRRP)

Only start if there is a configuration file



Read configuration variable file if it is present

ExecStart=/usr/sbin/keepalived $DAEMON_ARGS
ExecReload=/bin/kill -HUP $MAINPID


As far as I understand it, this file is what determines what keepalived “does” under SystemD. Killmode=process is the same as under Ubuntu 16 and 14.

Has anyone else had this issue ?