A method, device and system for LVS system deployment adjustment based on keepalived
By deploying keepalived components and master-slip mode in the LVS system, the problems of load balancing node failure and low scheduling algorithm efficiency are solved, and the system's high availability and load balancing efficiency are improved, avoiding RS server downtime.
Patent Information
- Application Number
- CN202110804895.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-16
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-07-16
AI Technical Summary
The LVS system has high risk when the load balancing node fails, the scheduling algorithm is inefficient and prone to downtime, which may cause the RS server node to go down, affecting the overall system reliability and performance.
Deploy keepalived components in the LVS system to realize the main and backup mode of the load balancing node, periodically update the traffic allocation weight of the physical server node, and dynamically adjust the traffic distribution based on the current load information to ensure that the load balancer switches in time in the event of a failure and Optimize traffic distribution.
It improves the reliability and load balancing and regulation efficiency of the LVS system, avoids the downtime of RS server nodes, and enhances the high availability and user experience of the system.
Smart Images

Figure CN113709054B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of LVS deployment, and in particular to a method, device and system for LVS system deployment adjustment based on keepalived. Background Art
[0002] In the LVS (Linux Virtual Server) system in DR (Direct Routing) mode, the load balancer dynamically selects an RS (Real Server) server based on the load of each RS. It does not modify or encapsulate the IP message, but directly modifies the target MAC address (Media Access Control Address or Ethernet address) of the data frame to the MAC address of the selected server, and then sends the modified data frame on the local area network of the server group.
[0003] Because the MAC address of the data frame is the MAC address of the selected server, the RS server can receive the data frame and obtain the IP message from it. When the RS server finds that the target address VIP (Virtual IP) of the message is on the local network device, the RS server will process the message and then return the corresponding message directly to the user according to the routing table.
[0004] However, during the construction of the LVS system in DR mode, a single load balancer will face the problem of single point failure. Once the load balancer goes down and cannot forward requests from the client, the entire service will be unavailable to the client. In addition, there are many scheduling algorithms that have been implemented in the current LVS. Taking the weighted least connection algorithm (WLC) as an example, the weighted least connection algorithm (WLC) has high efficiency and practicality. The weighted least connection algorithm is an improvement on the minimum connection algorithm. The core of the algorithm is: set a weight Wi for each RS server, which represents the performance of the RS server. The larger the weight, the better the performance. When the load balancer allocates requests, it will search for the server node with the smallest ratio of the number of connections to the weight in all RS server lists when Wi is not zero. If the RS server node cannot be found, NULL will be returned.
[0005] The specific implementation principle of the WLC algorithm is as follows: If a group of RS servers is represented by {S0, S1, S2..., Sn-1}, W(Si) represents the weight of RS server node Si, and C(Si) represents the current number of connections of server node Si, then the total number of current connections of the RS server is Csum=∑C(Si), (i=0, 1, 2..., n-1), and the node selected by the load balancer from the cluster is Sm, then the selected RS server node should satisfy: (C(Sm) / Csum) / W(Sm)=min{(C(Si) / Csum) / W(Si)}. Csum is a constant in the formula, so the formula can be simplified to C(Sm) / W(Sm)=min{C(Si) / W(Si)}. Since the weight of each RS server node in the RS server pool is greater than zero, and the performance consumption of division operation is greater than that of multiplication operation, the formula can be written as C(Sm)*W(Si)>C(Si)*W(Sm).
[0006] Although the WLC algorithm is highly efficient and practical, it has the following two disadvantages: 1) The weights of all RS servers are configured by the administrator rather than by the load status of the node itself. This weight configuration method that relies on the administrator's experience may lead to a decrease in server efficiency, which in turn affects the entire server cluster; 2) After the weight allocation of each RS server is completed, the performance of the node with a large weight in the cluster may decrease as the number of assigned tasks increases. At this time, if the weight is not changed dynamically and tasks are continued to be assigned to the RS server node, it may cause the RS server node to crash. Summary of the invention
[0007] In order to solve the problems existing in the prior art, the present invention innovatively proposes a LVS system deployment and adjustment method, device and system based on keepalived, which effectively solves the problems of high risk of load balancing node failure during LVS system construction caused by the prior art, and low scheduling efficiency and easy downtime of the load balancing scheduling algorithm, effectively improves the reliability of LVS system deployment and adjustment and the load balancing adjustment efficiency, and avoids RS server node downtime.
[0008] A first aspect of the present invention provides a method for adjusting LVS system deployment based on keepalived, comprising:
[0009] Build and deploy an LVS system, and install keepalived components on the first load balancing node and the second load balancing node in the LVS system, wherein the first load balancing node and the second load balancing node complete the traffic distribution task in the master-slave mode;
[0010] The load balancing node currently performing the traffic distribution task periodically obtains the current traffic distribution weight of each physical server node in the LVS system;
[0011] Determine whether the difference between the current traffic distribution weight of the physical server node and the last stored traffic distribution weight is greater than the preset update write weight; if greater, update the current traffic distribution weight of the physical server node to the load balancing node currently executing the traffic distribution task;
[0012] The load balancing node currently executing the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update.
[0013] Optionally, building and deploying an LVS system, and installing the keepalived component on both the first load balancing node and the second load balancing node in the built LVS system specifically includes:
[0014] Create multiple virtual machine nodes, where the first virtual machine node is a first load balancer node, the second virtual machine node and the third virtual machine node are both physical server nodes, and the fourth virtual machine node is a second load balancer node;
[0015] Based on the LVS system, respectively configure the target addresses of the first virtual machine node, the second virtual machine node, and the third virtual machine node;
[0016] The first load balancing node is set as the primary load balancing node, and the second load balancing node is set as the backup load balancing node. When the first load balancing node goes down, the second load balancing node will take over the traffic distribution task.
[0017] Optionally, the current traffic distribution weight of the physical server node is determined by current load information of the physical server node.
[0018] Furthermore, the load information of the physical server node includes: CPU utilization in the physical server node, memory utilization in the physical server node, and network bandwidth utilization in the physical server node.
[0019] Furthermore, the current traffic distribution weight of the physical server node is determined by the current load information of the physical server node:
[0020] F(Sinew)=A(Kcpu(1-CPU_USEnew)+Kmem(1-MEM_USEnew)+Kband(1-BAND_USEnew))
[0021] Among them, F(Sinew) is the current traffic allocation weight of the physical server node, CPU_USEnew is the current utilization of the CPU in the physical server node, MEM_USEnew is the current utilization of the memory in the physical server node, and BAND_USEnew is the current utilization of the network bandwidth in the physical server node; Kcpu is the influence factor of CPU utilization on the physical server node allocation weight, Kmem is the influence factor of memory utilization on the physical server node allocation weight, Kband is the influence factor of network bandwidth utilization on the physical server node allocation weight, the sum of Kcpu, Kmem, and Kband is 1, and A is the reference coefficient for adjusting the weight change.
[0022] Furthermore, if any of the current utilization of the CPU in the physical server node, the current utilization of the memory in the physical server node, and the current utilization of the network bandwidth in the physical server node is greater than a preset utilization threshold, the current traffic allocation weight of the physical server node is 0.
[0023] Optionally, the preset update write weight is determined by the load information of the physical server, specifically the product of the adjustment reference coefficient of the weight change and the preset update write weight factor, wherein the preset update write weight factor is specifically:
[0024] B=Kcpu*|CPU_USEnew-CPU_USEold|+Kmem*|MEM_USEnew-MEM_USEold|+Kband*|BAND_USEnew-BAND_USEold|
[0025] Among them, B is the preset update write weight factor, CPU_USEnew is the current utilization of the CPU in the physical server node, CPU_USEold is the utilization of the CPU in the physical server node corresponding to the last storage; MEM_USEnew is the current utilization of the memory in the physical server node, MEM_USEold is the utilization of the memory in the physical server node corresponding to the last storage; BAND_USEnew is the current utilization of the network bandwidth in the physical server node, BAND_USEold is the utilization of the network bandwidth in the physical server node corresponding to the last storage.
[0026] Optionally, the load balancing node currently executing the traffic distribution task executes the traffic distribution task specifically as follows according to the traffic distribution weight of the physical server node written in the most recent update:
[0027] The load balancing node currently executing the traffic distribution task obtains the traffic distribution weight of the physical server node that was last updated and written;
[0028] Determine the physical server node with the largest traffic allocation weight, and preferentially allocate the traffic distribution task to be executed to the physical server node with the largest traffic allocation weight.
[0029] A second aspect of the present invention provides a LVS system deployment adjustment device based on keepalived, including:
[0030] Build a module, build and deploy the LVS system, and install the keepalived component on the first load balancing node and the second load balancing node in the built LVS system. The first load balancing node and the second load balancing node complete the traffic distribution task in the master-slave mode;
[0031] The acquisition module, the load balancing node currently performing the traffic distribution task, periodically obtains the current traffic distribution weight of each physical server node in the LVS system;
[0032] A judgment module determines whether the difference between the current traffic distribution weight of the physical server node and the corresponding traffic distribution weight at the last storage is greater than a preset update write weight; if greater, the current traffic distribution weight of the physical server node is updated and written to the load balancing node currently executing the traffic distribution task;
[0033] The distribution module, the load balancing node currently executing the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update.
[0034] The third aspect of the present invention provides an LVS system deployment and adjustment system based on keepalived, comprising: a first physical server node, a second physical server node, a first load balancing node, and a second load balancing node; keepalived components are installed on the first load balancing node and the second load balancing node, wherein the first load balancing node and the second load balancing node complete the traffic distribution task in a master-slave mode;
[0035] The first load balancing node and the load balancing node that currently executes the traffic distribution task in the second load balancing node periodically obtain the current traffic distribution weight of each physical server node in the LVS system; determine whether the difference between the current traffic distribution weight of the physical server node and the corresponding traffic distribution weight at the time of the last storage is greater than the preset update write weight; if greater, update the current traffic distribution weight of the physical server node and write it into the load balancing node that currently executes the traffic distribution task; execute the traffic distribution task according to the traffic distribution weight of the physical server node that was most recently updated and written.
[0036] The technical solution adopted by the present invention includes the following technical effects:
[0037] 1. The present invention effectively solves the problems of high risk of load balancing node failure during LVS system construction caused by the prior art, and low scheduling efficiency and easy downtime of the load balancing scheduling algorithm, effectively improves the reliability of LVS system deployment adjustment and load balancing adjustment efficiency, and avoids RS server node downtime.
[0038] 2. In the technical solution of the present invention, keepalived components are deployed in the first load balancing node and the second load balancing node. The working modes of the first load balancing node and the second load balancing node are master-slave mode. When one of the load balancing nodes goes down, another load balancing node can take over in time, thereby improving the reliability of LVS system load balancing and improving user experience.
[0039] 3. In the technical solution of the present invention, the load balancing node that currently executes the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node that was last updated and written; the traffic distribution weight of the current physical server node is determined by the current load information of the physical server node, and the traffic distribution weight can be adjusted according to the current load information of the physical server node, so that when the load balancing node that executes the traffic distribution task distributes traffic, it can be dynamically adjusted according to the current load situation of the physical server, thereby improving the accuracy of load balancing adjustment.
[0040] 4. In the technical solution of the present invention, it is determined whether the difference between the current traffic distribution weight of the physical server node and the traffic distribution weight stored last time is greater than the preset update write weight; if greater, the current traffic distribution weight of the physical server node is updated and written to the load balancing node that is currently executing the traffic distribution task; it is realized that according to the load change of the physical server node, it is determined whether to update the current traffic distribution weight of the physical server and write it to the load balancing node that is executing the traffic distribution task, thereby avoiding updating and writing new traffic distribution weights of all physical server nodes in each cycle, which makes the load balancer overloaded, and improves the reliability of load balancer adjustment.
[0041] 5. According to the technical solution of the present invention, if any one of the CPU utilization, memory utilization, and network bandwidth utilization in the physical server node is greater than a preset utilization threshold, the traffic distribution weight of the physical server node is 0, thereby avoiding overload or even downtime of the physical server node and improving the reliability of load balancing adjustment of the load balancer (the load balancing node that is performing traffic distribution tasks).
[0042] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 It is a structural diagram of the OSI network model in the first embodiment of the solution of the present invention;
[0045] Figure 2 This is a schematic diagram of the LVS network topology structure in Example 1 of the solution of the present invention;
[0046] Figure 3 This is a schematic diagram of a process of a method in Example 1 of the present invention;
[0047] Figure 4 Schematic diagram of the process of step S1 in the method of embodiment 1 of the present invention;
[0048] Figure 5 Schematic diagram of the process of step S6 in the method of embodiment 1 of the present invention;
[0049] Figure 6 This is a schematic diagram of the structure of the device in Example 2 of the present invention;
[0050] Figure 7 This is a schematic diagram of the structure of the system of Example 3 in the solution of the present invention. DETAILED DESCRIPTION
[0051] In order to clearly illustrate the technical features of the present solution, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings. The disclosure below provides many different embodiments or examples for realizing different structures of the present invention. In order to simplify the disclosure of the present invention, the components and settings of specific examples are described below. In addition, the present invention may repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed. It should be noted that the components illustrated in the accompanying drawings are not necessarily drawn to scale. The present invention omits the description of known components and processing techniques and processes to avoid unnecessary limitations on the present invention.
[0052] Embodiment 1
[0053] OSI (Open System Interconnect), also known as the OSI reference model, is a network interconnection model developed by ISO (International Organization for Standardization) in 1985. In order to make network applications more popular, ISO introduced the OSI reference model, which means that all companies are recommended to use this specification to control the network. In this way, all companies have the same specifications and can be interconnected.
[0054] like Figure 1 As shown in the figure, OSI defines a seven-layer framework for network interconnection (physical layer, data link layer, network layer, transport layer, session layer, presentation layer, and application layer), namely the ISO open interconnection system reference model.
[0055] Each layer implements its own functions and protocols, and completes the interface communication with the adjacent layer. The OSI service definition details the services provided by each layer. The service of a certain layer is a capability of the layer and the layers below it, which is provided to the higher layer through the interface.
[0056] When host A wants to send a data packet to host B, it will first encapsulate the data packet layer by layer. The so-called encapsulation is to add the corresponding data header at each layer. The main information added by the transport layer is the source port number and the destination port number, the network layer mainly adds the source IP address and the destination IP address, and the data link layer mainly adds the source MAC address and the destination MAC address. Assuming that host A and host B are not in the same network segment, the following process will be experienced during the sending period:
[0057] 1) Since A now only knows B's IP address but not B's MAC address, and the Layer 2 device switch does not forward data according to the IP address, host A will send an ARP (Address Resolution Protocol, a TCP / IP protocol that obtains the physical address based on the IP address; when a host sends information, it broadcasts an ARP request containing the target IP address to all hosts on the local area network and receives a return message to determine the target's physical address; after receiving the return message, the IP address and physical address are stored in the local ARP cache and retained for a certain period of time. The next time a request is made, the ARP cache is directly queried to save resources) broadcast, with the source IP address being the IP address of host A and the source MAC address being the MAC address of host A; the target IP address being the IP address of host B and the target MAC address being FF:FF:FF:FF:FF:FF, indicating that the queried IP address is the MAC address of host B.
[0058] 2) When the switch receives the broadcast frame through port F1, it will forward it to all other ports and add the source MAC address of the frame (i.e. the MAC address of host A) to its own MAC address table.
[0059] 3) After host B receives the ARP broadcast frame, it compares it with its own IP. If a match is found, it responds to host A's ARP request frame with A as the target MAC address.
[0060] 4) After the switch receives the reply frame from host B through port F2, it compares the target MAC address of the frame with its own MAC address table and finds that the port corresponding to the frame is F1, so it forwards the frame to port F1 (if the target MAC address of the data frame does not exist in the table, it will be forwarded to all ports except the source port), and adds the source MAC address of the frame (that is, the MAC address of host B) to its own MAC address table.
[0061] 5) After host A receives the reply frame from host B, it obtains the MAC address of host B, and then saves this information to the local ARP cache. At the same time, it encapsulates the data to be transmitted into a frame with host B's MAC address as the target address and sends it out.
[0062] 6) The switch receives the data frame from host A again and finds that the destination MAC address is the MAC address of host B, and the port corresponding to the address is F2, so it forwards the data to port F2.
[0063] 7) Host B successfully receives the data sent by Host A.
[0064] In actual production environments, manufacturers often use server clusters to handle large numbers of requests. Due to various factors such as user habits, uneven loads often occur in server clusters. Consider the following scenario:
[0065] There are three communities with different work and rest schedules, namely daytime work, nighttime work, and leisure time work. Each of these three communities is bound to a server to use a certain network service. If load balancing is not used, each community will only use the server it is bound to, which will cause one server to be almost idle in a day, causing waste, and one server to be under huge access pressure, increasing the risk of downtime.
[0066] LVS (Linux Virtual Server) is a Linux virtual server. It works at the network layer and has been integrated into the Linux kernel module. It implements an IP-based data request load balancing scheduling solution in the Linux kernel. Because it works at the network layer, it is much more efficient than other load balancing solutions, such as DNS (Domain Name System) domain name rotation resolution, application layer load scheduling, client scheduling, etc.
[0067] The network topology of LVS is as follows: Figure 2 As shown in the figure. The load balancing scheduler is the core of LVS. It maintains the real IP addresses (RIP) of all real servers (i.e. physical servers) RS (Real Server) internally, and only exposes a virtual VIP (Virtual IP) to the client to receive all client requests. After receiving the request from the client, the load balancer distributes the request data packet to multiple real servers RS at the back end through a balancing algorithm, and the RS server processes and responds to the request.
[0068] Since the source IP in the data packet sent by the client is the local IP and the target IP is the VIP, the source IP in the received response packet must be the VIP and the target IP must be the local IP, so that the client will receive and continue to process the data packet, otherwise it will discard the data packet. In order to enable the client and RS to communicate normally, LVS has the following three working modes:
[0069] (1) VS / NAT (Virtual Server via Network Address Translation) mode:
[0070] When a client accesses a VIP, the request message arrives at the load balancer. The load balancer selects a server from a group of RSs based on the scheduling algorithm, rewrites the target address of the message to the address of the selected server, rewrites the target port of the message to the corresponding port of the selected server, and finally sends the modified message to the selected server. At the same time, the load balancer maintains a connection table internally, records this connection in the table, and when the next message of this connection arrives, the address and port of the originally selected server can be obtained from the connection table, and the same rewrite operation is performed, and the message is sent to the originally selected server. When the response message from the real server passes through the load balancer, the load balancer changes the source address and source port of the message to the VIP and the corresponding port, and then sends the message to the user.
[0071] (2) VS / TUN (Virtual Server via IP Tunneling) mode:
[0072] In VS / NAT mode, both request and response data need to pass through the load balancer. When the number of RS is large, the load balancer will become the bottleneck of the entire system. Most network services have a characteristic that the request message sends very little data, but the response message often contains a large amount of data, and the bandwidth of the load balancing server is limited. Therefore, when the number of RS is large, so many RIPs use one network cable to return data, which will cause a bottleneck in system performance.
[0073] The solution of VS / TUN mode to the above bottleneck is mainly its different message forwarding method. The load balancer dynamically selects a server according to the load situation of each RS, encapsulates the request message into another IP message, and then forwards the encapsulated new IP message to the selected server. After receiving the message, RS first unpacks the message to obtain the message with the original target address as VIP. When the server finds that the VIP address is configured on the local IP tunnel device, it will process the request and then return the corresponding message directly to the user according to the routing table.
[0074] In VS / TUN mode, the destination address of the request message is VIP, and the source address of the response message is also VIP, so the response message does not need to be modified and can be directly returned to the user.
[0075] (3) VS / DR (Virtual Server via Direct Routing) mode:
[0076] Compared with the above two modes, the message forwarding method of DR mode is different. The load balancer dynamically selects a server according to the load of each RS, does not modify or encapsulate the IP message, but directly modifies the target MAC address of the data frame to the MAC address of the selected server, and then sends the modified data frame on the LAN of the server group.
[0077] Because the MAC address of the data frame is the MAC address of the selected server, the RS can receive the data frame and obtain the IP message from it. When the server finds that the target address VIP of the message is on the local network device, the server will process the message and then return the corresponding message directly to the user according to the routing table. However, to use this mode, there are two requirements: 1. The load balancer and the back-end RS are in the same LAN, otherwise the load balancer cannot communicate with the RS through the MAC address. 2. Each RS must be configured with VIP so that it can process messages from the load balancer.
[0078] like Figure 3 As shown, the present invention provides a method for adjusting the deployment of an LVS system based on keepalived, including:
[0079] S1, build and deploy the LVS system, install the keepalived component on the first load balancing node and the second load balancing node in the built LVS system, where the first load balancing node and the second load balancing node complete the traffic distribution task in the master-slave mode;
[0080] S2, the load balancing node currently performing the traffic distribution task, periodically obtains the current traffic distribution weight of each physical server node in the LVS system;
[0081] S3, determining whether the difference between the current traffic allocation weight of the physical server node and the last stored traffic allocation weight is greater than the preset update write weight, if the determination result is yes, executing step S4; if the determination result is no, executing step S5;
[0082] S4, updating the current traffic distribution weight of the physical server node and writing it into the load balancing node currently executing the traffic distribution task;
[0083] S5, temporarily not writing the current traffic allocation weight of the physical server node into the load balancing node currently executing the traffic distribution task, and waiting for the traffic allocation weight of the physical server node in the next cycle;
[0084] S6, the load balancing node currently executing the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update.
[0085] Among them, Figure 4 As shown, step S1 specifically includes:
[0086] S11, creating multiple virtual machine nodes, wherein the first virtual machine node is a first load balancer node, the second virtual machine node and the third virtual machine node are both physical server nodes, and the fourth virtual machine node is a second load balancer node;
[0087] S12, based on the LVS system, respectively configure the target addresses of the first virtual machine node, the second virtual machine node, and the third virtual machine node;
[0088] S13, setting the first load balancing node as the primary load balancing node, and setting the second load balancing node as the backup load balancing node. When the first load balancing node goes down, the second load balancing node will take over the traffic distribution task.
[0089] In step S11, VMware (virtual machine or virtualization service) is used to create three virtual machine nodes, named LVS_DR_Node01 (hereinafter referred to as node1, i.e., the first virtual machine node, IP: 10.180.180.12), LVS_DR_Node02 (hereinafter referred to as node2, i.e., the second virtual machine node, IP: 10.180.180.13) and LVS_DR_Node03 (hereinafter referred to as node3, i.e., the third virtual machine node, IP: 10.180.180.14). Node1 is used as a load balancer, i.e., the first load balancing node, and node2 and node3 are used as backend real servers RS, i.e., the second virtual machine node and the third virtual machine node are both physical server nodes; VMware is used to create a new LVS_DR_Node04 node (hereinafter referred to as node04, i.e., the fourth virtual machine node, IP: 10.180.180.15), and node01 and node04 are used as two highly available load balancers, i.e., the first load balancing node and the second load balancing node. The second virtual machine node serves as the first physical server node, and the third virtual machine node serves as the second physical server node. The LVS system constructed and deployed in the present invention is an LVS system in DR mode.
[0090] In step S12, set VIP in node1 (the first load balancing node). Assuming that the VIP address is 10.180.180.100, you need to execute the command ifconfig ens33:1 10.180.180.100 / 24 in node1 to configure the ens33 network card. Since the DR mode is set up, VIP also needs to be configured on node2 (the first physical server node) and node3 (the second physical server node). However, since the public VIP has been configured on the first load balancing node node1, the VIP on node2 and node3 should be hidden from the outside (client) and visible to the inside (physical server and load balancer). First, after the RS is configured with VIP, it is necessary to prevent the RS from responding to the VIP address configured by itself when receiving an arp request. Secondly, when the RS sends an ARP request to the outside, the source IP address cannot use the VIP address. The above requirements can be achieved through the following two configuration items:
[0091] 1)arp_ignore: The control system in the RS server determines whether to return an ARP response when receiving an external ARP request. The options for this parameter are as follows:
[0092] 0 (default): Respond to ARP requests for the local IP address received on any network card (including addresses on the loopback network card), regardless of whether the destination IP is on the receiving network card.
[0093] 1: Only respond to ARP requests whose destination IP address is the local address on the receiving network card.
[0094] 2: Only respond to arp requests whose destination IP address is the local address on the receiving network card, and the source IP of the arp request must be in the same network segment as the receiving network card.
[0095] 3: If the local address corresponding to the IP address requested by the ARP request packet has a scope of host, the ARP response packet will not be responded to. If the scope is global or link, the ARP response packet will be responded to.
[0096] 4~7: Reserved and not used.
[0097] 8: Do not respond to all ARP requests.
[0098] Here, arp_ignore should be set to 1, that is, the ens33 network card on the RS will only respond when the destination IP address of the ARP request received is the address of this network card.
[0099] 2) arp_announce: Controls how the system selects the source IP address of the arp request packet when sending an arp request to the outside. The options for this parameter are as follows:
[0100] 0 (default): Allows the use of any IP address on the network card as the source IP of the ARP request, usually the source IP of data packet a.
[0101] 1: Try to avoid using a local address that does not belong to the sending network card subnet as the source IP address for sending ARP requests.
[0102] 2: Ignore the source IP address of the IP data packet and select the most appropriate local address on the sending network card as the source IP address of the ARP request.
[0103] Here, arp_announce should be set to 2. When RS uses the ens33 network card to send an arp request, the source IP address only uses the ens33 IP address, so that the VIP address will not be notified to the outside.
[0104] In addition to the above configuration, in order to prevent RS from exposing the VIP address by sending arp requests, VIP should also be configured on the loopback network card lo. In addition, the subnet mask also needs to be configured to 255.255.255.255, otherwise the data sent from the node will go through the lo loopback network card and return to the local machine and cannot be sent out.
[0105] After completing the above configurations, configure LVS on the first load balancing node node1. In Linux, LVS has been integrated as an ipvsadm module at the kernel level. First, execute the command yum install ipvsadm to install the ipvsadm module on the first load balancing node node1. Then execute the command ipvsadm-At 10.180.180.100:80-s rr to add a load balancing rule and specify the scheduling algorithm as round-robin scheduling. Then execute the following command to add two RSs, and the polling weight of each RS is 1:
[0106] ipvsadm-at 10.180.180.100:80-r 10.180.180.13-gw 1
[0107] ipvsadm-at 10.180.180.100:80-r 10.180.180.14-gw 1
[0108] After adding, execute the command ipvsadm to view the addition results. Finally, start the httpd service (the main program of the Hypertext Transfer Protocol (HTTP) server) on the corresponding ports of the two RSs, and after distinguishing the page content from different RSs, enter http: / / 10.180.180.100:80 in the browser and refresh it continuously. You can see the httpd pages from the two RSs respectively. Execute the command ipvsadm-lnc to observe the connections that the first load balancing node node1 has processed and the actual address to which each connection is forwarded.
[0109] Although the above steps have completed the construction of the LVS system in DR mode, there is also a problem, that is, the single-machine load balancer will face the problem of single point failure. Once the load balancer goes down and cannot forward requests from the client, the entire service will be unavailable to the client, which is unacceptable. Therefore, the load balancer needs to be set to high availability. When one of them goes down, another one can take over in time, which is unaware to the client, and the entire system can still provide services to the client normally.
[0110] Therefore, in step S13, the keepalived service component is installed on both the first load balancing node node01 and the second load balancing node node04. Keepalived is a lightweight high-availability solution under Linux. It implements the same and similar functions as HeartBeat (a component of the Linux-HA project, which implements a high-availability cluster system) and RoseHA (shared storage dual-machine hot standby software). Compared with HeartBeat, Keepalived mainly implements high-availability functions through virtual routing redundancy. Although it is not as powerful as HeartBeat, Keepalived is very simple to deploy and use, and all configurations can be completed with only one configuration file.
[0111] Then configure the keepalived.conf files of the first load balancing node node01 and the second load balancing node node04 respectively to implement the virtual routing redundancy protocol configuration. The first load balancing node node01 and the second load balancing node node04 are in active-standby mode. The first load balancing node node01 is the master, and the configuration in the second load balancing node node04 is BACKUP, which means that when the first load balancing node node01 goes down, the second load balancing node node04 automatically takes over. virtual_ipaddress indicates that the VIP and subnet mask are configured on the ens33:1 sub-interface, specifically: 10.180.180.100 / 24dev ens33 label ens33:1.
[0112] The IP addresses of the two real servers are 10.180.180.1380 and 10.180.180.1480. The HTTP_GET configuration indicates that the keepalived component will perform health checks on the two real servers (physical servers) at the backend in this way. If one of them is down, keepalived will promptly operate the ipvsadm module to remove this item from the real server list.
[0113] After the keepalived component is configured on both load balancers (the first load balancing node and the second load balancing node), the keepalived service is started. At this time, it can be found that the ens:1 sub-interface is automatically configured on the first load balancing node node01, and ipvsadm is also configured with two real server entries. However, since the second load balancing node node04 is a backup machine, when the first load balancing node node01 survives, the ens:1 network card is not configured, but the ipvsadm real server entry is also configured.
[0114] At this time, when you access VIP through the client browser and refresh it continuously, you can still see the page content from node02 and node03 respectively, but you can see that the node accessed is the first load balancing node node01. When the keepalived service in the first load balancing node node01 is stopped, you can see that the second load balancing node node04 as the backup machine automatically registers the ens33:1 network card and takes over the task of traffic distribution. The above is the LVS system construction process based on the high-availability DR mode of keepalived.
[0115] In step S2, the load balancing node that currently executes the traffic distribution task periodically obtains the current traffic allocation weight of each physical server node in the LVS system; wherein, the load balancing node that currently executes the traffic distribution task generally defaults to the first load balancing node. When the first load balancing node goes down or fails, the second load balancing node executes the traffic distribution task; the acquisition period can be 1 minute or 1 hour, or 1 day, and can be flexibly adjusted according to actual conditions, and the present invention is not limited here.
[0116] The current traffic distribution weight of the physical server node can be determined by the current load information of the physical server node. The current traffic distribution weight of the physical server node is calculated and determined by the corresponding physical server node based on the current load information, and then sent by the physical server node to the load balancing node that performs the traffic distribution task. Specifically, the load information of the physical server node may include: CPU utilization in the physical server node, memory utilization in the physical server node, and network bandwidth utilization in the physical server node.
[0117] Furthermore, the current traffic distribution weight of the physical server node is determined by the current load information of the physical server node:
[0118] F(Sinew)=A(Kcpu(1-CPU_USEnew)+Kmem(1-MEM_USEnew)+Kband(1-BAND_USEnew))
[0119] Among them, F(Sinew) is the current traffic allocation weight of the physical server node, CPU_USEnew is the current utilization of the CPU in the physical server node, MEM_USEnew is the current utilization of the memory in the physical server node, and BAND_USEnew is the current utilization of the network bandwidth in the physical server node; Kcpu is the influence factor of CPU utilization on the physical server node allocation weight, Kmem is the influence factor of memory utilization on the physical server node allocation weight, Kband is the influence factor of network bandwidth utilization on the physical server node allocation weight, the sum of Kcpu, Kmem, and Kband is 1, and A is the reference coefficient for adjusting the weight change.
[0120] Preferably, if any one of the current utilization of the CPU in the physical server node, the current utilization of the memory in the physical server node, and the current utilization of the network bandwidth in the physical server node is greater than a preset utilization threshold, the current traffic allocation weight of the physical server node is 0.
[0121] The reference coefficient A for weight change can be flexibly set according to the actual situation. For example, when A is set to 10, the value range of F(Si) is [0,10]. It can be obtained from the above formula that when the utilization of the three parameters of the physical server node is 1, the calculated weight is 0, and the load balancer node will no longer allocate tasks to the real server. However, considering the actual server situation, when any one of the three parameters reaches the preset utilization threshold (such as 0.9), no matter what the other two are in, the physical server node should be regarded as fully loaded, and the current traffic distribution weight of the corresponding physical server node should be set to 0 to avoid overloading or even downtime of the physical server node.
[0122] In steps S3-S5, it is determined whether the difference between the current traffic distribution weight of the physical server node and the last stored traffic distribution weight is greater than the preset update write weight, wherein the last stored traffic distribution weight is the traffic distribution weight corresponding to the last update and write of the load balancing node currently executing the traffic distribution task. That is, F(Sinew)-F(Siold)|=A*B. Among them, F(Sinew) is the current traffic distribution weight of the physical server node, and F(Siold) is the traffic distribution weight of the physical server node corresponding to the last storage.
[0123] The preset update write weight is determined by the load information of the physical server, specifically the product of the adjustment reference coefficient A of the weight change and the preset update write weight factor B, wherein the preset update write weight factor B is specifically:
[0124] B=Kcpu*|CPU_USEnew-CPU_USEold|+Kmem*|MEM_USEnew-MEM_USEold|+Kband*|BAND_USEnew-BAND_USEold|
[0125] Among them, CPU_USEnew is the current utilization of the CPU in the physical server node, and CPU_USEold is the utilization of the CPU in the physical server node corresponding to the last storage; MEM_USEnew is the current utilization of the memory in the physical server node, and MEM_USEold is the utilization of the memory in the physical server node corresponding to the last storage; BAND_USEnew is the current utilization of the network bandwidth in the physical server node, and BAND_USEold is the utilization of the network bandwidth in the physical server node corresponding to the last storage. The value range of B can be between [0,1].
[0126] It should be noted that, in the embodiment of the present invention, the load balancing node that performs the traffic distribution task acquires, judges, updates and writes, all for a single physical server node, that is, the load balancing node that performs the traffic distribution task acquires the current traffic distribution weight of the first physical server node, performs a judgment operation, and if the judgment result is yes, then the current traffic distribution weight of the first physical server node is written into the load balancing node that performs the traffic distribution task; the load balancing node that performs the traffic distribution task acquires the current traffic distribution weight of the second physical server node, performs a judgment operation, and if the judgment result is yes, then the current traffic distribution weight of the second physical server node is written into the load balancing node that performs the traffic distribution task. When the load balancing node that performs the traffic distribution task performs the acquisition, judgment, and update writing, it can be a multi-process or multi-thread operation at the same time, or a single process or a single thread operation in sequence, and the present invention does not limit this.
[0127] In step S6, if Figure 5 As shown, step S6 specifically includes:
[0128] S61, the load balancing node currently executing the traffic distribution task obtains the traffic distribution weight of the physical server node that was last updated and written;
[0129] S62, determining the physical server node with the largest traffic allocation weight, and preferentially allocating the traffic distribution task to be executed to the physical server node with the largest traffic allocation weight.
[0130] In step S61, if in steps S3-S5, the current traffic distribution weight of the physical server node is updated and written to the load balancing node that is currently executing the traffic distribution task; the traffic distribution weight of the physical server node that was last updated and written is the current traffic distribution weight of the updated physical server node; if the current traffic distribution weight of the physical server node is not updated and written to the load balancing node that is currently executing the traffic distribution task, the traffic distribution weight of the physical server node that was last updated and written is the traffic distribution weight of the physical server node that was last updated and written to the load balancing node (the load balancing node that is currently executing the traffic distribution task).
[0131] In step S62, a physical server node with the largest traffic allocation weight is determined from multiple physical server nodes, and the traffic distribution task to be executed is preferentially allocated to the physical server node with the largest traffic allocation weight.
[0132] It should be noted that, in this embodiment, the value of the preset update weight can be selected according to actual conditions. If the hardware and software resources of the load balancer (the load balancing node currently performing the traffic distribution task) are sufficient or the cycle for the load balancer to obtain the traffic distribution weight of the physical server node is short, the value of the preset update write weight factor B can be smaller; if the hardware and software resources of the load balancer (the load balancing node currently performing the traffic distribution task) are not sufficient or the cycle for the load balancer to obtain the traffic distribution weight of the physical server node is long, the value of the preset update write weight factor B can be appropriately increased.
[0133] The present invention effectively solves the problems of high risk of load balancing node failure during LVS system construction caused by the prior art, and low scheduling efficiency and easy downtime of the load balancing scheduling algorithm, effectively improves the reliability of LVS system deployment adjustment and the load balancing adjustment efficiency, and avoids RS server node downtime.
[0134] In the technical solution of the present invention, keepalived components are deployed in both the first load balancing node and the second load balancing node. The working modes of the first load balancing node and the second load balancing node are master-slave mode. When one of the load balancing nodes goes down, another load balancing node can take over in time, thereby improving the reliability of LVS system load balancing and improving user experience.
[0135] In the technical solution of the present invention, the load balancing node that currently executes the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node that was most recently updated and written; the traffic distribution weight of the current physical server node is determined by the current load information of the physical server node, and the traffic distribution weight can be adjusted according to the current load information of the physical server node, so that when the load balancing node that executes the traffic distribution task distributes traffic, it can be dynamically adjusted according to the current load situation of the physical server, thereby improving the accuracy of load balancing adjustment.
[0136] In the technical solution of the present invention, it is determined whether the difference between the current traffic distribution weight of the physical server node and the last stored traffic distribution weight is greater than the preset update write weight; if greater, the current traffic distribution weight of the physical server node is updated and written to the load balancing node that is currently executing the traffic distribution task; it is realized that according to the load change of the physical server node, it is determined whether the current traffic distribution weight of the physical server is updated and written to the load balancing node that is executing the traffic distribution task, thereby avoiding updating and writing new traffic distribution weights of all physical server nodes in each cycle, which makes the load balancer overloaded, and improves the reliability of load balancer adjustment.
[0137] According to the technical solution of the present invention, if any one of the CPU utilization, memory utilization, and network bandwidth utilization in the physical server node is greater than a preset utilization threshold, the traffic distribution weight of the physical server node is 0, thereby avoiding overload or even downtime of the physical server node and improving the reliability of load balancing adjustment of the load balancer (the load balancing node that is performing traffic distribution tasks).
[0138] Embodiment 2
[0139] like Figure 6 As shown, the technical solution of the present invention also provides a LVS system deployment adjustment device based on keepalived, including:
[0140] Building module 101, building and deploying the LVS system, installing the keepalived component on the first load balancing node and the second load balancing node in the built LVS system, wherein the first load balancing node and the second load balancing node complete the traffic distribution task in the master-slave mode;
[0141] The acquisition module 102, the load balancing node currently executing the traffic distribution task, periodically acquires the current traffic distribution weight of each physical server node in the LVS system;
[0142] The judgment module 103 judges whether the difference between the current traffic distribution weight of the physical server node and the corresponding traffic distribution weight stored last time is greater than the preset update write weight; if greater, the current traffic distribution weight of the physical server node is updated and written into the load balancing node currently executing the traffic distribution task;
[0143] The distribution module 104, the load balancing node currently executing the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update.
[0144] If the current traffic distribution weight of the physical server node is updated and written into the load balancing node that is currently executing the traffic distribution task; the traffic distribution weight of the physical server node that was last updated and written is the current traffic distribution weight of the updated physical server node; if the current traffic distribution weight of the physical server node is not updated and written into the load balancing node that is currently executing the traffic distribution task, the traffic distribution weight of the physical server node that was last updated and written into is the traffic distribution weight of the physical server node that was last updated and written into (stored in) the load balancing node (the load balancing node that is currently executing the traffic distribution task).
[0145] A physical server node with the largest traffic allocation weight is determined from multiple physical server nodes, and the traffic distribution task to be executed is preferentially allocated to the physical server node with the largest traffic allocation weight.
[0146] The present invention effectively solves the problems of high risk of load balancing node failure during LVS system construction caused by the prior art, and low scheduling efficiency and easy downtime of the load balancing scheduling algorithm, effectively improves the reliability of LVS system deployment adjustment and the load balancing adjustment efficiency, and avoids RS server node downtime.
[0147] In the technical solution of the present invention, keepalived components are deployed in both the first load balancing node and the second load balancing node. The working modes of the first load balancing node and the second load balancing node are master-slave mode. When one of the load balancing nodes goes down, another load balancing node can take over in time, thereby improving the reliability of LVS system load balancing and improving user experience.
[0148] In the technical solution of the present invention, the load balancing node that currently executes the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node that was most recently updated and written; the traffic distribution weight of the current physical server node is determined by the current load information of the physical server node, and the traffic distribution weight can be adjusted according to the current load information of the physical server node, so that when the load balancing node that executes the traffic distribution task distributes traffic, it can be dynamically adjusted according to the current load situation of the physical server, thereby improving the accuracy of load balancing adjustment.
[0149] In the technical solution of the present invention, it is determined whether the difference between the current traffic distribution weight of the physical server node and the last stored traffic distribution weight is greater than the preset update write weight; if greater, the current traffic distribution weight of the physical server node is updated and written to the load balancing node that is currently executing the traffic distribution task; it is realized that according to the load change of the physical server node, it is determined whether the current traffic distribution weight of the physical server is updated and written to the load balancing node that is executing the traffic distribution task, thereby avoiding updating and writing new traffic distribution weights of all physical server nodes in each cycle, which makes the load balancer overloaded, and improves the reliability of load balancer adjustment.
[0150] According to the technical solution of the present invention, if any one of the CPU utilization, memory utilization, and network bandwidth utilization in the physical server node is greater than a preset utilization threshold, the traffic distribution weight of the physical server node is 0, thereby avoiding overload or even downtime of the physical server node and improving the reliability of load balancing adjustment of the load balancer (the load balancing node that is performing traffic distribution tasks).
[0151] Embodiment 3
[0152] like Figure 7 As shown, the technical solution of the present invention also provides an LVS system deployment and adjustment system based on keepalived, including: a first physical server node 201, a second physical server node 202, a first load balancing node 203 and a second load balancing node 204; keepalived components are installed on the first load balancing node 203 and the second load balancing node 204, wherein the first load balancing node 203 and the second load balancing node 204 complete the traffic distribution task in the master-slave mode;
[0153] The load balancing node currently executing the traffic distribution task among the first load balancing node 203 and the second load balancing node 204 periodically obtains the load information of each physical server node in the LVS system; adjusts the traffic distribution weight of the physical server node according to the load information of each physical server node; determines whether to write the current traffic distribution weight of the physical server node into the load balancing node currently executing the traffic distribution task according to the current load information of each physical server node and the load information of the previous cycle; and executes the traffic distribution task according to the traffic distribution weight of the physical server node that was most recently updated and written.
[0154] If the current traffic distribution weight of the physical server node is updated and written into the load balancing node that is currently executing the traffic distribution task; the traffic distribution weight of the physical server node that was last updated and written is the current traffic distribution weight of the updated physical server node; if the current traffic distribution weight of the physical server node is not updated and written into the load balancing node that is currently executing the traffic distribution task, the traffic distribution weight of the physical server node that was last updated and written into is the traffic distribution weight of the physical server node that was last updated and written into (stored in) the load balancing node (the load balancing node that is currently executing the traffic distribution task).
[0155] A physical server node with the largest traffic allocation weight is determined from multiple physical server nodes, and the traffic distribution task to be executed is preferentially allocated to the physical server node with the largest traffic allocation weight.
[0156] The present invention effectively solves the problems of high risk of load balancing node failure during LVS system construction caused by the prior art, and low scheduling efficiency and easy downtime of the load balancing scheduling algorithm, effectively improves the reliability of LVS system deployment adjustment and the load balancing adjustment efficiency, and avoids RS server node downtime.
[0157] In the technical solution of the present invention, keepalived components are deployed in both the first load balancing node and the second load balancing node. The working modes of the first load balancing node and the second load balancing node are master-slave mode. When one of the load balancing nodes goes down, another load balancing node can take over in time, thereby improving the reliability of LVS system load balancing and improving user experience.
[0158] In the technical solution of the present invention, the load balancing node that currently executes the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node that was most recently updated and written; the traffic distribution weight of the current physical server node is determined by the current load information of the physical server node, and the traffic distribution weight can be adjusted according to the current load information of the physical server node, so that when the load balancing node that executes the traffic distribution task distributes traffic, it can be dynamically adjusted according to the current load situation of the physical server, thereby improving the accuracy of load balancing adjustment.
[0159] In the technical solution of the present invention, it is determined whether the difference between the current traffic distribution weight of the physical server node and the last stored traffic distribution weight is greater than the preset update write weight; if greater, the current traffic distribution weight of the physical server node is updated and written to the load balancing node that is currently executing the traffic distribution task; it is realized that according to the load change of the physical server node, it is determined whether the current traffic distribution weight of the physical server is updated and written to the load balancing node that is executing the traffic distribution task, thereby avoiding updating and writing new traffic distribution weights of all physical server nodes in each cycle, which makes the load balancer overloaded, and improves the reliability of load balancer adjustment.
[0160] According to the technical solution of the present invention, if any one of the CPU utilization, memory utilization, and network bandwidth utilization in the physical server node is greater than a preset utilization threshold, the traffic distribution weight of the physical server node is 0, thereby avoiding overload or even downtime of the physical server node and improving the reliability of load balancing adjustment of the load balancer (the load balancing node that is performing traffic distribution tasks).
[0161] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A method for deploying and adjusting an LVS system based on keepalived, characterized in that: include: Build and deploy the LVS system, install the keepalived component on the first load balancing node and the second load balancing node in the LVS system, wherein the first load balancing node and the second load balancing node complete the traffic distribution task in the active-standby mode; the LVS system is in VS / DR mode; build and deploy the LVS system, and install the keepalived component on the first load balancing node and the second load balancing node in the built LVS system specifically including: Create multiple virtual machine nodes, where the first virtual machine node is the first load balancer node, the second virtual machine node and the third virtual machine node are both physical server nodes, and the fourth virtual machine node is the second load balancer node; the second virtual machine node and the third virtual machine node are both configured with a VIP that is hidden from external clients and visible to internal physical server nodes and load balancer nodes, and the configuration items arp_ignore and arp_announce are used to prevent the physical server node from responding to the VIP address configured by itself when receiving an arp request, and when the physical server node sends an arp request to the outside, the source IP address cannot use the VIP address; When the configuration item arp_ignore is set to the first preset parameter value, the physical server node will respond only when the destination IP address of the ARP request received by the ens33 network card on the physical server node is the address of this network card; when the configuration item arp_announce is set to the second preset parameter value, when the physical server node uses the ens33 network card to send an arp request to the outside, the source IP address only uses the IP address of the ens33 network card, and the VIP address will not be notified to the outside; in order to prevent the physical server node from exposing the VIP address by sending an arp request, the VIP is configured on the loopback network card lo; the subnet mask is configured to 255.255.255.255 to prevent the data sent from the physical server node from going through the lo loopback network card and returning to the local machine, and cannot be sent out; Based on the LVS system, respectively configure the target addresses of the first virtual machine node, the second virtual machine node, and the third virtual machine node; Set the first load balancing node as the primary load balancing node and the second load balancing node as the backup load balancing node. When the first load balancing node goes down, the second load balancing node will take over the traffic distribution task. The load balancing node currently executing the traffic distribution task periodically obtains the current traffic distribution weight of each physical server node in the LVS system; wherein the current traffic distribution weight of the physical server node is determined by the current load information of the physical server node; the load information of the physical server node includes: the utilization rate of the CPU in the physical server node, the utilization rate of the memory in the physical server node, and the utilization rate of the network bandwidth in the physical server node; The current traffic distribution weight of the physical server node is determined by the current load information of the physical server node: F(Sinew)=A(Kcpu(1-CPU_USEnew)+Kmem(1-MEM_USEnew)+Kband(1-BAND_USEnew)) Among them, F(Sinew) is the current traffic allocation weight of the physical server node, CPU_USEnew is the current utilization of the CPU in the physical server node, MEM_USEnew is the current utilization of the memory in the physical server node, and BAND_USEnew is the current utilization of the network bandwidth in the physical server node; Kcpu is the influence factor of the CPU utilization on the physical server node allocation weight, Kmem is the influence factor of the memory utilization on the physical server node allocation weight, Kband is the influence factor of the network bandwidth utilization on the physical server node allocation weight, the sum of the values of Kcpu, Kmem, and Kband is 1, and A is the reference coefficient for adjusting the weight change; Determine whether the difference between the current traffic allocation weight of the physical server node and the last stored traffic allocation weight is greater than the preset update write weight; if greater, update and write the current traffic allocation weight of the physical server node to the load balancing node currently executing the traffic distribution task; the preset update write weight is determined by the load information of the physical server, specifically the product of the adjustment reference coefficient of the weight change and the preset update write weight factor, wherein the preset update write weight factor is specifically: B=Kcpu*|CPU_USEnew-CPU_USEold|+Kmem*|MEM_USEnew-MEM_USEold|+Kband*|BAND_USEnew-BAND_USEold| Among them, B is the preset update write weight factor, CPU_USEnew is the current utilization of the CPU in the physical server node, and CPU_USEold is the utilization of the CPU in the physical server node corresponding to the last storage; MEM_USEnew is the current utilization of the memory in the physical server node, and MEM_USEold is the utilization of the memory in the physical server node corresponding to the last storage; BAND_USEnew is the current utilization of the network bandwidth in the physical server node, and BAND_USEold is the utilization of the network bandwidth in the physical server node corresponding to the last storage; The load balancing node currently executing the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update.
2. According to the keepalived-based LVS system deployment adjustment method of claim 1, it is characterized in that: If any value of the current utilization of the CPU in the physical server node, the current utilization of the memory in the physical server node, and the current utilization of the network bandwidth in the physical server node is greater than the preset utilization threshold, the current traffic allocation weight of the physical server node is 0.
3. The LVS system deployment adjustment method based on keepalived according to claim 1 is characterized in that: The load balancing node currently performing the traffic distribution task performs the traffic distribution task specifically as follows: The load balancing node currently executing the traffic distribution task obtains the traffic distribution weight of the current physical server node written in the most recent update; Determine the physical server node with the largest traffic allocation weight, and preferentially allocate the traffic distribution task to be executed to the physical server node with the largest traffic allocation weight.
4. A LVS system deployment adjustment device based on keepalived, characterized in that: include: Build a module, build and deploy an LVS system, install keepalived components on the first load balancing node and the second load balancing node in the built LVS system, where the first load balancing node and the second load balancing node complete the traffic distribution task in active-standby mode; the LVS system is in VS / DR mode; build and deploy an LVS system, and install keepalived components on the first load balancing node and the second load balancing node in the built LVS system, specifically including: Create multiple virtual machine nodes, where the first virtual machine node is the first load balancer node, the second virtual machine node and the third virtual machine node are both physical server nodes, and the fourth virtual machine node is the second load balancer node; the second virtual machine node and the third virtual machine node are both configured with a VIP that is hidden from external clients and visible to internal physical server nodes and load balancer nodes, and the configuration items arp_ignore and arp_announce are used to prevent the physical server node from responding to the VIP address configured by itself when receiving an arp request, and when the physical server node sends an arp request to the outside, the source IP address cannot use the VIP address; When the configuration item arp_ignore is set to the first preset parameter value, the physical server node will respond only when the destination IP address of the ARP request received by the ens33 network card on the physical server node is the address of this network card; when the configuration item arp_announce is set to the second preset parameter value, when the physical server node uses the ens33 network card to send an arp request to the outside, the source IP address only uses the IP address of the ens33 network card, and the VIP address will not be notified to the outside; in order to prevent the physical server node from exposing the VIP address by sending an arp request, the VIP is configured on the loopback network card lo; the subnet mask is configured to 255.255.255.255 to prevent the data sent from the physical server node from going through the lo loopback network card and returning to the local machine, and cannot be sent out; Based on the LVS system, respectively configure the target addresses of the first virtual machine node, the second virtual machine node, and the third virtual machine node; Set the first load balancing node as the primary load balancing node and the second load balancing node as the backup load balancing node. When the first load balancing node goes down, the second load balancing node will take over the traffic distribution task. The acquisition module, the load balancing node currently executing the traffic distribution task, periodically acquires the current traffic distribution weight of each physical server node in the LVS system; wherein the current traffic distribution weight of the physical server node is determined by the current load information of the physical server node; the load information of the physical server node includes: the CPU utilization rate in the physical server node, the memory utilization rate in the physical server node, and the network bandwidth utilization rate in the physical server node; The current traffic distribution weight of the physical server node is determined by the current load information of the physical server node: F(Sinew)=A(Kcpu(1-CPU_USEnew)+Kmem(1-MEM_USEnew)+Kband(1-BAND_USEnew)) Among them, F(Sinew) is the current traffic allocation weight of the physical server node, CPU_USEnew is the current utilization of the CPU in the physical server node, MEM_USEnew is the current utilization of the memory in the physical server node, and BAND_USEnew is the current utilization of the network bandwidth in the physical server node; Kcpu is the influence factor of the CPU utilization on the physical server node allocation weight, Kmem is the influence factor of the memory utilization on the physical server node allocation weight, Kband is the influence factor of the network bandwidth utilization on the physical server node allocation weight, the sum of the values of Kcpu, Kmem, and Kband is 1, and A is the reference coefficient for adjusting the weight change; The judgment module judges whether the difference between the current traffic allocation weight of the physical server node and the corresponding traffic allocation weight at the last storage is greater than the preset update write weight; if greater, the current traffic allocation weight of the physical server node is updated and written to the load balancing node currently executing the traffic distribution task; the preset update write weight is determined by the load information of the physical server, specifically the product of the adjustment reference coefficient of the weight change and the preset update write weight factor, wherein the preset update write weight factor is specifically: B=Kcpu*|CPU_USEnew-CPU_USEold|+Kmem*|MEM_USEnew-MEM_USEold|+Kband*|BAND_USEnew-BAND_USEold| Among them, B is the preset update write weight factor, CPU_USEnew is the current utilization of the CPU in the physical server node, and CPU_USEold is the utilization of the CPU in the physical server node corresponding to the last storage; MEM_USEnew is the current utilization of the memory in the physical server node, and MEM_USEold is the utilization of the memory in the physical server node corresponding to the last storage; BAND_USEnew is the current utilization of the network bandwidth in the physical server node, and BAND_USEold is the utilization of the network bandwidth in the physical server node corresponding to the last storage; The distribution module, the load balancing node currently executing the traffic distribution task executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update.
5. A LVS system deployment and adjustment system based on keepalived, characterized in that: include: The first physical server node, the second physical server node, the first load balancing node, and the second load balancing node; the keepalived component is installed on the first load balancing node and the second load balancing node, wherein the first load balancing node and the second load balancing node complete the traffic distribution task in the active-standby mode; the LVS system is in VS / DR mode; the construction and deployment of the LVS system specifically includes: Create multiple virtual machine nodes, where the first virtual machine node is the first load balancer node, the second virtual machine node and the third virtual machine node are both physical server nodes, and the fourth virtual machine node is the second load balancer node; the second virtual machine node and the third virtual machine node are both configured with a VIP that is hidden from external clients and visible to internal physical server nodes and load balancer nodes, and the configuration items arp_ignore and arp_announce are used to prevent the physical server node from responding to the VIP address configured by itself when receiving an arp request, and when the physical server node sends an arp request to the outside, the source IP address cannot use the VIP address; When the configuration item arp_ignore is set to the first preset parameter value, the physical server node will respond only when the destination IP address of the ARP request received by the ens33 network card on the physical server node is the address of this network card; when the configuration item arp_announce is set to the second preset parameter value, when the physical server node uses the ens33 network card to send an arp request to the outside, the source IP address only uses the IP address of the ens33 network card, and the VIP address will not be notified to the outside; in order to prevent the physical server node from exposing the VIP address by sending an arp request, the VIP is configured on the loopback network card lo; the subnet mask is configured to 255.255.255.255 to prevent the data sent from the physical server node from going through the lo loopback network card and returning to the local machine, and cannot be sent out; Based on the LVS system, respectively configure the target addresses of the first virtual machine node, the second virtual machine node, and the third virtual machine node; Set the first load balancing node as the primary load balancing node and the second load balancing node as the backup load balancing node. When the first load balancing node goes down, the second load balancing node will take over the traffic distribution task. The load balancing node currently executing the traffic distribution task among the first load balancing node and the second load balancing node periodically obtains the current traffic distribution weight of each physical server node in the LVS system; determines whether the difference between the current traffic distribution weight of the physical server node and the corresponding traffic distribution weight at the time of the last storage is greater than the preset update write weight; if greater, updates the current traffic distribution weight of the physical server node to the load balancing node currently executing the traffic distribution task; executes the traffic distribution task according to the traffic distribution weight of the physical server node written in the most recent update; wherein the current traffic distribution weight of the physical server node is determined by the current load information of the physical server node; the load information of the physical server node includes: the utilization rate of the CPU in the physical server node, the utilization rate of the memory in the physical server node, and the utilization rate of the network bandwidth in the physical server node; The current traffic distribution weight of the physical server node is determined by the current load information of the physical server node: F(Sinew)=A(Kcpu(1-CPU_USEnew)+Kmem(1-MEM_USEnew)+Kband(1-BAND_USEnew)) Among them, F(Sinew) is the current traffic allocation weight of the physical server node, CPU_USEnew is the current utilization of the CPU in the physical server node, MEM_USEnew is the current utilization of the memory in the physical server node, and BAND_USEnew is the current utilization of the network bandwidth in the physical server node; Kcpu is the influence factor of the CPU utilization on the physical server node allocation weight, Kmem is the influence factor of the memory utilization on the physical server node allocation weight, Kband is the influence factor of the network bandwidth utilization on the physical server node allocation weight, the sum of the values of Kcpu, Kmem, and Kband is 1, and A is the adjustment reference coefficient for weight change; the preset update write weight is determined by the load information of the physical server, specifically the product of the adjustment reference coefficient for weight change and the preset update write weight factor, wherein the preset update write weight factor is specifically: B=Kcpu*|CPU_USEnew-CPU_USEold|+Kmem*|MEM_USEnew-MEM_USEold|+Kband*|BAND_USEnew-BAND_USEold| Among them, B is the preset update write weight factor, CPU_USEnew is the current utilization of the CPU in the physical server node, CPU_USEold is the utilization of the CPU in the physical server node corresponding to the last storage; MEM_USEnew is the current utilization of the memory in the physical server node, MEM_USEold is the utilization of the memory in the physical server node corresponding to the last storage; BAND_USEnew is the current utilization of the network bandwidth in the physical server node, BAND_USEold is the utilization of the network bandwidth in the physical server node corresponding to the last storage.
