KEEPALIVED detection RS principle, keepalivedrs Principle
The S function managed by keepalived supports health checks on the real servers of the backend nodes.
Common methods includeTcp_checkAnd http_get(More accurate)
Tcp_checkThe principle is to implement ip + port detection on the Real Server (we can use wget nmap telnet). If the corresponding port is enabled, add the forwarding table of The lvs instance (ipvsadm-a-t 192.168.1.6: 80-r 192.168.1.12: 80-g). Otherwise, delete the node.
(Ipvsadm-d-t 192.168.1.6: 80-r 192.168.1.12: 80-g)
The configuration method is as follows:
Real_server 192.168.1.11 80 {
Weight 1
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
Connect_port 80
}
}
Another way to detect backend nodes isHttp_getOr use ssl_get to verify and compare the md5 value of the accessed content. If the comparison is successful, add the lvs Forwarding Table operation. Similarly, if the verification fails, delete the node.
The configuration method is as follows:
First, define the check url and obtain the MD5dum value of the corresponding page.
[Root @ web1 bbs] # md5sum/application/nginx/html/bbs/fei.jpg
Ba45c8f60456a672e003a875e469d0eb/application/nginx/html/bbs/fei.jpg
The above marked red is the obtained MD5sum value, which will be used in the keepalived configuration file later.
Configuration method
Real_server 192.168.1.12 80 {
Weight 1
HTTP_GET {
Url {
Path/fei.jpg
Digest ba45c8f60456a672e003a875e469d0eb
}
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}
Note that bbs is the root directory of my site and the root directory location accessed by default with IP address 192.168.1.12
Therefore, the url we define is/fei.jpg. Multiple URLs can be defined at the same time. Only after all URLs are detected successfully can the node be added to the ipvs forwarding table.
The sharing is here. If you have any questions, please discuss them ~~~