In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following will give you an introduction to the working principle of Keepalived and the load balancing of haproxy, hoping to give you some help in practical application. Load balancing involves many things, not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
Keepalived highly available CVM and haproxy load balancer Keepalive operating principle Keepalived detects the status of each service node when the server node is abnormal or fails, keepalived kicks the failed node from the cluster and recovers the failed node from the cluster system, automatically adds it to the HA cluster using keepalived software and configures HA cluster 1 with keepalived software. The host that provides the service needs to install keepalived and web service yum-y install httpd keepalived2. Modify the configuration file of the keepalived of the host providing the service / line 35 is the master and standby server for the high availability configuration planning of the scheduler. Set VIP (public network IP) the master / slave here is the preemptive global_defs {notification_email {acassen@firewall.com / / set alarm recipient mailbox} notification_email_from link@firewall.com / / sender mailbox smtp_server 192.168.200.1 / / mail server address smtp_connect_timeout 30 / / mail timeout router_id LVS_DEVEL / / set routing ID # vrrp_strict / / this one needs to be commented out Otherwise, the following VIP will not be able to access} vrrp_instance webha {/ / webha cluster name state MASTER / / description name. The communication between interface eth0 / / and the service hosts in the cluster uses the network card virtual_router_id 51 priority 100 / / priority. The higher the value, the higher the priority, and the higher the priority of the master. Exceeds the communication interval between the service hosts in the failed advert_int 1 / / cluster, unit second authentication {auth_type PASS / / authentication type auth_pass 1111 / / use password} virtual_ipaddress {/ / set VIP address 192.168.200.16}} when the web service down The scheduling master / slave of a highly available cluster will not float VIPvim / rootswap check.Bingray _ netstat-ntulp | grep 80 if [$?-ne 0] Thensystemctl stop keepaloved.serviceif integrated application: keepalived+LVS configuration LVS scheduler HA cluster requirements: host An is configured as the main LVS scheduler, and host B is the standby LVS scheduler. When distributor An is down, host B immediately enables 1.A, installs keepalived software on B, and ipvsadm software Yum-y install keepalived ipvsadm2. Modify / etc/keepalived/keepalived.conf modify priority division (AB) service host modify the password of the authenticated master / slave (AB) server must unanimously change the IPV (virtual_ipaddress) to 192.168.4.253 and below configuration A, B consistent virtual_server 192.168.4.253 80 {/ / define virtual dispatcher delay_loop 6 lb_algo rr / / scheduling algorithm lb_kind DR / / working mode Consistent with the working mode of the backend realserver, persistence_timeout 50 protocol TCP connect_timeout 3 nb_get_retry 3 delay_before_retry 3 real_server 192.168.4.52 80 {/ / the backend host providing web service weight 1}} this step is to set An and B as the keepalived master and standby, and add LVS (ipvsadm) to achieve the integrated application of high availability (HA) and load balancing (LB). Start and set the keepalived systemctl restart keepalived.service systemctl enable keepalived.service4 on An and B. Test on the client Curl http://192.168.4.253 premise: the machine providing web service in the background must be running echo 1 > / proc/sys/net/ipv4/conf/lo/arp_ignore echo 2 > / proc/sys/net/ipv4/conf/lo/arp_announce echo 1 > / proc/sys/net/ipv4/conf/all/arp_ignore echo 2 > / proc/sys/net/ipv4/conf/all/arp_announce ifconfig lo:1 192. 168.4.253Universe 32 extension: after the above configuration is done Keepalived will not do a health check on the back-end httpd service, if necessary Tcp connection must be checked real_server 192.168.4.52 80 {weight 1 TCP_CHECK {connect_timeout 3 nb_get_retry 3 delay_before_retry 3}} configure LB cluster working mode 1.mode http 2.mode tcp 3.mode htalthMode http1.http close with Haproxy software disconnect 2.keep immediately after each response request -alive can initiate multiple requests per connection However, multiple requests require the server to respond sequentially, a response cannot be made at one time, 3.pipelining can initiate multiple requests at a time, these request servers respond in parallel and process the requests at the same time, reducing the delay, but the requirements for the server are relatively high, configuration: 1. Pack Yum-y install haproxy2. Configuration file and introduction to Vim / etc/haproxy/haproxy.cfg default: set default parameters for subsequent parts The default parameters can be overridden by the following parts: frontend: describe the receiving client listening socket purple set backend: describe the server set that forwards the connection listen: complete declaration of combining frontend and backend / / here is the configuration of / etc/haproxy/haproxy.cfg default stats uri / admin # shows the actual situation of the LB cluster in a friendly page listen webla 192.168.4.56:80cookie SERVERID rewritebalance Roundrobinserver weba 192.168.4.55:80 cookie app1inst1 check inter 2000 rise 2 fall 5server webb 192.168.4.57:80 cookie app2inst2 check inter 2000 rise 2 fall 53. Start the service and check the status of Systemctl restart haproxy Systemctl status haproxy4. Have access to good pages
Http://192.168.4.56/admin
After reading the above introduction about the working principle of Keepalived and the load balancing of haproxy, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineer to answer it. Technical engineers have more than ten years of experience in the industry. Official website link www.yisu.com
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.