|
Keepalived software is mainly through the VRRP protocol to achieve high-availability features. VRRP is the acronym for Virtual Router Redundancy Protocol (VRRP), VRRP appeared in order to solve the problem of static routes with a single point of failure, which ensures that when an individual node is down, the whole network can be uninterrupted operation. Therefore, Keepalived on the one hand has the function of configuration and management of LVS, but also has the function of health checking the nodes below the LVS, on the other hand, it can also realize the function of high availability of the system network services.
Keepalived Highly Available Failover Principle
The failover transfer between Keepalived highly available service pairs is realized through VRRP (Virtual Router Redundancy Protocol).
When the Keepalived service is working normally, the master node sends heartbeat messages to the backup node to tell the backup node that it is still alive. When the master node fails, it can't send heartbeat messages, and the backup node can't detect heartbeats coming from the master node. When the master node fails, it cannot send heartbeat messages, and the backup node cannot detect the heartbeat from the master node, so it calls its own takeover program to take over the IP resources and services of the master node. When the master node recovers, the backup node releases the IP resources and services it took over when the master node failed and returns to its original standby role.
Keepalived high availability pairs communicate with each other through VRRP.
(1) VRRP, full name Virtual Router Redundancy Protocol, Chinese name for Virtual Route Redundancy Protocol, VRRP appeared in order to solve the static route of a single point of failure. (2) VRRP is a campaign protocol mechanism to give routing tasks to a particular VRRP router. 3) VRRP uses IP multicast ( default multicast address (224.0.0.18) ) to realize communication between highly available pairs. 4) When working, the master node sends packets and the backup node receives packets. When the backup node cannot receive the packets sent by the master node, it starts the takeover program to take over the resources of the master node. The backup node can have more than one, through the priority campaign, but generally Keepalived system operation and maintenance work is a pair. (5) VRRP uses a cryptographic protocol to encrypt data. but Keepalived officials still recommend configuring authentication types and passwords in plaintext.
How the Keepalived service works
(1) Keepalived highly available pairs are communicating with each other through VRRP. VRRP determines the master and the backup through the election mechanism, and the priority of the master is higher than that of the backup, so the master will have priority to obtain all the resources at work, and the backup node is in a waiting state. When the master hangs up, the backup node will take over the resources of the master node, and then take over from the master node to provide services to the outside world.
(2) In the Keepalived service pairs, only the server as the master will keep sendingVRRPbroadcast packets to tell the backup that it is still alive, at this time, the backup will not seize the master, when the master is not available, i.e., the backup can't listen to the broadcast packets sent by the master, it will start the related services to take over the resources, to ensure the continuity of the service. The fastest takeover speed can be less than 1 second.
Test Environment
System: CentOS 8
IP Address | Description | 192.168.50.222 | VIP Address | 192.168.50.227 | MASTER Master Node | 192.168.50.131 | BACKUP Standby node |
Let's look at the finished build as follows:
Install the Nginx service
Use yum to install nginx directly on the primary and standby node servers with the following commands:
Edit the nginx configuration files of the master and standby nodes respectively at /etc/nginx/nginx.conf with the following configuration:
Start the nginx command and test accessing port 8055 through a browser as shown below:
Install Keepalived Install on both servers, the primary and standby nodes, with the following commands:
Configuration file address: /etc/keepalived/keepalived.conf
Here you need to configure a health check script, create a new chk_nginx.sh file with the following code:
Upload the script to the /etc/keepalived directory. Upload the script to the /etc/keepalived directory and give it execute permission with the following command:
192.168.50.227 The master node keepalived.conf is configured as follows:
192.168.50.133 The standby node keepalived.conf is configured as follows:
Set up power-on startup on each of the two servers and start the
At this point, the configuration is complete (see the top of the article for the effect), you can test through the nginx service, the command is as follows:
(end) |
Previous: OpenFeign connect timed out executing exceptionNext:Stumble upon the site
|