[Install keepalived]
1. Download keepalived.
Wget http://www.keepalived.org/software/keepalived-1.2.13.tar.gz
2. Compile and install
Yum install-y gcc openssl-devel ipvsadm libnl-devel
Tar zxvf keepalived-1.2.13.tar.gz
Cd keepalived-1.2.13
./Configure -- sysconfdir =/etc & make install
Libnl is a library developed to facilitate applications to use the netlink interface. This library provides a unified interface for original netlink message transmission and different netlink family-specific interfaces.
If the SO_MARK header cannot be found, the kernel version is too low. You can choose to disable or upgrade the Kernel Compilation parameters.
Keepalived configuration]
1. Firewall configuration
The MASTER node sends VRRP packets in the form of IP multicast (multicast address: 224.0.0.18), and maintains heartbeat connection with the BACKUP node. If the MASTER node is unavailable (or the BACKUP node cannot receive the VRRP packet ), BACKUP generates a new MASTER by running for election and continues to provide the routing service to external users to achieve high availability. Firewall configuration:
Iptables-I INPUT-d 224.0.0.0/8-j ACCEPT
Iptables-a input-p vrrp-j ACCEPT
2. Application Configuration
Keepalived configurations are written in the configuration file, and many configurations are supported. There are roughly three types: global configuration, vrrp configuration, and lvs configuration. (Lvs configuration can be omitted, if not used)
Global configuration:
! Configuration File for keepalived
Global_defs {
Notification_email {
Acassen@firewall.loc
Failover@firewall.loc
Sysadmin@firewall.loc
}
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server 192.168.200.1
Smtp_connect_timeout 30
Router_id LVS
}
# Configure sendmail here. If you do not need sendmail, omit the following:
! Configuration File for keepalived
Global_defs {
Router_id LVS
}
Vrrp configuration:
This part is divided into two parts: synchronization group and instance group.
A synchronization group enables direct state synchronization switching between several instances. For example, when there are two NICs (one public network and one intranet), for example, if the health check is performed on the intranet, but the public network fails, a problem may occur. After synchronization, the status can be synchronized.
This is generally useless.
The instance group configuration is as follows:
# The initial state of the state value vrrp.
# Interface indicates the bound interface.
# Virtual_router_id indicates the vrrp id
# Priopity indicates the weight value
# Advert_int check comments
# Authentication indicates authentication
Virtual_ipaddress indicates the bound address.
# Notify is the script for notifying the call.
Lvs:
Lvs default load modes include rr | wrr | lc | wlc | lblc | sh | dh.
Health check method HTTP_GET | SSL_GET | TCP_CHECK | SMTP_CHECK | MISC_CHECK
Scheduling mode NAT | DR | TUN
Many suggestions for the configuration here refer to the samples configuration in the compilation package.
Start the default configuration.
Well, do not add -- enable-debug during compilation, or your doll will suffer.