CN108881512B - CTDB virtual IP balance distribution method, device, equipment and medium - Google Patents

CTDB virtual IP balance distribution method, device, equipment and medium Download PDF

Info

Publication number
CN108881512B
CN108881512B CN201810621502.4A CN201810621502A CN108881512B CN 108881512 B CN108881512 B CN 108881512B CN 201810621502 A CN201810621502 A CN 201810621502A CN 108881512 B CN108881512 B CN 108881512B
Authority
CN
China
Prior art keywords
virtual
distributed
storage
ips
storage node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810621502.4A
Other languages
Chinese (zh)
Other versions
CN108881512A (en
Inventor
孙业宽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810621502.4A priority Critical patent/CN108881512B/en
Publication of CN108881512A publication Critical patent/CN108881512A/en
Application granted granted Critical
Publication of CN108881512B publication Critical patent/CN108881512B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1034Reaction to server failures by a load balancer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Abstract

The embodiment of the invention discloses a CTDB virtual IP balance distribution method, a device, equipment and a computer readable storage medium. The method comprises the steps of acquiring loaded virtual IPs and idle virtual IPs to be allocated in a current distributed storage cluster when a new storage node is added; and reserving the loaded virtual IP on the source storage node without drifting, and uniformly distributing the virtual IP to be distributed to each storage node of the distributed storage cluster. The technical scheme provided by the application can ensure that the virtual IP with the load does not drift and the service of the client is not interrupted, and can balance the distribution of the virtual IP, avoid the condition that the virtual IP is distributed to the same node and the corresponding load is distributed to the same node, improve the data processing performance of the distributed storage cluster, and improve the stability and the high availability of the distributed storage cluster.

Description

CTDB virtual IP balance distribution method, device, equipment and medium
Technical Field
The embodiment of the invention relates to the technical field of distributed storage, in particular to a CTDB virtual IP balanced distribution method, device and equipment and a computer readable storage medium.
Background
The distributed storage is a cluster formed by a plurality of storage node servers, one piece of data is supported to be stored on a plurality of storage nodes, each storage node can acquire complete data through communication among the nodes, and when one storage node goes down, the complete data can be recovered according to a configured strategy.
The CTDB is a high-availability management file system depending on clustering, can be shared in all nodes participating in the CTDB cluster and is used for monitoring the cluster node state and the allocation of virtual IP. When a cluster node fails, the virtual IP distributed at the node can drift to other nodes, and the read-write service of the failed node can correspondingly drift to other nodes, so that the cluster can form a high-availability cluster.
A plurality of nodes for starting the CTDB form a set of CTDB cluster, all the nodes in the cluster can select a main node for fault recovery and virtual IP allocation, namely the CTDB virtual IP allocation is uniformly allocated by the CTDB main node.
In the CTDB starting process, virtual IPs in the configuration file are evenly and randomly distributed to cluster nodes, when the nodes in the cluster fail, the CTDB executes failure switching, releases the virtual IPs distributed on the failed nodes, then drifts the IP to other normal nodes, and corresponding read-write services also drift to other normal nodes; when the failed node restarts to join the cluster, the CTDB randomly selects virtual IPs on other nodes to be allocated to the node.
The existing virtual IP allocation algorithm of the CTDB is balanced allocation and random allocation, after the node is restarted, the node is added into the CTDB to randomly select one or more virtual IPs to be allocated to the node, and when client-side connection exists on the virtual IPs and data reading and writing exist, the service of the client-side can be interrupted for a period of time, even the whole service is interrupted. For the scenario requiring uninterrupted service in the production environment, the virtual IP allocation algorithm of the CTDB open source software is obviously not applicable.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a device, and a computer-readable storage medium for allocating CTDB virtual IP in a balanced manner, which can ensure that a service of a client connected to a virtual IP with service read/write is not interrupted and improve stability and high availability of a distributed storage cluster on the premise of allocating CTDB virtual IP in a balanced manner.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
an embodiment of the present invention provides a method for allocating CTDB virtual IP in a balanced manner, including:
when a newly added storage node exists in the distributed storage cluster, acquiring a loaded virtual IP and an idle virtual IP to be allocated in the current distributed storage cluster;
and keeping the virtual IP of the source storage node of the loaded virtual IP unchanged, and uniformly distributing the virtual IP to be distributed to each storage node of the distributed storage cluster.
Optionally, the step of when there is a newly added storage node in the distributed storage cluster includes:
judging whether the number of the storage nodes in the new virtual IP table is larger than that of the storage nodes in the old virtual IP table;
if yes, adding a new storage node into the distributed storage cluster; if not, no new storage node is added into the distributed storage cluster;
the new virtual IP table is a virtual IP table of a current distributed storage cluster generated in real time; and the old virtual IP table is the virtual IP table of the distributed storage cluster after the last virtual IP allocation.
Optionally, the obtaining of the loaded virtual IP in the current distributed storage cluster includes:
sending a virtual IP request instruction for acquiring a load to each storage node in the old virtual IP table;
and receiving the loaded virtual IP instruction responded by each storage node, and summarizing the loaded virtual IP.
Optionally, the obtaining the idle virtual IP to be allocated in the current distributed storage cluster includes:
after a newly added storage node is started, calculating the average number of virtual IPs distributed to each storage node in the distributed storage cluster, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
selecting target storage nodes with the number of virtual IPs larger than the average number from all the storage nodes;
judging whether the number of the virtual IPs with loads on each target storage node is larger than the average number;
if so, taking all the space virtual IPs on the target storage node as virtual IPs to be allocated;
if not, all loaded virtual IPs and the preset number of idle virtual IPs on the target storage node are reserved, and the remaining idle virtual IPs are used as virtual IPs to be allocated, wherein the preset number is the average number and the number of the loaded virtual IPs.
Optionally, the allocating, to be balanced, each to-be-allocated virtual IP to each storage node of the distributed storage cluster includes:
sequentially distributing a first plurality of virtual IPs to be distributed for newly added storage nodes;
judging whether the residual virtual IP to be distributed still exists;
if yes, the remaining virtual IP to be distributed is distributed to each storage node in the distributed storage cluster in a balanced mode;
and the product of the value of the first number and the value of the number of the newly added storage nodes is not more than the total number of the virtual IP to be distributed.
Optionally, sequentially allocating a first plurality of virtual IPs to be allocated to the newly added storage node includes:
calculating the ratio of the number of the virtual IPs to be distributed to the number of the newly added storage nodes as a distribution reference number;
after a newly added storage node is started, calculating the average number of virtual IPs distributed to each storage node in the distributed storage cluster, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
if the distribution reference number is smaller than the average number and the number of the virtual IPs to be distributed is larger than the product of the distribution reference number and the number value of the newly added storage node, taking the distribution reference number as the first number value;
and if the distribution reference number is larger than the average number and the number of the virtual IPs to be distributed is larger than the product of the average number and the number value of the newly added storage node, taking the average number as the first number value.
Optionally, the allocating the remaining virtual IPs to be allocated to each storage node in the distributed storage cluster in a balanced manner includes:
and distributing the remaining virtual IP to be distributed in sequence according to the newly added storage node and the remaining storage nodes.
Another aspect of the embodiments of the present invention provides a device for allocating CTDB virtual IP in a balanced manner, including:
the information acquisition module is used for acquiring a loaded virtual IP and an idle virtual IP to be allocated in the current distributed storage cluster when a newly added storage node exists in the distributed storage cluster;
the virtual IP reserving module is used for reserving the virtual IP of the source storage node of the loaded virtual IP unchanged;
and the virtual IP distribution module is used for distributing the virtual IPs to be distributed to the storage nodes of the distributed storage cluster in a balanced manner.
The embodiment of the present invention further provides a device for allocating virtual IP of a CTDB, including a processor, where the processor is configured to implement the steps of the method for allocating virtual IP of a CTDB as described in any previous item when executing a computer program stored in a memory.
Finally, an embodiment of the present invention provides a computer-readable storage medium, where a virtual IP equal allocation program of a CTDB is stored on the computer-readable storage medium, and when executed by a processor, the virtual IP equal allocation program of the CTDB implements the steps of the virtual IP equal allocation method of the CTDB as described in any previous item.
The embodiment of the invention provides a CTDB virtual IP balanced distribution method, which comprises the steps of acquiring loaded virtual IPs and idle virtual IPs to be distributed in a current distributed storage cluster when a new storage node is added; and reserving the loaded virtual IP on the source storage node without drifting, and uniformly distributing the virtual IP to be distributed to each storage node of the distributed storage cluster.
The technical scheme provided by the application has the advantages that when a newly added node is added into the distributed storage cluster, loaded virtual IP and idle virtual IP in the current distributed storage cluster are distinguished, the loaded virtual IP is kept not to drift on a source storage node, the service of a client is not influenced in the starting process of the new node, the occurrence of service interruption of the client in the prior art is effectively avoided, the problem of fault back switching is solved, and the actual requirement that the service is required to be uninterrupted in a production environment is met; and then, the idle virtual IP is distributed to each storage node in a balanced manner, so that the problem that all services are concentrated on one node due to unbalanced distribution of the virtual IP, namely the load is unbalanced, the data processing performance of the distributed storage cluster is greatly improved, and the stability and the high availability of the distributed storage cluster are improved.
In addition, the embodiment of the invention also provides a corresponding implementation device, equipment and a computer readable storage medium for the CTDB virtual IP balance allocation method, so that the method has higher practicability, and the device, the equipment and the computer readable storage medium have corresponding advantages.
Drawings
In order to more clearly illustrate the embodiments or technical solutions of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for allocating CTDB virtual IP in a balanced manner according to an embodiment of the present invention;
fig. 2 is a schematic view of an interaction flow of a CTDB master node obtaining a virtual IP of each storage node according to an embodiment of the present invention;
fig. 3 is a schematic flow chart illustrating balanced allocation of virtual IPs to storage nodes according to an embodiment of the present invention;
fig. 4 is a schematic flowchart of another method for allocating CTDB virtual IP in a balanced manner according to an embodiment of the present invention;
fig. 5 is a structural diagram of a virtual IP balanced allocation apparatus of a CTDB according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the invention will be described in further detail with reference to the accompanying drawings and specific embodiments. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and claims of this application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may include other steps or elements not expressly listed.
Having described the technical solutions of the embodiments of the present invention, various non-limiting embodiments of the present application are described in detail below.
Referring to fig. 1, fig. 1 is a schematic flowchart of a virtual IP balanced allocation method for a CTDB according to an embodiment of the present invention, where the embodiment of the present invention includes the following contents:
s101: when a newly added storage node exists in the distributed storage cluster, acquiring a loaded virtual IP and an idle virtual IP to be allocated in the current distributed storage cluster.
S102: the virtual IP of the source storage node holding the virtual IP with the load is unchanged.
S103: and uniformly distributing the virtual IP to be distributed to each storage node of the distributed storage cluster.
The execution subject of the embodiment of the present invention may be a master node of the CTDB. The virtual IP is a group of IP addresses managed by the CTDB software, the CTDB software evenly allocates the IPs to each storage node in the distributed storage cluster, and the client connected to the storage node can connect the IPs to read and write the distributed cluster storage data.
The CTDB master node may generate a virtual IP table of the current distributed storage cluster according to the original algorithm. When a new storage node is added to the distributed storage cluster, the previous virtual IP table is an old virtual IP table, namely the virtual IP table of the distributed storage cluster after the last virtual IP allocation, and after the new storage node is added, the generated virtual IP table is a new virtual IP table, namely the virtual IP table of the current distributed storage cluster. Whether a new storage node is added can be judged by comparing the number of the storage nodes in the new virtual IP table with the number of the storage nodes in the old virtual IP table in real time. And if the number of the nodes of the new table is larger than that of the nodes of the old table, adding a new storage node into the scene, otherwise, adding no new storage node.
The process of the CTDB master node acquiring the loaded virtual IP in the current distributed storage cluster may be as follows, please refer to fig. 2, which specifically includes:
sending a virtual IP request instruction for acquiring a load to each storage node in the old virtual IP table; and receiving the loaded virtual IP instruction responded by each storage node, and summarizing the loaded virtual IP.
The CTDB main node sends a request message to other storage nodes (such as a CTDB X node, a CTDB Y node and a CTDB Z node) in the cluster to acquire a virtual IP (Internet protocol) loaded by each node, after each storage node receives the request, the virtual IP loaded by the current node is acquired by calling a related command (the command is provided by specific business service, such as samba/ganesha and the like) provided by a business service process, when the storage node has no business read-write, namely the command returns to be null, and when the storage node has a plurality of virtual IPs for reading and writing data, namely the command returns to a plurality of rows of virtual IPs; and then returning a loaded virtual IP composition response to the CTDB main node, wherein the CTDB main node distinguishes idle virtual IPs and loaded virtual IPs according to all virtual IPs in the current cluster, and summarizes all loaded virtual IPs.
After the CTDB master node collects the loaded virtual IPs and the idle virtual IPs, the idle virtual IPs are allocated in a balanced manner, where the allocation principle is that the loaded virtual IPs do not drift, and the idle virtual IPs are allocated in a balanced manner, and a specific allocation process may be shown in fig. 3, where the specific process may include:
after a newly added storage node is started, calculating the average number AVG of virtual IP distributed to each storage node in the distributed storage cluster;
selecting target storage nodes with the number of virtual IPs larger than the average number from all the storage nodes;
judging whether the number of the virtual IPs with loads on each target storage node is larger than the average number; if so, taking all the space virtual IPs on the target storage node as virtual IPs to be allocated; if not, all loaded virtual IPs and the preset number of idle virtual IPs on the target storage node are reserved, and the remaining idle virtual IPs are used as virtual IPs to be allocated, wherein the preset number is the average number and the number of the loaded virtual IPs.
The average number is a ratio of the total number of virtual IPs to the total number of storage nodes in the distributed storage cluster, for example, if the number of current storage nodes in the distributed storage cluster is 6 (including 2 newly added storage nodes), and the total number of virtual IPs is 12, the average number of virtual IPs allocated to each storage node is 2.
Optionally, when polling the storage nodes in the current cluster, a normal node may be selected first, where the normal node is a storage node that operates normally in a working state, and a target node is selected from the normal nodes.
When the storage nodes in the cluster are polled, if the total number of the virtual IPs on the storage node is less than or equal to the average number AVG, all the virtual IPs of the storage node are kept unchanged, namely the storage nodes with the total number of the virtual IPs less than or equal to the average number AVG are not target nodes, and the total number of the virtual IPs on each target node is greater than the average number AVG.
For each target node, if the number of loaded virtual IPs of the node is less than or equal to AVG, keeping the loaded virtual IPs unchanged, keeping (the number of AVG-service read-write virtual IPs (the number of loaded virtual IPs)) a number of idle virtual IPs unchanged on the node, filling the rest of the idle virtual IPs (to-be-allocated virtual IPs) into a to-be-allocated virtual IP list left _ IPs, if the number of loaded virtual IPs of the node is greater than AVG, keeping the loaded virtual IPs unchanged, taking all the idle virtual IPs of the node as to-be-allocated virtual IPs, adding the to-be-allocated virtual IP list left _ IPs, and directly selecting the virtual IPs from the to-be-allocated virtual IP list left _ IPs when balanced allocation of the virtual IPs is performed.
Of course, it should be noted that the virtual IP to be allocated may also be directly marked, and is not placed in the virtual IP list left _ IPs to be allocated.
After obtaining all the virtual IPs to be allocated, the newly added storage nodes may be preferentially allocated with virtual IPs, that is, a first number of virtual IPs to be allocated are sequentially allocated to the newly added storage nodes, a product of a value of the first number and a value of the number of the newly added storage nodes is not greater than a total number of the virtual IPs to be allocated, and a calculation process of the number of virtual IPs allocated to each newly added storage node may include:
calculating the ratio of the number of the virtual IPs to be distributed to the number of the newly added storage nodes as a distribution reference number;
after a newly added storage node is started, calculating the average number of virtual IPs distributed to each storage node in the distributed storage cluster, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
if the distribution reference number is smaller than the average number and the number of the virtual IPs to be distributed is larger than the product of the distribution reference number and the number value of the newly added storage nodes, taking the distribution reference number as a first numerical value;
and if the distribution reference number is larger than the average number and the number of the virtual IPs to be distributed is larger than the product of the average number and the number value of the newly added storage nodes, taking the average number as a first numerical value.
For example, the number of current storage nodes of the distributed storage cluster is 6 (including 2 newly added storage nodes), the total number of virtual IPs is 12, the number of virtual IPs to be allocated is 8, the average number of virtual IPs allocated to each storage node is 2, the number of allocation bases is 4, and then the number of virtual IPs allocated to each newly added storage node is 2.
Of course, the number of virtual IPs allocated to each newly added storage node may also be obtained without performing the above calculation, and those skilled in the art may preset the number according to the specific actual situation. For example, if more clients are connected to the newly added storage node or the data to be processed is larger, a larger number of virtual IPs can be allocated.
After the virtual IP is preferentially allocated to the newly added storage node, if the virtual IP to be allocated is left, the remaining virtual IP to be allocated is allocated to each storage node in the distributed storage cluster in a balanced manner, the newly added storage node can be preferentially allocated, and after the allocation is completed, the remaining virtual IP to be allocated is allocated to other normal storage nodes in a balanced manner.
For example, the number of current storage nodes of the distributed storage cluster is 6 (including 2 newly added storage nodes 5# and 6#), the total number of virtual IPs is 12, the number of virtual IPs to be allocated is 8, the average number of virtual IPs allocated to each storage node is 2, the number of allocation references is 4, and then the number of virtual IPs allocated to each newly added storage node is 2. The number of the remaining virtual IPs to be allocated is 8-2 × 2 — 4, and the virtual IPs may be preferentially allocated to one of the newly added 5# and 6# storage nodes, and the remaining 2 virtual IPs to be allocated may be randomly allocated to the other four storage nodes, for example, to the 1# and 3# storage nodes. Of course, the virtual IP may also be allocated according to the number of clients operated by each node and the data volume of the data to be processed, and the virtual IP is preferentially allocated to the storage node with a large data volume processing capacity.
In the technical scheme provided by the embodiment of the invention, when a newly added node is added into a distributed storage cluster, a loaded virtual IP and an idle virtual IP in the current distributed storage cluster are distinguished, the loaded virtual IP is kept not to drift on a source storage node, the service of a client is not influenced in the starting process of the new node, the occurrence of service interruption of the client in the prior art is effectively avoided, the problem of back-off of a fault is solved, and the actual requirement that the service is required to be uninterrupted in a production environment is met; and then, the idle virtual IP is distributed to each storage node in a balanced manner, so that the problem that all services are concentrated on one node due to unbalanced distribution of the virtual IP, namely the load is unbalanced, the data processing performance of the distributed storage cluster is greatly improved, and the stability and the high availability of the distributed storage cluster are improved.
Referring to fig. 4, fig. 4 is a schematic flowchart of another virtual IP balanced allocation method for a CTDB according to an embodiment of the present invention, where the embodiment of the present invention may be applied to a distributed storage system, and specifically includes the following contents:
s401: and judging whether the number of the storage nodes in the new virtual IP table of the distributed storage cluster is larger than that in the old virtual IP table, if so, executing S402.
The new virtual IP table is a virtual IP table of the current distributed storage cluster generated in real time; the old virtual IP table is the virtual IP table of the distributed storage cluster after the last virtual IP allocation
S402: and acquiring loaded virtual IPs and idle virtual IPs to be allocated in the current distributed storage cluster.
S403: the virtual IP of the source storage node holding the virtual IP with the load is unchanged.
S404: and sequentially distributing a first plurality of virtual IPs to be distributed for the newly added storage nodes.
And the product of the value of the first number and the value of the number of the newly added storage nodes is not more than the total number of the virtual IPs to be distributed.
S405: and judging whether the remaining virtual IP to be allocated still exist, if so, executing S406.
S406: and distributing the remaining virtual IP to be distributed in sequence according to the newly added storage node and the remaining storage nodes.
Therefore, the embodiment of the invention can ensure that the service of the client connected with the virtual IP with service reading and writing is not interrupted on the premise of the balanced distribution of the virtual IP, and improves the stability and high availability of the distributed storage cluster.
The embodiment of the invention also provides a corresponding implementation device for the CTDB virtual IP balance distribution method, thereby further ensuring that the method has higher practicability. The following describes a virtual IP equal allocation apparatus of a CTDB according to an embodiment of the present invention, and the following description may refer to the virtual IP equal allocation apparatus of the CTDB and the above description may refer to the virtual IP equal allocation method of the CTDB correspondingly.
Referring to fig. 5, fig. 5 is a structural diagram of a virtual IP balanced distribution apparatus of a CTDB according to an embodiment of the present invention, in an implementation manner, where the apparatus may include:
the information obtaining module 501 is configured to obtain a loaded virtual IP and an idle virtual IP to be allocated in a current distributed storage cluster when a newly added storage node exists in the distributed storage cluster.
A virtual IP reserving module 502, configured to reserve the virtual IP of the source storage node of the virtual IP with the load unchanged.
The virtual IP allocating module 503 is configured to allocate each virtual IP to be allocated to each storage node of the distributed storage cluster in a balanced manner.
Optionally, in some implementations of this embodiment, the information obtaining module 501 may include:
the judging submodule is used for judging whether the number of the storage nodes in the new virtual IP table of the distributed storage cluster is larger than that of the storage nodes in the old virtual IP table; if yes, adding a new storage node into the distributed storage cluster; if not, no new storage node is added in the distributed storage cluster; the new virtual IP table is a virtual IP table of a current distributed storage cluster generated in real time; and the old virtual IP table is the virtual IP table of the distributed storage cluster after the last virtual IP allocation.
Specifically, the information obtaining module 501 may include:
the sending submodule is used for sending a virtual IP request instruction for acquiring a load to each storage node in the old virtual IP table;
and the receiving response submodule is used for receiving the loaded virtual IP instructions responded by each storage node and summarizing the loaded virtual IPs.
In addition, the information obtaining module 501 may further include:
the first calculation submodule is used for calculating the average number of virtual IPs distributed to each storage node in the distributed storage cluster after a newly added storage node is started, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
the selection submodule is used for selecting target storage nodes with the number of virtual IPs larger than the average number from all the storage nodes;
the judging submodule is used for judging whether the number of the virtual IPs with loads on each target storage node is larger than the average number;
a to-be-allocated virtual IP statistical module, if the number of loaded virtual IPs is greater than the average number, taking all spatial virtual IPs on the target storage node as to-be-allocated virtual IPs; if the number of the virtual IPs with loads is not more than the average number, all the virtual IPs with loads and a preset number of idle virtual IPs on the target storage node are reserved, and the remaining idle virtual IPs are used as virtual IPs to be allocated, wherein the preset number is the average number and the number of the virtual IPs with loads.
Optionally, in other embodiments of this embodiment, the virtual IP allocating module 503 may include:
the distribution submodule is used for sequentially distributing a plurality of first virtual IPs to be distributed for the newly added storage nodes; the product of the value of the first number and the value of the number of the newly added storage nodes is not more than the total number of the virtual IP to be distributed;
the judging submodule is used for judging whether the residual virtual IP to be distributed still exists;
and the redistribution submodule is used for distributing the remaining virtual IP to be distributed to each storage node in the distributed storage cluster in a balanced manner.
Specifically, the allocation submodule may include:
the second calculation submodule is used for calculating the ratio of the number of the virtual IP to be distributed to the number of the newly added storage nodes as a distribution reference number;
the third computation submodule is used for computing the average number of virtual IPs distributed to each storage node in the distributed storage cluster after a newly added storage node is started, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
determining a submodule, and if the distribution reference number is smaller than the average number and the number of the virtual IPs to be distributed is larger than the product of the distribution reference number and the number value of the newly added storage nodes, taking the distribution reference number as a first numerical value; and if the distribution reference number is larger than the average number and the number of the virtual IPs to be distributed is larger than the product of the average number and the number value of the newly added storage nodes, taking the average number as a first numerical value.
The functions of the functional modules of the virtual IP balanced allocation apparatus of the CTDB according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the description related to the foregoing method embodiment, which is not described herein again.
Therefore, the embodiment of the invention can ensure that the service of the client connected with the virtual IP with service reading and writing is not interrupted on the premise of the balanced distribution of the virtual IP, and improves the stability and high availability of the distributed storage cluster.
The embodiment of the present invention further provides a virtual IP balanced distribution device for a CTDB, which specifically includes:
a memory for storing a computer program;
a processor for executing a computer program to implement the steps of the virtual IP equal allocation method of the CTDB according to any one of the above embodiments.
The functions of each functional module of the virtual IP balanced distribution device of the CTDB according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the description related to the foregoing method embodiment, which is not described herein again.
Therefore, the embodiment of the invention can ensure that the service of the client connected with the virtual IP with service reading and writing is not interrupted on the premise of the balanced distribution of the virtual IP, and improves the stability and high availability of the distributed storage cluster.
The embodiment of the present invention further provides a computer-readable storage medium, in which a virtual IP equal allocation program of a CTDB is stored, and when the virtual IP equal allocation program of the CTDB is executed by a processor, the steps of the virtual IP equal allocation method of the CTDB according to any one of the above embodiments are further provided.
The functions of the functional modules of the computer-readable storage medium according to the embodiment of the present invention may be specifically implemented according to the method in the foregoing method embodiment, and the specific implementation process may refer to the related description of the foregoing method embodiment, which is not described herein again.
Therefore, the embodiment of the invention can ensure that the service of the client connected with the virtual IP with service reading and writing is not interrupted on the premise of the balanced distribution of the virtual IP, and improves the stability and high availability of the distributed storage cluster.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The present invention provides a method, an apparatus, a device and a computer readable storage medium for allocating CTDB virtual IP in a balanced manner. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (9)

1. A CTDB virtual IP balance distribution method is characterized by comprising the following steps:
when a newly added storage node exists in the distributed storage cluster, acquiring a loaded virtual IP and an idle virtual IP to be allocated in the current distributed storage cluster;
keeping the virtual IP of the source storage node of the loaded virtual IP unchanged, and distributing the virtual IP to be distributed to each storage node of the distributed storage cluster in a balanced manner;
wherein the allocating each to-be-allocated virtual IP to each storage node of the distributed storage cluster in a balanced manner includes:
sequentially distributing a first plurality of virtual IPs to be distributed for newly added storage nodes; the product of the value of the first number and the value of the number of the newly added storage nodes is not more than the total number of the virtual IP to be distributed;
judging whether the residual virtual IP to be distributed still exists;
and if so, uniformly distributing the remaining virtual IP to be distributed to each storage node in the distributed storage cluster.
2. The method for virtual IP balanced distribution of CTDB according to claim 1, wherein when there is a newly added storage node in the distributed storage cluster, the method comprises:
judging whether the number of the storage nodes in the new virtual IP table is larger than that of the storage nodes in the old virtual IP table;
if yes, adding a new storage node into the distributed storage cluster; if not, no new storage node is added into the distributed storage cluster;
the new virtual IP table is a virtual IP table of a current distributed storage cluster generated in real time; and the old virtual IP table is the virtual IP table of the distributed storage cluster after the last virtual IP allocation.
3. The method of claim 2, wherein the obtaining loaded virtual IPs in a current distributed storage cluster comprises:
sending a virtual IP request instruction for acquiring a load to each storage node in the old virtual IP table;
and receiving the loaded virtual IP instruction responded by each storage node, and summarizing the loaded virtual IP.
4. The CTDB virtual IP balanced distribution method according to any one of claims 1 to 3, wherein the obtaining of the idle virtual IP to be distributed in the current distributed storage cluster comprises:
after a newly added storage node is started, calculating the average number of virtual IPs distributed to each storage node in the distributed storage cluster, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
selecting target storage nodes with the number of virtual IPs larger than the average number from all the storage nodes;
judging whether the number of the virtual IPs with loads on each target storage node is larger than the average number;
if so, taking all idle virtual IPs on the target storage node as virtual IPs to be allocated;
if not, all loaded virtual IPs and the preset number of idle virtual IPs on the target storage node are reserved, and the remaining idle virtual IPs are used as virtual IPs to be allocated, wherein the preset number is the average number and the number of the loaded virtual IPs.
5. The method for virtual IP balanced allocation of a CTDB as recited in claim 1, wherein said sequentially allocating a first number of virtual IPs to be allocated to the newly added storage node comprises:
calculating the ratio of the number of the virtual IPs to be distributed to the number of the newly added storage nodes as a distribution reference number;
after a newly added storage node is started, calculating the average number of virtual IPs distributed to each storage node in the distributed storage cluster, wherein the average number is the ratio of the total number of the virtual IPs in the distributed storage cluster to the total number of the storage nodes;
if the distribution reference number is smaller than the average number and the number of the virtual IPs to be distributed is larger than the product of the distribution reference number and the number value of the newly added storage node, taking the distribution reference number as the first number value;
and if the distribution reference number is larger than the average number and the number of the virtual IPs to be distributed is larger than the product of the average number and the number of the newly added storage nodes, taking the average number as the first number.
6. The method for virtual IP balanced distribution of a CTDB according to claim 1, wherein the balanced distribution of the remaining virtual IPs to be distributed to each storage node in the distributed storage cluster comprises:
and distributing the remaining virtual IP to be distributed in sequence according to the newly added storage node and the remaining storage nodes.
7. A virtual IP balanced distribution apparatus of a CTDB, comprising:
the information acquisition module is used for acquiring a loaded virtual IP and an idle virtual IP to be allocated in the current distributed storage cluster when a newly added storage node exists in the distributed storage cluster;
the virtual IP reserving module is used for reserving the virtual IP of the source storage node of the loaded virtual IP unchanged;
the virtual IP distribution module is used for distributing the virtual IPs to be distributed to the storage nodes of the distributed storage cluster in a balanced manner;
wherein the virtual IP reservation module is further configured to:
sequentially distributing a first plurality of virtual IPs to be distributed for newly added storage nodes; the product of the value of the first number and the value of the number of the newly added storage nodes is not more than the total number of the virtual IP to be distributed;
judging whether the residual virtual IP to be distributed still exists;
and if so, uniformly distributing the remaining virtual IP to be distributed to each storage node in the distributed storage cluster.
8. An apparatus for virtual IP equal distribution of a CTDB, comprising a processor for implementing the steps of the method for virtual IP equal distribution of a CTDB according to any one of claims 1 to 6 when executing a computer program stored in a memory.
9. A computer-readable storage medium, having stored thereon a virtual IP equal allocation program of a CTDB, which when executed by a processor, implements the steps of the virtual IP equal allocation method of the CTDB according to any one of claims 1 to 6.
CN201810621502.4A 2018-06-15 2018-06-15 CTDB virtual IP balance distribution method, device, equipment and medium Active CN108881512B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810621502.4A CN108881512B (en) 2018-06-15 2018-06-15 CTDB virtual IP balance distribution method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810621502.4A CN108881512B (en) 2018-06-15 2018-06-15 CTDB virtual IP balance distribution method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN108881512A CN108881512A (en) 2018-11-23
CN108881512B true CN108881512B (en) 2021-06-29

Family

ID=64339260

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810621502.4A Active CN108881512B (en) 2018-06-15 2018-06-15 CTDB virtual IP balance distribution method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN108881512B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110519406B (en) * 2019-08-16 2022-05-17 济南浪潮数据技术有限公司 Virtual address allocation method and device, CTDB cluster and storage medium
CN110674095B (en) * 2019-09-27 2022-06-10 浪潮电子信息产业股份有限公司 CTDB cluster expansion method, device and equipment and readable storage medium
CN111416884B (en) 2020-03-12 2021-08-31 苏州浪潮智能科技有限公司 CTDB virtual IP allocation method and device and distributed storage equipment
CN111770209A (en) * 2020-05-29 2020-10-13 苏州浪潮智能科技有限公司 Virtual IP redistribution method, terminal and storage medium
CN111885112A (en) * 2020-06-24 2020-11-03 广东浪潮大数据研究有限公司 Node service exception handling method, device, equipment and storage medium
CN111901448B (en) * 2020-06-29 2022-06-14 苏州浪潮智能科技有限公司 CTDB virtual IP balance distribution method for cluster node fault scene
CN111866210A (en) * 2020-07-08 2020-10-30 苏州浪潮智能科技有限公司 Virtual IP balance distribution method, system, terminal and storage medium
CN114285729B (en) * 2021-11-29 2023-08-25 苏州浪潮智能科技有限公司 Distributed cluster management node deployment method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103905531A (en) * 2014-03-14 2014-07-02 浪潮电子信息产业股份有限公司 Method for converting load balancing among nodes in cluster storage system
CN104283710A (en) * 2014-08-18 2015-01-14 四川长虹电器股份有限公司 Database cluster fault handling method and management server
CN104410557A (en) * 2014-12-25 2015-03-11 深圳中科讯联科技有限公司 Dynamic networking method and communication method based on RS-485
CN106331210A (en) * 2016-08-19 2017-01-11 中国银联股份有限公司 IP address allocation method and device for cloud computing network
CN106453360A (en) * 2016-10-26 2017-02-22 上海爱数信息技术股份有限公司 Distributed block storage data access method and system based on iSCSI (Internet Small Computer System Interface) protocol
CN107329830A (en) * 2017-06-28 2017-11-07 郑州云海信息技术有限公司 A kind of method and device of distributed cluster system optimization

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8949986B2 (en) * 2006-12-29 2015-02-03 Intel Corporation Network security elements using endpoint resources
TWI389525B (en) * 2010-02-25 2013-03-11 Gemtek Technology Co Ltd System of multiple subnet accessible data transfer and method thereof
CN102497458B (en) * 2011-12-22 2014-06-04 北京华环电子股份有限公司 Allocation method for network element IP (Internet Protocol) address
CN105704256B (en) * 2014-11-26 2019-01-08 中国移动通信集团公司 A kind of IP address management methods, devices and systems

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103905531A (en) * 2014-03-14 2014-07-02 浪潮电子信息产业股份有限公司 Method for converting load balancing among nodes in cluster storage system
CN104283710A (en) * 2014-08-18 2015-01-14 四川长虹电器股份有限公司 Database cluster fault handling method and management server
CN104410557A (en) * 2014-12-25 2015-03-11 深圳中科讯联科技有限公司 Dynamic networking method and communication method based on RS-485
CN106331210A (en) * 2016-08-19 2017-01-11 中国银联股份有限公司 IP address allocation method and device for cloud computing network
CN106453360A (en) * 2016-10-26 2017-02-22 上海爱数信息技术股份有限公司 Distributed block storage data access method and system based on iSCSI (Internet Small Computer System Interface) protocol
CN107329830A (en) * 2017-06-28 2017-11-07 郑州云海信息技术有限公司 A kind of method and device of distributed cluster system optimization

Also Published As

Publication number Publication date
CN108881512A (en) 2018-11-23

Similar Documents

Publication Publication Date Title
CN108881512B (en) CTDB virtual IP balance distribution method, device, equipment and medium
EP3433759B1 (en) Method and apparatus for expanding high-availability server cluster
CN109802986B (en) Equipment management method, system, device and server
CN106713378B (en) Method and system for providing service by multiple application servers
CN110244901B (en) Task allocation method and device and distributed storage system
CN110912972A (en) Service processing method, system, electronic equipment and readable storage medium
CN112231108A (en) Task processing method and device, computer readable storage medium and server
CN110674095B (en) CTDB cluster expansion method, device and equipment and readable storage medium
CN114020405A (en) Virtual machine scheduling method, device, equipment and medium
CN111198756A (en) Application scheduling method and device of kubernets cluster
CN111522664A (en) Service resource management and control method and device based on distributed service
WO2016206433A1 (en) Method and apparatus for balancing server load
CN111866210A (en) Virtual IP balance distribution method, system, terminal and storage medium
CN109005071B (en) Decision deployment method and scheduling equipment
CN113055461B (en) ZooKeeper-based unmanned cluster distributed cooperative command control method
CN109327520B (en) Method and device for establishing connection between terminal and server node
CN114237910A (en) Client load balancing implementation method and device
CN113596195A (en) Public IP address management method, device, main node and storage medium
US10771539B2 (en) Systems and methods for cross-cluster service provision
CN113032188A (en) Method, device, server and storage medium for determining main server
CN111274022A (en) Server resource allocation method and system
CN113254159B (en) Migration method and device of stateful service, computer equipment and storage medium
CN111416884B (en) CTDB virtual IP allocation method and device and distributed storage equipment
CN114490186A (en) Data backup rule distribution method, node, system and storage medium
US9047128B1 (en) Backup server interface load management based on available network interfaces

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant