Virtual IP distribution method and device, equipment and medium
By grouping and reallocating virtual IPs in a distributed storage system, the problem of unbalanced virtual IPs is solved, achieving uniform distribution on nodes and network devices, optimizing resource utilization and load balancing, and improving system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies do not consider service load and network equipment factors when allocating virtual IPs, resulting in an imbalance of virtual IPs on nodes. This may cause one network card to be under excessive pressure while another network card is idle, affecting the performance of the storage system.
By obtaining the virtual IP allocation information of different network interfaces in the distributed storage system, the virtual IPs are grouped and reallocated to ensure even distribution across nodes and network devices. Unnecessary movement of business IPs is avoided during the load balancing process, and the LPC2 algorithm is used to optimize load balancing.
It achieves uniform distribution of virtual IPs across nodes and network devices, optimizes resource utilization, ensures load balancing and system reliability, reduces network load imbalance, and improves system stability.
Smart Images

Figure CN121644522A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a virtual IP allocation method, apparatus, device and medium. Background Technology
[0002] CTDB (Cluster Trivial Database) is a clustered database component within clustered Samba, providing a highly available, load-sharing CIFS server cluster. Initially, CTDB was considered supplementary software to Samba, primarily responsible for handling Samba cross-node messages and implementing a distributed TDB database across all cluster nodes. Now, CTDB clusters can manage not only Samba but also cluster implementations for applications such as NFS, iSCSI, and winbind.
[0003] In practical applications, distributed clusters typically provide services by offering virtual IP addresses. These virtual IP addresses provide a unified access point for clients, ensuring that clients always access the service through this fixed IP address regardless of changes in the underlying service deployment. For the cluster, the CTDB service can be used to manage the virtual IP resource pool. Firstly, CTDB enables a balanced distribution of virtual IPs across cluster nodes, significantly improving service response speed and concurrency capabilities. Secondly, when a node in the cluster fails or crashes, CTDB can quickly transfer virtual IP addresses to other healthy nodes, ensuring service continuity and high availability.
[0004] In the above process, the most critical aspect of the IP allocation algorithm used by CTDB is how to evenly distribute virtual IPs across nodes, as this relates to whether the overall performance and throughput of the cluster can be maximized. The algorithm aims to minimize the travel distance, ensuring that each node has the same number of virtual IPs when equipped with an integer multiple of the number of nodes.
[0005] However, this method does not take into account business load and network device factors when allocating IPs. When a failed node rejoins the cluster and IPs are reallocated, a single network device on a node may have two virtual IPs. The virtual IPs are unbalanced among network devices, which may result in one network card being under excessive pressure while the other network card is idle, thus failing to maximize the performance of the storage system. Summary of the Invention
[0006] In view of this, embodiments of this application provide a virtual IP allocation method, apparatus, device, and medium to overcome or at least partially solve the above problems.
[0007] The first aspect of this application provides a virtual IP allocation method, the method comprising:
[0008] Obtain the allocation of virtual IPs corresponding to different network interfaces in the distributed storage system across various nodes;
[0009] When the allocation situation indicates that the virtual IPs corresponding to the different network interfaces are unevenly distributed across the nodes, the multiple virtual IPs allocated to each node are grouped according to the network interfaces corresponding to the multiple virtual IPs to obtain multiple virtual IP groups. Each virtual IP group contains: the virtual IPs corresponding to the same network interface.
[0010] For each virtual IP group, each virtual IP contained in the virtual IP group is reassigned to each node.
[0011] Optionally, after reassigning each virtual IP contained in each virtual IP group to each node for each virtual IP group, the method further includes:
[0012] For each node where virtual IPs are redistributed, determine the load of each virtual IP on each node;
[0013] Based on the load of each virtual IP, determine whether any service IPs have moved between different nodes after the virtual IPs have been redistributed;
[0014] When a service IP moves between different nodes, the service IP that moved between different nodes will be reassigned to the node where the service IP was before the reassignment.
[0015] Optionally, before assigning the service IP that has moved between different nodes to the node where the service IP was located before the reallocation, the method further includes:
[0016] Determine whether there is a non-business IP belonging to the same virtual IP group on the node where the business IP was located before the reallocation;
[0017] The step of assigning a service IP that moves between different nodes to the node where the service IP was located before the reallocation includes: when there is a non-service IP, exchanging the node numbers of the nodes where the non-service IP and the service IP are located.
[0018] Optionally, determining the load of each virtual IP on each node for each node that has reassigned virtual IPs includes:
[0019] For each virtual IP group, the master node sends messages to each node to query the load status of each virtual IP on each node according to the service type, and obtain the business query results.
[0020] Save the business query results, and based on the business query results, mark the virtual IPs of each node as business IPs or non-business IPs according to whether they are providing services;
[0021] Virtual IPs that are currently providing services are marked as service IPs, while virtual IPs that are not currently providing services are marked as non-service IPs.
[0022] Optionally, determining whether any service IPs have moved between different nodes after the virtual IPs are reallocated, based on the load conditions of each virtual IP, includes:
[0023] For each virtual IP group, iterate through all the virtual IPs contained in the virtual IP group and determine whether there is a service IP among all the virtual IPs contained in the virtual IP group;
[0024] When a non-business IP is encountered during the traversal of the virtual IP group, the traversal continues.
[0025] When a service IP is encountered during the traversal of the virtual IP group, it is determined whether the encountered service IP has moved between different nodes after being reassigned.
[0026] If the traversed business IP does not move between different nodes, the traversal continues until all virtual IPs contained in the virtual IP group have been traversed.
[0027] Optionally, when a service IP is encountered during traversal of the virtual IP group, determining whether the encountered service IP has moved between different nodes after being reassigned includes:
[0028] Obtain the node number corresponding to the node where the traversed business IP is located before and after being reassigned, wherein the node number corresponding to the node before and after being reassigned includes the first node number and the second node number.
[0029] Determine whether the first node number and the second node number are equal;
[0030] When the first node number and the second node number are not equal, it is determined that the traversed business IP has moved between different nodes after being reassigned.
[0031] When the first node number and the second node number are equal, it is determined that the traversed business IP has not moved between different nodes;
[0032] Wherein, the first node number is the node number of the node where the traversed business IP was located before the reallocation, and the second node number is the node number of the node where the traversed business IP is located after the reallocation.
[0033] Optionally, the step of reallocating each virtual IP contained in each virtual IP group to each node includes:
[0034] The LPC2 algorithm is used to calculate the balanced distribution of each virtual IP group on each node and different network interfaces.
[0035] According to the balanced allocation result, each virtual IP in the virtual IP group is redistributed to each node.
[0036] A second aspect of this application provides a virtual IP allocation device, the device comprising:
[0037] The acquisition module is used to acquire the allocation status of each virtual IP corresponding to different network interfaces in the distributed storage system on each node.
[0038] The grouping module is used to group the virtual IPs allocated to each node according to the network interface corresponding to the virtual IPs when the allocation situation indicates that the virtual IPs corresponding to the different network interfaces are unevenly distributed on the nodes, thereby obtaining multiple virtual IP groups. Each virtual IP group contains: virtual IPs corresponding to the same network interface.
[0039] The reallocation module is used to reallocate each virtual IP contained in each virtual IP group to each node.
[0040] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the virtual IP allocation method as described in the first aspect.
[0041] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the virtual IP allocation method as described in the first aspect.
[0042] The beneficial effects of this application are:
[0043] This application provides a virtual IP allocation method, apparatus, device, and medium. The method includes: acquiring the allocation status of virtual IPs corresponding to different network interfaces in a distributed storage system across various nodes; when the allocation status indicates an uneven distribution of virtual IPs corresponding to different network interfaces across nodes, grouping the multiple virtual IPs allocated to each node according to the network interfaces corresponding to the multiple virtual IPs to obtain multiple virtual IP groups, each virtual IP group containing virtual IPs corresponding to the same network interface; and for each virtual IP group, redistributing the virtual IPs contained in the virtual IP group to various nodes. This achieves a uniform distribution of virtual IPs across different nodes and network devices, thereby helping to optimize resource utilization, ensure load balancing across nodes, reduce network load imbalance, and improve system reliability. Attached Figure Description
[0044] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0045] To more clearly illustrate the technical solution of this application, the drawings used in the description of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a flowchart illustrating a virtual IP allocation method provided in an embodiment of this application;
[0047] Figure 2 This is a flowchart illustrating the virtual IP allocation process for each virtual IP group in an embodiment of the present application.
[0048] Figure 3 This is a flowchart illustrating a virtual IP allocation method provided in another embodiment of this application;
[0049] Figure 4 This is a schematic diagram of the framework of a virtual IP allocation device provided in one embodiment of this application;
[0050] Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0051] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0053] The process of allocating virtual IPs in related technologies is as follows:
[0054] Assuming a three-node cluster, each node has two service network cards and two virtual IPs. Node 1 has VIP1 (network card 1) and VIP2 (network card 2), Node 2 has VIP3 (network card 1) and VIP4 (network card 2), and Node 3 has VIP5 (network card 1, which is currently providing services) and VIP6 (network card 2).
[0055] Assuming node 3 fails, the virtual IP allocation distribution among nodes during the failure period might be as follows: Node 1 has VIP1 (NIC 1), VIP2 (NIC 2), and VIP5 (NIC 1, currently providing service); Node 2 has VIP3 (NIC 1), VIP4 (NIC 2), and VIP6 (NIC 2). Finally, if node 3 recovers and rejoins the CTDB cluster, the LPC2 algorithm might produce the following result: Node 1 has VIP1 (NIC 1) and VIP2 (NIC 2); Node 2 has VIP4 (NIC 2) and VIP6 (NIC 2); Node 3 has VIP5 (NIC 1, currently providing service) and VIP3 (NIC 1).
[0056] The above examples illustrate two points: First, after the fault was recovered, the VIP5 service experienced migration, which caused service interruption and production stoppage. Second, the virtual IPs on both Node 2 and Node 3 were on the same network interface card (NIC), potentially leading to excessive load on that single NIC.
[0057] Therefore, how to ensure that the IP allocation algorithm is balanced across all nodes, while also distributing it evenly across different network devices on those nodes, and finally, how to ensure balance while minimizing the movement of virtual IPs currently in use, are problems that urgently need to be solved by those in this field.
[0058] Figure 1 This is a flowchart illustrating a virtual IP allocation method according to an embodiment of this application, as shown below. Figure 1 As shown.
[0059] One embodiment of this application provides a virtual IP allocation method, the method comprising:
[0060] In step S101, the allocation of each virtual IP corresponding to each network interface in the distributed storage system on each node is obtained.
[0061] In step S102, when the allocation situation indicates that the virtual IPs corresponding to the different network interfaces are unevenly distributed on the nodes, the multiple virtual IPs allocated to the nodes are grouped according to the network interfaces corresponding to the multiple virtual IPs to obtain multiple virtual IP groups. Each virtual IP group contains: the virtual IPs corresponding to the same network interface.
[0062] In step S103, for each virtual IP group, each virtual IP contained in the virtual IP group is reassigned to each node.
[0063] First, the virtual IP allocation method provided in this application is applied to a distributed storage system. The distributed storage system contains multiple nodes. A node refers to a basic computing or storage unit in the distributed storage system, such as a physical node or a virtual node. Each node is configured with multiple network interfaces through a network card. The network interfaces between different nodes can be the same or different. Each network interface can provide multiple virtual IPs to different nodes.
[0064] In step S101, since there are multiple network interfaces in the distributed storage system, and each interface has one or more virtual IPs, it is necessary to obtain the allocation of these virtual IPs on different nodes and different network cards to determine whether the multiple virtual IPs are evenly distributed on different nodes and different network cards. Even distribution means that the number of virtual IPs on each node is relatively balanced, and the distribution of the multiple virtual IPs provided by the network interfaces of all network cards on different nodes is also uniform.
[0065] In other words, "balanced allocation" means that in a distributed storage system, the allocation of Virtual IPs (VIPs) needs to be balanced at the following two levels:
[0066] 1. The virtual IPs are evenly distributed across all nodes;
[0067] 2. The virtual IPs are evenly distributed across network devices (such as network cards).
[0068] The process of obtaining the allocation status can be done at any time, such as after the virtual IP is adjusted, after a node is removed due to failure, or after a node is restored to normal operation. Alternatively, the allocation status of the virtual IP can be obtained periodically.
[0069] Furthermore, in step S102, if the allocation information obtained through step S101 indicates that the virtual IPs corresponding to different network interfaces are unevenly distributed across nodes, it means that the distribution of virtual IPs across nodes and / or network devices (such as network cards) is uneven.
[0070] At this point, in order to ensure that the virtual IPs provided by the network interfaces of multiple network cards can be evenly redistributed to each node, it is necessary to group the multiple virtual IPs that have been allocated to each node according to the network interfaces corresponding to the multiple virtual IPs. Multiple virtual IPs belonging to the same network interface are grouped into one virtual IP group, thus obtaining multiple virtual IP groups. After this grouping, each virtual IP group can contain the virtual IPs corresponding to the same network interface.
[0071] For example, suppose there are 3 nodes (node N1, node N2, node N3) and 3 network interfaces (network interface 1, network interface 2, network interface 3), and each interface has multiple virtual IPs.
[0072] The virtual IPs on node N1 include: VIP4 (network interface 2), VIP6 (network interface 3), and VIP3 (network interface 3);
[0073] The virtual IPs on node N2 include: VIP4 (network interface 2) and VIP1 (network interface 1);
[0074] The virtual IPs on node N3 include: VIP2 (network interface 1);
[0075] In step S102, the virtual IP will be grouped as follows:
[0076] Virtual IP Group 1 (Network Interface 1): VIP1, VIP2;
[0077] Virtual IP Group 2 (Network Interface 2): VIP4, VIP5;
[0078] Virtual IP group 3 (network interface 3): VIP6, VIP3.
[0079] Finally, in step S103, the virtual IPs are evenly distributed to each node according to the virtual IP groups. The multiple virtual IPs contained in each virtual IP group are evenly distributed to each node, thus taking into account the uniform distribution of virtual IPs on each node and on network devices (such as network cards).
[0080] For example, following the order of the virtual IP groups, multiple virtual IPs from each virtual IP group are assigned to each node in sequence.
[0081] Virtual IP Group 1 (Network Interface 1): VIP1, VIP2;
[0082] Virtual IP Group 2 (Network Interface 2): VIP4, VIP5;
[0083] Virtual IP group 3 (network interface 3): VIP6, VIP3.
[0084] The distribution of virtual IPs on each node is as follows:
[0085] The virtual IPs on node N1 include: VIP1 (network interface 1) and VIP4 (network interface 2);
[0086] The virtual IPs on node N2 include: VIP5 (network interface 2) and VIP6 (network interface 3);
[0087] The virtual IPs on node N3 include: VIP2 (network interface 1) and VIP3 (network interface 3).
[0088] Through the above embodiments, the allocation of virtual IPs on various nodes and network interfaces is obtained, and any imbalance in allocation is checked. When an imbalance occurs, the virtual IPs are grouped according to the network interface, and then redistributed to each node according to the virtual IP group. In this way, the virtual IPs of the same network interface are evenly distributed to each node, preventing multiple virtual IPs provided by the network interface of the same network card from being on the same node. This avoids situations where one network card on the same node is overloaded while another network card is idle when the service requires the source address of the BIND network card for communication. This achieves a uniform distribution of virtual IPs on various nodes and on different network cards of the same node, thereby helping to optimize resource utilization, ensure load balancing of each node, reduce network load imbalance, and improve system reliability.
[0089] The uniform distribution of virtual IPs across nodes is reflected in the fact that the number of virtual IPs on each node is the same. The uniform distribution of virtual IPs across different network cards on the same node is reflected in the fact that multiple virtual IPs on a single network card are on the same node.
[0090] Optionally, after step S103, the method further includes:
[0091] For each node where virtual IPs are redistributed, determine the load of each virtual IP on each node;
[0092] Based on the load of each virtual IP, determine whether any service IPs have moved between different nodes after the virtual IPs have been redistributed;
[0093] When a service IP moves between different nodes, the service IP that moved between different nodes will be reassigned to the node where the service IP was before the reassignment.
[0094] Specifically, in one embodiment, in order to further ensure that the services of clients with virtual IP connections that are engaged in business read and write operations are not interrupted due to the movement of virtual IPs in business state from one node to another after the virtual IPs in business state are reallocated, further adjustments need to be made after the virtual IPs in business state are reallocated to ensure the stability and availability of the distributed storage system.
[0095] Therefore, after the initial redistribution of virtual IPs to each node is completed, it is necessary to check the load status of the virtual IPs on each node. The load status refers to whether the virtual IP is in a service state. Virtual IPs in a service state are called service IPs.
[0096] Check whether the reassigned service IP has moved between nodes, that is, whether the service IP has been transferred from one node to another after the reassignment.
[0097] When a business IP is moved to a different node after being reassigned, it can cause the business that was being processed to be interrupted. This is especially true if the node where the business IP was previously located has accumulated a large amount of state or cache information, which can greatly affect the continuity of business.
[0098] Therefore, for service IPs that move between different nodes, it is necessary to reassign the service IPs that moved between different nodes to the node where the service IPs were located before the reassignment.
[0099] For example, suppose there is a distributed storage system with three nodes (N1, N2, N3) and three virtual IPs (VIP1, VIP2, VIP3). The original allocation of the virtual IPs on each node is as follows:
[0100] Node N1: VIP1, VIP2;
[0101] Node N2: VIP3;
[0102] Node N3: VIP4;
[0103] After reallocation, the virtual IP allocation on each node becomes:
[0104] Node N1: VIP2;
[0105] Node N2: VIP1, VIP3;
[0106] Node N3: VIP4;
[0107] The load status check shows:
[0108] Node N1 load: VIP2 (no service);
[0109] Node N2 load: VIP1 (with service), VIP3 (without service);
[0110] Node N3 load: VIP1 (no service);
[0111] Load analysis revealed that VIP1 (originally on node N1) had service on node N2, while VIP2 (originally on node N1) had no service on node N2. At this point, VIP1 and VIP2 had moved between nodes. To mitigate potential problems, VIP1 could be reassigned back to node N1. This would ensure that VIP1 remained on the same node before and after the reassignment, preventing service interruption for clients.
[0112] The virtual IP allocation on each node after adjustment:
[0113] Node N1: VIP1, VIP2;
[0114] Node N2: VIP3;
[0115] Node N3: VIP4.
[0116] The above embodiments demonstrate how load balancing and service continuity are handled during virtual IP reallocation. By monitoring load conditions and preventing unnecessary movement of service IPs between nodes, the continuity of client services is ensured, thereby guaranteeing system stability and performance.
[0117] Optionally, before assigning the service IP that has moved between different nodes to the node where the service IP was located before the reallocation, the method further includes:
[0118] Determine whether there is a non-business IP belonging to the same virtual IP group on the node where the business IP was located before the reallocation;
[0119] The step of assigning a service IP that moves between different nodes to the node where the service IP was located before the reallocation includes: when there is a non-service IP, exchanging the node numbers of the nodes where the non-service IP and the service IP are located.
[0120] Specifically, in one embodiment, before assigning a service IP that has moved between different nodes to the node where the service IP was located before the reallocation, it is also necessary to consider whether the virtual IPs of each node are balanced. Therefore, it is necessary to determine whether there are any non-service IPs belonging to the same virtual IP group as the service IP among the multiple virtual IPs reassigned to the original node where the service IP was located before the reallocation. Non-service IPs refer to virtual IPs that do not have service read / write operations, that is, virtual IPs that are in a non-service state both during and after the reallocation. Moving non-service IPs between nodes will not burden that node. When there are non-service IPs on the original node of the service IP before the reallocation after the reallocation, the node number of the non-service IP on the original node and the node number of the service IP that needs to be transferred to the original node can be swapped, thereby moving the non-service IP to the original node of the service IP, and the service IP is then reallocated to that original node.
[0121] By exchanging node numbers, we ensure that services on the business IP will not be interrupted after the business IP returns to the original node.
[0122] For example, virtual IP groups include:
[0123] Virtual IP Group 1: VIP1, VIP4;
[0124] Virtual IP Group 2: VIP3, VIP2;
[0125] Virtual IP Group 3: VIP5;
[0126] After the reallocation, the following node and virtual IP allocation is achieved (at this point, each virtual IP group is evenly distributed across all nodes and different network interfaces on those nodes):
[0127] Node N1: VIP2 (business IP), VIP4 (non-business IP);
[0128] Node N2: VIP1 (business IP), VIP5 (non-business IP);
[0129] Node N3: VIP3 (Business IP);
[0130] Among them, VIP1 (business IP) was transferred from node N1 to node N2 before and after the reallocation, and VIP1 (business IP) is a business IP.
[0131] Therefore, the goal is to reassign VIP1 (service IP) back to its original node N1. If VIP4 (non-service IP) already exists on node N1 after the reassignment, since VIP1 (service IP) and VIP4 (non-service IP) belong to the same virtual IP group, their node numbers can be swapped, and the balanced distribution of each virtual IP group across all nodes and different network cards on those nodes can be maintained.
[0132] Check node N1: Node N1 currently has VIP2 (business IP) and VIP4 (non-business IP).
[0133] Perform the swap operation: Swap virtual IPs: Move VIP1 to node N1, and move VIP4 from node N1 to node N2.
[0134] New allocation results:
[0135] Node N1: VIP1 (Business IP) and VIP2 (Business IP);
[0136] Node N2: VIP4 (non-business IP) and VIP5 (non-business IP);
[0137] Node N3: VIP3 (Business IP);
[0138] Through the exchange, the service IP (VIP1) ensures the continuity of services on node N1, and the number of virtual IPs on node N1 remains unchanged. Each group of virtual IPs is evenly distributed across various nodes and different network cards on the nodes, thereby ensuring a reasonable load distribution across each node.
[0139] Through the above embodiments, the problem of uneven resource distribution or load imbalance on nodes after adjusting the service IP can be solved while ensuring that the service of the service IP is not interrupted, thereby ensuring that a reasonable load distribution is maintained on each node.
[0140] Optionally, determining the load of each virtual IP on each node for each node that has reassigned virtual IPs includes:
[0141] For each virtual IP group, the master node sends messages to each node to query the load status of each virtual IP on each node according to the service type, and obtain the business query results.
[0142] Save the business query results, and based on the business query results, mark the virtual IPs of each node as business IPs or non-business IPs according to whether they are providing services;
[0143] Virtual IPs that are currently providing services are marked as service IPs, while virtual IPs that are not currently providing services are marked as non-service IPs.
[0144] Specifically, in one embodiment, the master node of the distributed storage system can query and classify the load status of virtual IPs on each node, and mark the virtual IPs according to their load status. The master node is a control node in the system, responsible for coordinating and managing the load balancing of virtual IPs and other operations. The master node sends query requests to each node, requesting each node to report the load status of the virtual IPs on its nodes.
[0145] The following is a detailed explanation of this section, along with examples:
[0146] The master node sends messages to each node to obtain the load information of multiple virtual IPs on each node. It then queries the load information of the virtual IPs on each node according to the service type, obtaining the business query result. The service type represents different types of services, including different types of traffic or tasks, such as HTTP requests and database queries. After receiving the load information of the virtual IPs returned by each node, the master node collects this information and forms a business query result. The master node then saves the collected load information to a database or other storage system.
[0147] Then, the master node marks the virtual IPs based on the business query results, that is, the master node classifies and marks the virtual IPs according to whether the virtual IPs are providing services.
[0148] in:
[0149] Business IP: refers to the virtual IPs that are currently processing business requests.
[0150] Non-business IPs: These are virtual IPs that do not handle business requests. They may be used for management, monitoring, backup, or other purposes, or there may be no business that needs to be processed at the moment.
[0151] Based on the saved business query results, the master node marks each virtual IP as either a "business IP" or a "non-business IP".
[0152] For example, suppose a distributed storage system has three nodes (N1, N2, N3) and several virtual IPs. The master node needs to query the load status of these virtual IPs and mark them.
[0153] The master node sends requests to nodes N1, N2, and N3, requesting them to report the load status of each virtual IP.
[0154] Node N1: VIP1 (business IP, with business operations), VIP2 (non-business IP, no load)
[0155] Node N2: VIP3 (business IP, with business operations), VIP4 (non-business IP, no load)
[0156] Node N3: VIP5 (business IP, with business operations), VIP6 (non-business IP, no load)
[0157] The master node marks each virtual IP as:
[0158] Business IPs (currently processing business): VIP1, VIP3, VIP5;
[0159] Non-business IPs (unprocessed business): VIP2, VIP4, VIP6;
[0160] The above embodiments can help distributed storage systems better obtain the load status of virtual IPs, thereby enabling more effective load balancing and resource allocation.
[0161] Optionally, determining whether any service IPs have moved between different nodes after the virtual IPs are reallocated, based on the load conditions of each virtual IP, includes:
[0162] For each virtual IP group, iterate through all the virtual IPs contained in the virtual IP group and determine whether there is a service IP among all the virtual IPs contained in the virtual IP group;
[0163] When a non-business IP is encountered during the traversal of the virtual IP group, the traversal continues.
[0164] When a service IP is encountered during the traversal of the virtual IP group, it is determined whether the encountered service IP has moved between different nodes after being reassigned.
[0165] If the traversed business IP does not move between different nodes, the traversal continues until all virtual IPs contained in the virtual IP group have been traversed.
[0166] Specifically, in one embodiment, determining whether a service IP has moved between different nodes involves traversing and checking the movement of multiple virtual IPs contained in each virtual IP group. The following is a detailed explanation and examples:
[0167] First, each virtual IP in the virtual IP group is traversed and checked to ensure that no one is missed, and then each virtual IP is determined to be a business IP.
[0168] During the traversal, each virtual IP is checked to see if it is a business IP. If it is a business IP, further movement checks are performed; if it is not a business IP, it is skipped, and the traversal continues to the next virtual IP.
[0169] For each service IP, check whether the node where the service IP resides has changed after the reassignment. If the node has not changed, continue traversing the next virtual IP; if it has changed, record or process this movement.
[0170] After traversing all virtual IPs, whether business IPs or non-business IPs, until the traversal of the entire virtual IP group is completed.
[0171] The traversal of each virtual IP group can be performed simultaneously.
[0172] For example, suppose there is a virtual IP group containing the following virtual IPs and their node allocations:
[0173] Virtual IP group:
[0174] VIP1: Node N1 (Business IP);
[0175] VIP2: Node N1 (non-business IP);
[0176] VIP3: Node N2 (Business IP);
[0177] VIP4: Node N3 (non-business IP);
[0178] Start iterating from VIP1.
[0179] Check VIP1:
[0180] VIP1 is a business IP.
[0181] Check whether VIP1's node has changed after the reassignment. Assuming VIP1 moved from node N1 to node N2, record the movement of VIP1.
[0182] Continue iterating through the next virtual IP.
[0183] Check VIP2:
[0184] VIP2 is a non-business IP.
[0185] Skip VIP2 and continue iterating through the next virtual IP.
[0186] Check VIP3:
[0187] VIP3 is a business IP.
[0188] Check if VIP3's node has changed after the reassignment. Assuming VIP3 is still on node N2, continue traversing the next virtual IP.
[0189] Check VIP4:
[0190] VIP4 is a non-business IP address.
[0191] Skip VIP4, virtual IP group traversal complete.
[0192] Through the above embodiments, the system can determine which service IPs have been moved during the redistribution process, thereby enabling further measures to optimize load balancing and system performance.
[0193] Optionally, when a service IP is encountered during traversal of the virtual IP group, determining whether the encountered service IP has moved between different nodes after being reassigned includes:
[0194] Obtain the node number corresponding to the node where the traversed business IP is located before and after being reassigned, wherein the node number corresponding to the node before and after being reassigned includes the first node number and the second node number.
[0195] Determine whether the first node number and the second node number are equal;
[0196] When the first node number and the second node number are not equal, it is determined that the traversed business IP has moved between different nodes after being reassigned.
[0197] When the first node number and the second node number are equal, it is determined that the traversed business IP has not moved between different nodes;
[0198] Wherein, the first node number is the node number of the node where the traversed business IP was located before the reallocation, and the second node number is the node number of the node where the traversed business IP is located after the reallocation.
[0199] Specifically, in one embodiment, determining whether a service IP has undergone node movement before and after reallocation involves comparing node information before and after virtual IP reallocation.
[0200] Below is a detailed explanation of each step and a specific example:
[0201] in:
[0202] The node number represents a unique identifier for each node in the system.
[0203] The node numbers before and after the reallocation refer to the identifiers of the nodes where the service IP was located before and after the reallocation.
[0204] First, obtain the node number of the node where the business IP was located before the reallocation (first node number), obtain the node number of the node where the business IP is located after the reallocation (second node number), and determine whether the node numbers before and after are equal, that is, determine whether the first node number and the second node number are equal. Where the node numbers are equal, it means that the business IP is still on the same node before and after the reallocation. The node numbers are not equal, it means that the business IP has moved to a different node after the reallocation. If they are equal, the business IP has not moved nodes. If they are not equal, the business IP has moved nodes after the reallocation.
[0205] For example, suppose there is a virtual IP group where the service IPs are allocated as follows:
[0206] Virtual IP: VIP1
[0207] Before reallocation:
[0208] VIP1 has a node number of 101 on node N1.
[0209] After reallocation:
[0210] VIP1 has a node number of 102 on node N2.
[0211] Determine the node number:
[0212] First node number (before reallocation): 101 (node number of node N1)
[0213] Second node number (after reallocation): 102 (node number of node N2)
[0214] Compare:
[0215] 101 (first node number) and 102 (second node number) are not equal.
[0216] Determine node movement status:
[0217] Conclusion: Due to the difference between the first and second node numbers, the service IP VIP1 experienced node movement after reallocation.
[0218] The above embodiments determine whether node movement has occurred by comparing the node numbers of the service IPs before and after the reallocation. This identifies the movement of service IPs before and after virtual IP reallocation, allowing for adjustments or optimizations as needed to ensure load balancing and system stability.
[0219] Optionally, the step of reallocating each virtual IP contained in each virtual IP group to each node includes:
[0220] The LPC2 algorithm is used to calculate the balanced distribution of each virtual IP group on each node and different network interfaces.
[0221] According to the balanced allocation result, each virtual IP in the virtual IP group is redistributed to each node.
[0222] Specifically, in one embodiment, the LPC2 algorithm (an algorithm for load balancing; LPC2 often stands for "Least-Partial-Capacity-2") can be used to calculate the load balancing result for each virtual IP group across various nodes and network interfaces during the allocation of virtual IPs to each node according to virtual IP groups. This includes considering the current load, capacity, and other performance metrics of each node. The balanced allocation result represents the optimal allocation scheme for each virtual IP across various nodes and network interfaces. The virtual IPs contained in the virtual IP groups are then redistributed to the respective nodes.
[0223] The above embodiments can optimize the allocation of virtual IPs, making the load on the distributed storage system more even and improving overall performance and stability.
[0224] Optionally, in one embodiment, when a service IP moves between nodes after a virtual IP is reassigned, it is necessary to determine whether there is a non-service IP in the same virtual IP group as the service IP, and whether the non-service IP is on the original node where the service IP was before the reassignment. If so, the node numbers between the non-service IP and the service IP can be directly exchanged.
[0225] In another scenario, when there are no non-business IPs that meet the above conditions, the following methods can be used to ensure that the business IPs can be adjusted to the original node.
[0226] Method 1: When there are no non-service IPs belonging to the same virtual IP group on the original node, determine whether there are non-service IPs belonging to other virtual IP groups on the original node. If so, the node numbers of the non-service IPs belonging to other virtual IP groups and the service IPs can be exchanged. After the service of the service IP is completed, the node numbers of the non-service IPs belonging to other virtual IP groups and the service IPs can be exchanged again. This can prioritize the preservation of the continuity of the client's service. At the same time, the exchange is performed again after the service is completed to ensure that the virtual IPs of each network port are evenly distributed on different nodes and network cards.
[0227] Method 2: Provide an additional redundant node. Under normal conditions, the redundant node does not need to be assigned a virtual IP. When no non-business IPs meeting the above conditions exist, ensure that even if business IPs cannot automatically relocate to the original node, other nodes can still handle the corresponding load. For example, if no non-business IPs are interacting with the node number on a certain node, then a redundant node is added to reallocate the virtual IP.
[0228] These strategies ensure that the movement of business IPs between nodes is effectively managed, thereby improving the stability and reliability of the system.
[0229] Figure 2 This is a flowchart illustrating the virtual IP allocation process for each virtual IP group in an embodiment of this application. Figure 2 As shown.
[0230] The virtual IPs provided by each network interface card (NIC) port are aggregated to form a total virtual IP pool. The virtual IPs in this pool are then grouped according to the NIC's network port, resulting in multiple virtual IP groups. The LPC2 allocation algorithm is used to calculate the allocation scheme for each virtual IP within each group across different nodes. Simultaneously, the load status of each virtual IP is marked as either a service IP or a non-service IP. The service IPs within each virtual IP group are iterated over. If the currently iterated virtual IP is not a service IP, the process continues to the next virtual IP. If it is, the process further checks if the service IP has moved between nodes after the reallocation. If not, the process continues to the next virtual IP. If it has moved, the process checks if there are any non-service nodes belonging to the same virtual IP group on the original node where the service IP was located before the reallocation. If so, the node numbers of the non-service nodes belonging to the same virtual IP group and the iterated service IP are directly swapped. This process is repeated for each virtual IP group until all virtual IPs have been iterated over.
[0231] Figure 3 This is a flowchart illustrating a virtual IP allocation method provided in another embodiment of this application, as shown below. Figure 3 As shown.
[0232] One embodiment of this application includes the following main steps:
[0233] In step S201, the virtual IPs in the virtual IP pool are grouped according to the network interface where the virtual IP is located;
[0234] In step S202, each virtual IP group independently performs virtual IP reallocation calculation;
[0235] In step S203, based on the service type, it is determined whether each virtual IP is providing services normally, and then marked accordingly;
[0236] In step S204, when a service IP moves, it is determined whether there is a non-service IP that meets the conditions, and the node numbers of the service IP and the non-service IP are exchanged.
[0237] Through the various embodiments provided above, this application first adds a mechanism for grouping virtual IPs according to different network interfaces, based on the virtual IP allocation. Dividing the virtual IP pool into different virtual IP groups according to the configured network cards, and redistributing virtual IPs relatively independently within each virtual IP group, ensures that virtual IPs under the same network interface are evenly distributed across all nodes, and also evenly distributed across different network cards on the same node. This maximizes the overall performance and throughput of the distributed storage system, significantly improves service response speed and concurrent processing capabilities, and ensures that users receive a fast and stable service experience.
[0238] Secondly, during this period, based on service type, it was confirmed whether all virtual IPs were providing services, and they were allocated and labeled. After the virtual IPs were allocated, the results of the reallocation were adjusted, and non-service nodes were moved as much as possible to ensure that service IPs remained on their original nodes. This ensured the stability and continuity of the distributed storage system's services without compromising balance.
[0239] Figure 4 This is a schematic diagram of the framework of a virtual IP allocation device provided in one embodiment of this application, as shown below. Figure 4 As shown.
[0240] This application provides a virtual IP allocation device, the device comprising:
[0241] Module 11 is used to obtain the allocation status of each virtual IP corresponding to different network interfaces in the distributed storage system on each node.
[0242] The grouping module 12 is used to group the multiple virtual IPs allocated to each node according to the network interface corresponding to the multiple virtual IPs when the allocation situation indicates that the virtual IPs corresponding to the different network interfaces are unevenly distributed on the nodes, so as to obtain multiple virtual IP groups. Each virtual IP group includes: the virtual IPs corresponding to the same network interface.
[0243] The reallocation module 13 is used to reallocate each virtual IP contained in each virtual IP group to each node.
[0244] Optionally, the device further includes:
[0245] The load condition determination module is used to determine the load condition of each virtual IP on each node after the virtual IP in each virtual IP group is reassigned to each node.
[0246] The mobility determination module is used to determine, based on the load status of each virtual IP, whether any service IPs have moved between different nodes after the virtual IPs have been reassigned.
[0247] The adjustment module is used to reassign a service IP that has moved between different nodes to the node where the service IP was before the reassignment.
[0248] Optionally, the device further includes:
[0249] The non-business IP determination module is used to determine whether there are any non-business IPs belonging to the same virtual IP group on the node where the business IP was located before the business IP that has moved between different nodes is assigned to the node where the business IP was located before the reassignment.
[0250] The adjustment module includes an adjustment unit, used to exchange the node numbers of the nodes where the non-service IP and the service IP are located when a non-service IP exists.
[0251] Optionally, the load condition determination module includes:
[0252] The business query result acquisition module is used to send messages to each node through the master node for each virtual IP group, so as to query the load status of each virtual IP on each node according to the service type and obtain the business query result.
[0253] The tagging module is used to store the business query results and, based on the business query results, tag the virtual IPs of each node as either business IPs or non-business IPs according to whether they are providing services.
[0254] Virtual IPs that are currently providing services are marked as service IPs, while virtual IPs that are not currently providing services are marked as non-service IPs.
[0255] Optionally, the movement determination module includes:
[0256] The first judgment unit is used to traverse all the virtual IPs contained in each virtual IP group and determine whether there is a service IP among all the virtual IPs contained in the virtual IP group.
[0257] The first execution unit is configured to continue traversing when a non-business IP is encountered in the virtual IP group;
[0258] The second judgment unit is used to determine whether the business IP that has been traversed has moved between different nodes after being reassigned when a business IP is traversed in the virtual IP group.
[0259] The second execution unit is used to continue traversing when the traversed business IP has not moved between different nodes, until all the virtual IPs contained in the virtual IP group have been traversed.
[0260] Optionally, the second determination unit includes:
[0261] The node number acquisition unit is used to acquire the node number corresponding to the node where the traversed business IP is located before and after being reassigned. The node number corresponding to the node before and after being reassigned includes a first node number and a second node number.
[0262] The second judgment subunit is used to determine whether the first node number and the second node number are equal;
[0263] The first determining unit is configured to determine that the traversed service IP has moved between different nodes after being reassigned when the first node number and the second node number are not equal.
[0264] The second determining unit is used to determine that the traversed service IP has not moved between different nodes when the first node number and the second node number are equal.
[0265] Wherein, the first node number is the node number of the node where the traversed business IP was located before the reallocation, and the second node number is the node number of the node where the traversed business IP is located after the reallocation.
[0266] Optionally, the load condition determination module includes:
[0267] The computing unit is used to calculate the balanced distribution results of each virtual IP group on each node and different network interfaces in turn using the LPC2 algorithm.
[0268] The reallocation unit is used to reallocate each virtual IP contained in the virtual IP group to each node according to the balanced allocation result.
[0269] Based on the same inventive concept, another embodiment of this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the virtual IP allocation method as described in any of the above embodiments.
[0270] Among them, electronic devices refer to Figure 5 , Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device 500 includes a memory 510 and a processor 520. The memory 510 and the processor 520 are connected via a bus for communication. The memory 510 stores a computer program that can run on the processor 520 to implement the steps in the virtual IP allocation method disclosed in the above embodiments of this application.
[0271] Based on the same inventive concept, another embodiment of this application also provides a computer program product, including a computer program that is executed by a processor using the virtual IP allocation method as described in any of the above embodiments.
[0272] Based on the same inventive concept, another embodiment of this application provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the virtual IP allocation method as described in any of the above embodiments.
[0273] As the apparatus is basically similar to the method embodiment, it is described in a relatively simple way. For relevant details, please refer to the description of the method embodiment.
[0274] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0275] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0276] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0277] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0278] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0279] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0280] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes the element.
[0281] The above provides a detailed description of a virtual IP allocation method, apparatus, device, and medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A virtual IP allocation method, characterized by, The method comprises: acquiring distribution of each virtual IP corresponding to each network interface in a distributed storage system on each node; when the distribution indicates that the distribution of each virtual IP corresponding to each network interface on each node is unbalanced, grouping a plurality of virtual IPs distributed to each node according to network interfaces corresponding to the plurality of virtual IPs to obtain a plurality of virtual IP groups, each virtual IP group containing each virtual IP corresponding to a same network interface; for each virtual IP group, re-distributing each virtual IP contained in the virtual IP group to each node.
2. The virtual IP allocation method according to claim 1, wherein After the re-distribution, the method further comprises: determining load conditions of each virtual IP on each node for each node to which a virtual IP is re-distributed; judging whether a service IP moves between different nodes after the re-distribution of the virtual IP based on the load conditions of each virtual IP; when the service IP moves between different nodes, distributing the service IP that moves between different nodes to a node on which the service IP was located before the re-distribution.
3. The virtual IP allocation method according to claim 2, wherein Before the distribution, the method further comprises: judging whether a non-service IP belonging to a same virtual IP group exists on the node on which the service IP was located before the re-distribution; the distribution of the service IP that moves between different nodes to the node on which the service IP was located before the re-distribution comprises exchanging node numbers of nodes on which the non-service IP and the service IP are respectively located when the non-service IP exists.
4. The virtual IP allocation method according to claim 3, wherein The determination of the load conditions of each virtual IP on each node for each node to which a virtual IP is re-distributed comprises: for each virtual IP group, sending a message to each node through a master node to query load conditions of each virtual IP on each node according to a service type to obtain a service query result; saving the service query result and marking a virtual IP of each node as a service IP or a non-service IP based on the service query result; wherein a virtual IP that is providing a service is marked as a service IP and a virtual IP that is not providing a service is marked as a non-service IP.
5. The virtual IP allocation method according to claim 3, wherein The judgment of whether a service IP moves between different nodes after the re-distribution of the virtual IP based on the load conditions of each virtual IP comprises: for each virtual IP group, traversing all virtual IPs contained in the virtual IP group and judging whether a service IP exists in all virtual IPs contained in the virtual IP group; when a non-service IP is traversed in the virtual IP group, traversing continues; when a service IP is traversed in the virtual IP group, judging whether the traversed service IP moves between different nodes after being re-distributed; When the traversed service IP is not moved between different nodes after being reassigned, the traversing continues until all virtual IPs included in the virtual IP group are traversed.
6. The virtual IP allocation method according to claim 5, wherein When the service IP is traversed in the virtual IP group, it is determined whether the traversed service IP is moved between different nodes after being reassigned. The node numbers corresponding to the nodes where the traversed service IP is located before and after being reassigned are obtained, and the node numbers corresponding to the nodes where the traversed service IP is located before and after being reassigned include a first node number and a second node number. It is determined whether the first node number and the second node number are equal. When the first node number and the second node number are not equal, it is determined that the traversed service IP is moved between different nodes after being reassigned. When the first node number and the second node number are equal, it is determined that the traversed service IP is not moved between different nodes. The first node number is the node number of the node where the traversed service IP is located before being reassigned, and the second node number is the node number of the node where the traversed service IP is located after being reassigned.
7. The virtual IP allocation method of claim 1, wherein, The method comprises the following steps: The balanced allocation results of each virtual IP group on each node and different network interfaces are calculated in sequence by using the LPC2 algorithm. According to the balanced allocation results, each virtual IP included in the virtual IP group is reassigned to each node.
8. A virtual IP allocation apparatus characterized by comprising: The apparatus comprises: An obtaining module is configured to obtain the allocation of each virtual IP corresponding to different network interfaces on each node in a distributed storage system. A grouping module is configured to group a plurality of virtual IPs allocated to each node according to the network interfaces corresponding to the plurality of virtual IPs to obtain a plurality of virtual IP groups when the allocation indicates that the allocation of each virtual IP corresponding to different network interfaces on each node is unbalanced, and each virtual IP group includes each virtual IP corresponding to a same network interface. A reassigning module is configured to reassign each virtual IP included in each virtual IP group to each node.
9. An electronic device, comprising: A computer program is stored in the memory, and the processor executes the computer program to implement the virtual IP allocation method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, A computer program is stored in the memory, and the processor executes the computer program to implement the virtual IP allocation method according to any one of claims 1-7.