|
Packit |
c22fc9 |
Kernel needs
|
|
Packit |
c22fc9 |
==============
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Compile a kernel with the following options :
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Kernel/User netlink socket
|
|
Packit |
c22fc9 |
LinuxVirtualServer
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Keepalived supports all LVS code.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Library dependencies
|
|
Packit |
c22fc9 |
====================
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
In order to compile Keepalived needs the following libraries :
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
* OpenSSL, <www.openssl.org>
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Linux flavours
|
|
Packit |
c22fc9 |
==============
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
RedHat based systems (RedHat Enterprise/CentOS/Fedora)
|
|
Packit |
c22fc9 |
------------------------------------------------------
|
|
Packit |
c22fc9 |
The following build packages are needed:
|
|
Packit |
c22fc9 |
make
|
|
Packit |
c22fc9 |
autoconf automake (to build from git source tree rather than tarball)
|
|
Packit |
c22fc9 |
The following libraries need to be installed:
|
|
Packit |
c22fc9 |
openssl-devel libnl3-devel ipset-devel iptables-devel libnfnetlink-devel
|
|
Packit |
c22fc9 |
For magic file identification support:
|
|
Packit |
c22fc9 |
file-devel
|
|
Packit |
c22fc9 |
For SNMP support:
|
|
Packit |
c22fc9 |
net-snmp-devel
|
|
Packit |
c22fc9 |
For DBUS support:
|
|
Packit |
c22fc9 |
glib2-devel
|
|
Packit |
c22fc9 |
For JSON support:
|
|
Packit |
c22fc9 |
json-c-devel
|
|
Packit |
c22fc9 |
For PCRE support
|
|
Packit |
c22fc9 |
pcre2-devel
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
For building the documentation, the following packages need to be installed:
|
|
Packit |
c22fc9 |
Fedora: python-sphinx (will pull in: python2-sphinx_rtd_theme)
|
|
Packit |
c22fc9 |
CentOS-and-friends: python-sphinx epel-release python-sphinx_rtd_theme
|
|
Packit |
c22fc9 |
For latex or pdf files, the following are also needed:
|
|
Packit |
c22fc9 |
Fedora: latexmk python-sphinx-latex
|
|
Packit |
c22fc9 |
CentOS-and-friends: latexmk texlive texlive-titlesec texlive-framed texlive-threeparttable texlive-wrapfig texlive-multirow
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Debian/Ubuntu
|
|
Packit |
c22fc9 |
-------------
|
|
Packit |
c22fc9 |
On Debian, install:
|
|
Packit |
c22fc9 |
pkg-config
|
|
Packit |
c22fc9 |
On Ubuntu, install:
|
|
Packit |
c22fc9 |
build-essential pkg-config, and to build from git repo automake autoconf
|
|
Packit |
c22fc9 |
The following libraries need to be installed:
|
|
Packit |
c22fc9 |
iptables-dev libipset-dev libnfnetlink-dev libnl-3-dev libnl-genl-3-dev libssl-dev
|
|
Packit |
c22fc9 |
For magic file identification support:
|
|
Packit |
c22fc9 |
libmagic-dev
|
|
Packit |
c22fc9 |
For SNMP support:
|
|
Packit |
c22fc9 |
libsnmp-dev
|
|
Packit |
c22fc9 |
For DBUS support:
|
|
Packit |
c22fc9 |
libglib2.0-dev
|
|
Packit |
c22fc9 |
For JSON support:
|
|
Packit |
c22fc9 |
libjson-c-dev
|
|
Packit |
c22fc9 |
For PCRE support:
|
|
Packit |
c22fc9 |
libpcre2-dev
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
For building the documentation, the following packages need to be installed:
|
|
Packit |
c22fc9 |
python-sphinx python-sphinx-rtd-theme
|
|
Packit |
c22fc9 |
For latex or pdf files, the following are also needed:
|
|
Packit |
c22fc9 |
texlive-latex-base texlive-generic-extra texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Alpine Linux
|
|
Packit |
c22fc9 |
------------
|
|
Packit |
c22fc9 |
The following libraries need to be installed:
|
|
Packit |
c22fc9 |
iptables-dev ipset-dev libnfnetlink-dev libnl3-dev musl-dev and openssl-dev or libressl-dev
|
|
Packit |
c22fc9 |
For magic file identification support:
|
|
Packit |
c22fc9 |
TBD
|
|
Packit |
c22fc9 |
For SNMP support:
|
|
Packit |
c22fc9 |
net-snmp-dev (requires libressl-dev and not openssl-dev)
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
For building the documentation, the following packages need to be installed:
|
|
Packit |
c22fc9 |
py-sphinx py3-sphinx_rtd_theme
|
|
Packit |
c22fc9 |
For latex or pdf files, you'll need texlive or similar, which is not yet
|
|
Packit |
c22fc9 |
available as a distro package.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Archlinux
|
|
Packit |
c22fc9 |
---------
|
|
Packit |
c22fc9 |
Run the following to install the required libraries:
|
|
Packit |
c22fc9 |
pacman -S ipset libnfnetlink libnl1
|
|
Packit |
c22fc9 |
For magic file identification support:
|
|
Packit |
c22fc9 |
TBD
|
|
Packit |
c22fc9 |
For SNMP support:
|
|
Packit |
c22fc9 |
pacman -S net-snmp
|
|
Packit |
c22fc9 |
for PCRE support:
|
|
Packit |
c22fc9 |
pcre-2 (may be installed by default)
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
For building the documentation, the following packages need to be installed:
|
|
Packit |
c22fc9 |
python-sphinx python-sphinx_rtd_theme
|
|
Packit |
c22fc9 |
For latex or pdf files, the following are also needed:
|
|
Packit |
c22fc9 |
texlive-core texlive-bin texlive-latexextra
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Kernel configuration requirements
|
|
Packit |
c22fc9 |
---------------------------------
|
|
Packit |
c22fc9 |
The following list is probably incomplete, and will be updated as other
|
|
Packit |
c22fc9 |
options become known.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
BPF
|
|
Packit |
c22fc9 |
EPOLL
|
|
Packit |
c22fc9 |
SIGNALFD
|
|
Packit |
c22fc9 |
TIMERFD
|
|
Packit |
c22fc9 |
SYSCTL
|
|
Packit |
c22fc9 |
PROC_FS
|
|
Packit |
c22fc9 |
INET
|
|
Packit |
c22fc9 |
IP_MULTICAST
|
|
Packit |
c22fc9 |
IPV6
|
|
Packit |
c22fc9 |
IP_VS (unless --disable-lvs is specified)
|
|
Packit |
c22fc9 |
IP_VS suboptions to match the real_server/virtual_server configuration
|
|
Packit |
c22fc9 |
NETFILTER_XTABLES - if strict_mode or no_accept.
|
|
Packit |
c22fc9 |
NETFILTER_XT options and IP_SET
|
|
Packit |
c22fc9 |
IP_ADVANCED_ROUTER and various associated options if static/dynamic routes specified
|
|
Packit |
c22fc9 |
FIB_RULES if static or dynamic rules are specified
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Installing from a git repo
|
|
Packit |
c22fc9 |
==========================
|
|
Packit |
c22fc9 |
To install from a git repo, execute:
|
|
Packit |
c22fc9 |
1. Ensure you have autoconf and automake installed
|
|
Packit |
c22fc9 |
2. git clone http://github.com/acassen/keepalived
|
|
Packit |
c22fc9 |
3. cd keepalived
|
|
Packit |
c22fc9 |
4. ./build_setup # generate the autoconf and automake environment
|
|
Packit |
c22fc9 |
5. Follow the instructions below for Installation, omitting the first two steps.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Installation
|
|
Packit |
c22fc9 |
============
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
1. tar -xf TARFILE
|
|
Packit |
c22fc9 |
2. cd into the directory
|
|
Packit |
c22fc9 |
3. './configure'
|
|
Packit |
c22fc9 |
4. 'make'
|
|
Packit |
c22fc9 |
5. 'make install'. This will install keepalived on your system,
|
|
Packit |
c22fc9 |
binaries and configuration file :
|
|
Packit |
c22fc9 |
* keepalived : The keepalived daemon program.
|
|
Packit |
c22fc9 |
* genhash : The MD5 url digest generator. You need it to
|
|
Packit |
c22fc9 |
configure HTTP GET check and SSL GET check in
|
|
Packit |
c22fc9 |
order to compute MD5SUM digest etalon.
|
|
Packit |
c22fc9 |
* /etc/keepalived/keepalived.conf
|
|
Packit |
c22fc9 |
6. link keepalived.init into your runlevel directory. On Red Hat systems :
|
|
Packit |
c22fc9 |
ln -s /etc/rc.d/init.d/keepalived.init /etc/rc.d/rc3.d/S99keepalived
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
By default the configure script uses /usr/local as base directory. You can
|
|
Packit |
c22fc9 |
change this value to your own by passing it the --prefix value.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
eg: './configure --prefix=/usr/'
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Building RPM files
|
|
Packit |
c22fc9 |
==================
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
If building from tarball:
|
|
Packit |
c22fc9 |
1a. tar -xf TARFILE
|
|
Packit |
c22fc9 |
1b. cd into the directory
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
If building from git clone:
|
|
Packit |
c22fc9 |
1. ./build_setup
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
For tarball and git
|
|
Packit |
c22fc9 |
2. ./configure
|
|
Packit |
c22fc9 |
3. make rpm
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
The .rpm files will be created in directory `rpm --eval "%{_rpmdir}"`/ARCH
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Modifying source code
|
|
Packit |
c22fc9 |
=====================
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
If you modify the source code, especially configure.ac or any Makefile.am
|
|
Packit |
c22fc9 |
file, you will need to regenerate the build files. Keepalived uses automake
|
|
Packit |
c22fc9 |
and so you will need to have automake and autoconf installed.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Configuration
|
|
Packit |
c22fc9 |
=============
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Just take a look at the /etc/keepalived/keepalived.conf file installed.
|
|
Packit |
c22fc9 |
It will give you all the information needed. Alternativley, run
|
|
Packit |
c22fc9 |
'man keepalived.conf' or look at doc/keepalived.conf.SYNOPSIS.
|
|
Packit |
c22fc9 |
If you want more information about keepalived, please refer to the
|
|
Packit |
c22fc9 |
keepalived homepage into the documentation section.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
http://www.keepalived.org
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Creating a docker container
|
|
Packit |
c22fc9 |
===========================
|
|
Packit |
c22fc9 |
There is a very useful github project maintained by osixia for building a
|
|
Packit |
c22fc9 |
docker container with keepalived.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
To use, run the following:
|
|
Packit |
c22fc9 |
git clone https://github.com/osixia/docker-keepalived.git
|
|
Packit |
c22fc9 |
cd docker-keepalived
|
|
Packit |
c22fc9 |
make build
|
|
Packit |
c22fc9 |
docker run --name keepalived --cap-add=NET_ADMIN --net=host \
|
|
Packit |
c22fc9 |
--env KEEPALIVED_INTERFACE=eth0 -d osixia/keepalived:1.3.5 \
|
|
Packit |
c22fc9 |
# or whatever version of keepalived you have
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
To update the keepalived source code, put a new tarball in the image
|
|
Packit |
c22fc9 |
directory (the Dockerfile may need updating with a new version).
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Useful docker commands are:
|
|
Packit |
c22fc9 |
docker logs keepalvied 2>&1 | lessa # view system logs of container
|
|
Packit |
c22fc9 |
docker exec it keepalived bash # execute shell in container
|
|
Packit |
c22fc9 |
docker rm -f keepalived # Remove the container
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
keepalived is unable to load the ip_tables, ip6_tables, xt_set and ip_vs
|
|
Packit |
c22fc9 |
modules from within the container, so ensure they are already loaded in
|
|
Packit |
c22fc9 |
the host system.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
To generate a core file in the root filesystem of the container,
|
|
Packit |
c22fc9 |
/proc/sys/kernel/core_pattern needs to be updated in the host system,
|
|
Packit |
c22fc9 |
and not from the container (or in other words the -M option to keepalived
|
|
Packit |
c22fc9 |
does not work within a container. Installing gdb in the container (edit
|
|
Packit |
c22fc9 |
the image/Dockerfile to add it before make build) may be helpful if you
|
|
Packit |
c22fc9 |
need to examine core files in the container.
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Have fun with it !
|
|
Packit |
c22fc9 |
|
|
Packit |
c22fc9 |
Alexandre, <acassen@linux-vs.org>
|