A keepalived profile:
The keepalived software was originally designed for LVS load balancing software to manage and monitor the status of each service node in the LVS cluster, and later added the VRRP function that can achieve high availability. In addition to managing LVS software, keepalived can also be used as a high-availability solution for other services.
Keepalived software mainly implements high-availability functions through the VRRP protocol. VRRP is the abbreviation of virtual router redundancy protocol (virtual redundant routing protocol). The purpose of VRRP is to solve the problem of static routing single point of failure. It can ensure that when individual nodes go down, the entire network can run uninterrupted.
1 Working mode of VRRP
1 VRRP Virtual Redundancy Routing Protocol, to solve the single point of failure of static routing
2 Pass routing tasks to a VRRP router through the election mechanism
3 VRRP uses multicast IP and 224.0.0.18 to achieve high availability communication
4 Master node at work Send packets. When the standby node cannot receive the data packets, it will become the master node through election backup.
5 VRRP uses encrypted data, but keepalived officially wants to use plaintext username and password
6 keepalived high availability is achieved through VRRP, when keepalive is serving, only the master node accepts resources, and the standby node is in a stagnant state. When the primary node recovers, the standby node will automatically hand over the data to the primary node.
2 Three important functions of keepalived service
1 Manage LVS load balancing software
2 Implement health check function for LVS cluster nodes
3 High availability function as system network service
Two experimental preparations:
Environment:
hostname function IP address
server1 primary HA high availability 192.168.122.232
server4 backup HA high availability 192.168.122.138
server2 back-end web service 192.168.122.4
server3 back-end web service 192.168.122.10
Construction of three experimental environments
1 Package installation
1 Download this package
2 Unzip the file
3 Install related dependencies
Install ipvsadm
4 Specify the installation path
5 Check the supported functions
6 Compile and install
7 Check whether the installation is successful
8 Add configuration links, startup links and other links
9 Start the service for testing
2 High availability standby configuration:
Start the alternate server and install the scp
alternate server Install the scp
delivery configuration file package and the yum source configuration file
See if its delivery was successful
Check whether the yum source is successfully configured.
Install ipvsadm and
configure the keepalived link file:
At this point, the keepalived software installation on both sides is completed, and the next step is to enter the service configuration link
3 keepalived service configuration
1 Configure the mail server related:
configure the configuration file:
test the mail server
2 Configure high availability:
start the keepalived service on the active side to check whether the VIP is generated:
3 Configure the service cluster
Send the configuration file to the standby server
Configure the standby server
4 web server configuration
1 Install the software:
2 Configure VIP
3 Configure ARP suppression:
4 Start the httpd service
4 View VIP
Start service: VIP address has no VIP address on BACKUP on
master
5 Test high availability:
When the server stops serving:
VIP will automatically switch to the standby server
6 Detect its health check and backend scheduling:
Start the service:
when servere2 is down:
no error is reported, normal processing:
7 Configure a highly available cluster for vsftp
1 Install vsftpd on server2 and server3
configuration service file
2 Configure services on server1 and server4
The persistence_timeout configuration on the server1 side
means that a certain terminal will be accessed within 50s after the link, which ensures that the service will not jump at will.
The server4 side configuration is the same as