Keepalived-01-Introduction and 2020 latest compilation and installation

What is Keepalived?

Keepalived is a routing software written in C language.

The main goal of the project is to provide simple and powerful functions of load balancing and high availability for Linux systems and Linux-based infrastructures.

The load balancing framework relies on the well-known and widely used Linux Virtual Server (IPVS) kernel module that provides layer 4 load balancing .

Keepalived also implements a set of checkers to dynamically and adaptively maintain and manage load-balanced server pools based on their operating conditions. On the other hand, VRRP implements a high-availability protocol. VRRP (Virtual Router Redundancy Protoco) is the virtual router redundancy protocol, which is the basis of router failover. In addition, Keepalived also implements a set of VRRP finite state machine hooks, thereby providing low-level and high-speed protocol interaction. In order to provide the fastest network fault detection, Keepalived implements the BFD protocol. VRRP state transition can consider BFD prompt to drive fast state transition. The Keepalived framework can be used independently or together to provide a resilient infrastructure.
Image source Baidu Encyclopedia
Image source Baidu Encyclopedia

Keepalived is free software; you can redistribute and/or modify it under the terms of the GNU General Public License issued by the Free Software Foundation.

2. Installation method

1. yum installation

installation

yum install keepalived

Management Service

systemctal start keepalived

2 Source package installation

2.1 Install dependencies

yum install -y  openssl-devel libnl3-devel \
    ipset-devel iptables-devel \
    file-devel net-snmp-devel \
    pcre2-devel

2.2 Download the source package from the official website

wget https://www.keepalived.org/software/keepalived-2.1.5.tar.gz

Unzip and enter the unzipped directory

tar -xf keepalived-2.1.5.tar.gz
cd keepalived-2.1.5

2.3 Configuration

It is generally recommended to specify PREFIX when compiling from source code. For example ( 不要执行下面的命令):


./configure   --prefix=/usr/local/keepalived-2.1.5

In this way, the compiled version of Keepalived can be easily uninstalled by simply deleting the parent directory. In addition, this installation method allows multiple versions of Keepalived to be installed without overwriting each other. Use a symbolic link to point to the desired version.

For example, your directory structure might look like this:

[root@lvs1 ~]# cd /usr/local
[root@lvs1 local]# ls -l
total 12
lrwxrwxrwx. 1 root root   17 Feb 24 20:23 keepalived -> keepalived-2.1.5
drwxr-xr-x 2 root root 4096 9月  13 09:38 keepalived-1.4.5
drwxr-xr-x 2 root root 4096 9月  13 09:38 keepalived-2.0.0
drwxr-xr-x 2 root root 4096 9月  13 09:39 keepalived-2.1.0
drwxr-xr-x 6 root root 4096 9月  12 08:13 keepalived-2.1.5

Correct configuration parameters

./configure --prefix=/usr/local/keepalived-2.1.5 \
--with-run-dir=/var/run/ \
--with-default-config-file=/etc/keepalived/keepalived.conf \
--enable-dynamic-linking  \
--enable-regex --enable-regex-timers \
--enable-sha1  --enable-bfd \
--enable-snmp --enable-snmp-rfc \
--enable-snmp-checker --enable-snmp-vrrp \
--enable-snmp-keepalived 

Description of some configuration parameters

Configuration parameter Description
–with-run-dir Specify the PID file directory (the current version needs to be specified)
–enable-dynamic-linking Use dynamic link to libiptc/libipset/libnl when compiling
–enable-regex Authorized use regular
–enable-regex-timers Use HTTP_GET regex to generate timer
–enable-bfd Use BFD framework
–enable-snmp-vrrp Compile with SNMP vrrp support
–enable-snmp-checker Compile with SNMP checker support
–enable-snmp-rfc Use SNMP RFC2787 (VRRPv2) and SNMP RFC6527 compilation (VRRPv3) support
–enable-sha1 Support SHA1

2.4 Compile

Compilation is to generate related files, such as command files, configuration files, and dependent library files, according to the related parameters configured before.

make

2.5 Installation

Installation is to copy the compiled relevant files to the specified directory of the current system according to the previously configured parameters

make install

Third, the configuration after installation

1. Processing configuration files

First copy the configuration file from the installation directory to /etc/keepalivedthe directory

[root@shark etc]# cd /usr/local/keepalived-2.1.5/etc
[root@shark etc]# cp keepalived/keepalived.conf /etc/keepalived/

Modify the configuration file /etc/keepalived/keepalived.confthe following content

Original content Modified content meaning
vrrp_garp_interval 0 vrrp_garp_interval 0.001 In milliseconds, the time interval for the interface to send ARRP packets, the value should be: decimal integer or floating point number
vrrp_gna_interval 0 vrrp_gna_interval 0.000001 Delay time (in milliseconds) between NA messages actively sent on the interface

Fourth, manage keepalived service

Make sure to follow the steps above.

[root@shark ~]# systemctl start keepalived      # 启动
[root@shark ~]# systemctl status keepalived     # 查看状态
[root@shark ~]# systemctl enable keepalived     # 授权开启自动启动此服务
[root@shark ~]# systemctl stop keepalived       # 停止
[root@shark ~]# systemctl restart keepalived    # 重启

Guess you like

Origin blog.csdn.net/qq_22648091/article/details/108519773