lvs+keepalived

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
write picture description here
2 Unzip the file
write picture description here
3 Install related dependencies
Install ipvsadm
write picture description here

write picture description here
4 Specify the installation path
write picture description here
5 Check the supported functions
write picture description here
6 Compile and install
write picture description here
7 Check whether the installation is successful
write picture description here
8 Add configuration links, startup links and other links
write picture description here
9 Start the service for testing
write picture description here

2 High availability standby configuration:

Start the alternate server and install the scp
write picture description here
alternate server Install the scp
write picture description here
delivery configuration file package and the yum source configuration file
write picture description here

write picture description here
See if its delivery was successful
write picture description here

write picture description here
Check whether the yum source is successfully configured.
write picture description here
Install ipvsadm and
write picture description here
configure the keepalived link file:
write picture description here

write picture description here
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:
write picture description here
configure the configuration file:
write picture description here
test the mail server
write picture description here
2 Configure high availability:
write picture description here
start the keepalived service on the active side to check whether the VIP is generated:
write picture description here
3 Configure the service cluster
write picture description here
Send the configuration file to the standby server
write picture description here
Configure the standby server
write picture description here

4 web server configuration

1 Install the software:
write picture description here
2 Configure VIP
write picture description here
3 Configure ARP suppression:
write picture description here

write picture description here
4 Start the httpd service
write picture description here

4 View VIP

Start service: VIP address has no VIP address on BACKUP on
write picture description here
master
write picture description here

write picture description here

5 Test high availability:

When the server stops serving:
write picture description here
VIP will automatically switch to the standby server
write picture description here

6 Detect its health check and backend scheduling:

Start the service:
write picture description here
when servere2 is down:
write picture description here
no error is reported, normal processing:
write picture description here

7 Configure a highly available cluster for vsftp

1 Install vsftpd on server2 and server3

write picture description here
configuration service file
write picture description here

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.
write picture description here

The server4 side configuration is the same as
write picture description here

3 Service restart and view

write picture description here

4 test

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326042022&siteId=291194637