Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The principle of LVS_DR mode and the configuration flow of load balancing

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following brings you the principle of LVS_DR mode and the configuration process of load balancing, hoping to bring some help to you 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.

1. Structure

Client: client IP CIP:10.3.138.126

Director: dispatcher VIP:192.168.10.200

DIP:192.168.10.128 / / Distributor Real IP

Real Server: RIP: 192.168.10.129 192.168.10.130

VIP: 192.168.10.200

2. The principle of LVS_DR mode

DR adds VIP for external access, and DR forwards the request to the server server, and adds the same VIP to the loopback network card on the server server, with a mask higher than that of the network card used, so that the ip of the data returned by the server is VIP, and the client can receive it normally. DR is different from the NET mode in that you no longer have to go through the DR dispenser when returning the packet, thus reducing the DR load. NET needs to enable routing forwarding.

3. Set up

DR and RS must be in the same physical network

1. Director dispenser configuration yum-y install ipvsadm / / ipvsadm LVS management tool RHEL ensures that the LoadBalancer repository can use ip addr add dev ens33 192.168.10.200 VIPipvsadm 32 / / configure VIPipvsadm-C / / clear all records in the kernel virtual cloud server table ipvsadm-A-t 192.168.10.200 ip addr add dev ens33 80-s rr / / add a new virtual server record to the server list-s algorithm rr polling ipvsadm-a-t 192.168 .10.200 ipvsadm 80-r 192.168.10.129-g / /-r Real server address (where to forward) ipvsadm-a-t 192.168.122.100 ipvsadm 80-r 192.168.10.130-g / /-g operating mode ipvsadm-S / / save-- -ipvsadm-Ln / / View configuration list ipvsadm-L-n-- stats / / display statistics ipvsadm-L-n-- rate / / look at rate ipvsadm-Ln-c / / View connection entries for LVS 2, RS server configures systemctl start nginx / / enables your WEB service ip addr add dev lo 192.168.122.100 / bind VIPecho 1 > / proc/sys/net/ipv4/conf/all/arp_ignore / / non-arpecho 2 > / proc/sys/net/ipv4/conf/all/arp_announce on the lo interface because the vip of realServer is available Then there are two vip in the same network segment, and the client needs to make the realServer not accept the response when the gateway sends arp broadcasts looking for vip. Solution: echo 1 > / proc/sys/net/ipv4/conf/eth0/arp_ignore arp_ignore is set to 1, which means that when someone else's arp request comes, if the receiving device does not have this ip, it will not respond (this ip is on lo, lo is not the import of the receiving device) echo 2 > / proc/sys/net/ipv4/conf/eth0/arp_announce uses the ip with the longest mask to respond. Make sure to reply with vip when you return the packet, otherwise the client requests VIP but the reply is not the requested IP. 4. Test browser: http://10.3.138.200linux terminal: after many visits by curl http://10.3.138.200

Ipvsadm-Ln-c / / look at the total number of requests, you can see the number of requests distributed by a server to see the effect.

After reading the above about the principle of LVS_DR mode and the configuration process of load balancing, if there is anything else you need to know, you can find what you are interested in in the industry information or find our professional and technical engineers to answer, technical engineers have more than ten years of experience in the industry.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report