CN109379238B - CTDB main node election method, device and system of distributed cluster - Google Patents

CTDB main node election method, device and system of distributed cluster Download PDF

Info

Publication number
CN109379238B
CN109379238B CN201811534389.2A CN201811534389A CN109379238B CN 109379238 B CN109379238 B CN 109379238B CN 201811534389 A CN201811534389 A CN 201811534389A CN 109379238 B CN109379238 B CN 109379238B
Authority
CN
China
Prior art keywords
election
node
normal
nodes
ctdb
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
CN201811534389.2A
Other languages
Chinese (zh)
Other versions
CN109379238A (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 CN201811534389.2A priority Critical patent/CN109379238B/en
Publication of CN109379238A publication Critical patent/CN109379238A/en
Application granted granted Critical
Publication of CN109379238B publication Critical patent/CN109379238B/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
    • 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/0668Management of faults, events, alarms or notifications using network fault recovery by dynamic selection of recovery network elements, e.g. replacement by the most appropriate element after failure
    • 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/30Decision processes by autonomous network management units using voting and bidding

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a CTDB main node election method, a device, a system and a computer readable storage medium of a distributed cluster, which comprises the steps that after a current main node is down, a target normal node sends first election messages to other normal nodes and receives second election messages sent by other normal nodes initiating election; the target normal node judges whether other normal nodes agree to use the target normal node as a main node according to election response messages returned by other normal nodes; if yes, sending election ending messages to other normal nodes, so that the other normal nodes set the target normal node as a main node after receiving the election ending messages; if not, determining the normal nodes meeting the election conditions as the main nodes according to the preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions, so that the election time is shortened, and the election efficiency and the fault switching efficiency are improved.

Description

CTDB main node election method, device and system of distributed cluster
Technical Field
The embodiment of the invention relates to the technical field of distributed storage systems, in particular to a CTDB master node election method, device and system of a distributed cluster and a computer readable storage medium.
Background
The distributed storage is a cluster formed by a plurality of storage node servers, supports that a piece of data is stored on a plurality of nodes, each node can acquire complete data through communication among the nodes, and when the nodes are down, the complete data can be recovered according to a configured strategy. The CTDB plays a role in high availability in distributed storage, wherein the CTDB (a clustered three-dimensional database) is used as cluster high-availability management software for monitoring the state of cluster nodes, a plurality of nodes for starting the CTDB form a set of CTDB clusters, and all the nodes in the clusters select a main node for fault recovery.
The existing election mechanism of the CTDB is that after each node enters an election state, it is decided by negotiation (including the process starting time point and the physical node number size) who is the master node, and after the negotiation is completed, it needs to wait for 3 seconds for timeout, and then can determine that the election process is ended, and this 3 seconds consumed time is hard to tolerate under the harsh condition of the fault switching required time, which may result in long consumed time of the whole election process, and reduce the fault switching efficiency.
In view of the above, how to provide a CTDB master node election method, apparatus, system and computer readable storage medium for distributed cluster that solve the above technical problems becomes a problem to be solved by those skilled in the art.
Disclosure of Invention
Embodiments of the present invention provide a CTDB master node election method, apparatus, system and computer readable storage medium for a distributed cluster, which can greatly shorten election time and improve election efficiency and failover efficiency during use.
In order to solve the above technical problem, an embodiment of the present invention provides a CTDB master node election method for a distributed cluster, including:
after the current main node is down, the target normal node sends first election messages to other normal nodes and receives second election messages sent by other normal nodes initiating election; the target node is any one of all normal nodes;
the target normal node receives election response messages returned by other normal nodes, and judges whether the other normal nodes agree to use the target normal node as a main node;
if yes, sending election ending messages to other normal nodes, so that after receiving the election ending messages, the other normal nodes set the target normal node as a main node;
if not, determining the normal nodes meeting the election conditions as the main nodes according to the preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions.
Optionally, the method further includes:
and determining normal nodes which do not meet the election conditions according to preset rules and the second election messages, and returning an inconceivable election response message to the normal nodes which do not meet the election conditions.
Optionally, the first election message includes CTDB start time and a physical node number corresponding to the target normal node;
the second election message includes a CTDB start time and a physical node number corresponding to a corresponding normal node.
Optionally, the process of determining, according to the preset rule and each second election message, that the normal node meeting the election condition is the master node is as follows:
comparing the CTDB starting time of each normal node sending the second election message, judging whether the CTDB starting time of each normal node sending the second election message is the same, if so, selecting the normal node with the smallest physical node number from each normal node sending the second election message as a main node; and if not, taking the normal node with the earliest CTDB starting time as the main node.
Optionally, after the target normal node sends the first election message to each other normal node, the method further includes:
and when the target normal node does not receive the election response message returned by any one other normal node within a preset time length, executing the step of sending an election finishing message to each other normal node.
Optionally, the method further includes:
and checking whether the target normal node sets itself as a main node or not, and if not, modifying the main node of the target normal node into itself.
The embodiment of the invention correspondingly provides a CTDB master node election device of a distributed cluster, which is applied to a target normal node, wherein the target normal node is any one of all normal nodes; the method comprises the following steps:
the first sending unit is used for sending a first election message to each other normal node after the current main node is down;
the receiving unit is used for receiving second election messages sent by other normal nodes initiating elections;
a judging unit, configured to judge whether each of the other normal nodes agrees to use the target normal node as a master node according to election response messages returned by each of the other normal nodes; if yes, triggering a second sending unit; if not, triggering a screening unit;
the second sending unit is configured to send an election end message to each of the other normal nodes, so that after each of the other normal nodes receives the election end message, the target normal node is set as a master node;
and the first screening unit is used for determining normal nodes meeting election conditions as main nodes according to preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions.
Optionally, the method further includes:
and the second screening unit is used for determining the normal nodes which do not meet the election conditions according to the preset rules and the second election messages and returning the non-agreed election response messages to the normal nodes which do not meet the election conditions.
The embodiment of the invention also provides a system for electing the CTDB master node of the distributed cluster, which comprises the following steps:
a memory for storing a computer program;
a processor for implementing the steps of the CTDB master node election method of a distributed cluster as described above when executing the computer program.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the CTDB master node election method for a distributed cluster are implemented as described above.
The embodiment of the invention provides a CTDB main node election method, a device and a system of a distributed cluster and a computer readable storage medium, wherein the method comprises the following steps: after the current main node is down, the target normal node sends first election messages to other normal nodes and receives second election messages sent by other normal nodes initiating election; the target node is any one of all normal nodes; the target normal node receives the election response messages returned by other normal nodes and judges whether the other normal nodes all agree to use the target normal node as a main node or not; if yes, sending election ending messages to other normal nodes, so that after receiving the election ending messages, the other normal nodes set the target normal node as a main node; if not, determining the normal nodes meeting the election conditions as the main nodes according to the preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions.
It can be seen that, after the current master node is down, the target normal node sends a first election message to other normal nodes and also receives second election messages sent by other normal nodes, the other normal nodes return election response messages to the target normal node, when each election response message received by the target normal node is agreed, an election finishing message is sent to each other normal node, that is, each other normal node is notified to finish election, each other normal node sets the target normal node as the master node, when each election response message received by the target normal node has an unexpected response message, the target normal node determines a normal node meeting the election condition from the received election messages sent by other normal nodes as the master node and returns the agreed election response message to the normal node, thereby determining the master node. By adding the election response message and the election finishing message, the method and the device avoid that the target normal node finishes the election process after waiting for 3 seconds overtime, thereby greatly shortening the election time and improving the election efficiency and the fault switching efficiency.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed in the prior art and the embodiments 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 to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart of a CTDB master node election method for a distributed cluster according to an embodiment of the present invention;
fig. 2 is a specific flowchart of a CTDB master node election method for a distributed cluster according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a CTDB master node election device of a distributed cluster according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a CTDB main node election method, a device and a system of a distributed cluster and a computer readable storage medium, which can greatly shorten election time and improve election efficiency and fault switching efficiency in the using process.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present 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.
Referring to fig. 1, fig. 1 is a flowchart illustrating a CTDB master node election method for a distributed cluster according to an embodiment of the present invention. The method comprises the following steps:
s110: after the current main node is down, the target normal node sends first election messages to other normal nodes and receives second election messages sent by other normal nodes initiating election; the target node is any one of all normal nodes;
it should be noted that, after the current master node in the system goes down, other normal nodes (i.e., normal CTDB nodes) trigger elections, where in this embodiment, a node (target normal node) in all the normal nodes is taken as an example to describe in detail, for example, the target normal node sends a first election message to each other normal node after triggering election, and the other normal nodes also send second election messages to other normal nodes except for the target normal node after triggering election, that is, the target normal node sends the first election message to the other normal nodes, and also receives the second election messages sent by each other normal node initiating election.
S120: the target normal node receives the election response messages returned by other normal nodes, and judges whether the other normal nodes agree to use the target normal node as a main node; if yes, entering S130; if not, entering S140;
specifically, each of the other normal nodes may receive not only the first election message sent by the target normal node but also the election messages sent by the other nodes initiating the election, and after receiving the election messages, each of the other normal nodes may determine whether to agree to use the target normal node as the master node according to all the election messages received by itself and a preset rule, if the target normal node satisfies the election requirement, the other normal nodes may return the agreed election response message to the target normal node, and if the target normal node does not satisfy the election requirement, the other normal nodes may return the disagree election response message to the target normal node.
It should be noted that after receiving the election response messages returned by other normal nodes, the target normal node determines whether all the election response messages are agreed, that is, whether all the other normal nodes agree to select the target normal node as the next master node, and if yes, S130 is performed.
S130: sending election ending messages to other normal nodes so that after the other normal nodes receive the election ending messages, the target normal node is set as a main node;
specifically, when each of the other normal nodes agrees to select the target normal node as the next master node, the target normal node sends an election end message to each of the other normal nodes, and after the other normal nodes end the election end message, the other normal nodes are set in their respective nodes, and the target normal node is set as the master node, where the election end message may include an identification code of the target normal node, and specifically may include a physical node number of the target normal node. That is, after the target normal node wins the election, the whole election process is ended, other normal nodes can be quickly notified by sending the election ending message to other normal nodes, and the master nodes set by all the normal nodes can be further kept consistent.
It should be noted that after receiving the election message sent by the target normal node and agreeing that the target normal node is used as the master node, each of the other normal nodes may set the target normal node as the master node, and after receiving the election completion message sent by the target normal node again, may confirm the set master node as the target normal node again according to the node identification code carried in the election completion message to ensure that the master nodes set by all the normal nodes are consistent.
S140: and determining the normal nodes meeting the election conditions as the master nodes according to the preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions.
Specifically, if there is a message that does not agree to select the target normal node as the next master node in the election response messages of the other normal nodes, the election needs to be performed again, specifically, the target normal node may determine the normal node that meets the election condition according to a preset rule and a second election message sent by the other normal nodes involved in the election and received by the target normal node, and agree to use the normal node as the master node, and then return the agreed election response message to the normal node, so that the normal node receives the election response messages of the other normal nodes and sends an election end message after determining that the normal node is the master node, thereby ending the election process.
In this embodiment, after determining whether to agree with the election of the target normal node, each other normal node returns an election response message to the target normal node, the target normal node does not need to wait for 3 seconds to timeout before knowing an election result, and after determining that the target normal node wins the election, the target normal node may also send an election termination message like each other normal node, thereby terminating the election, achieving millisecond level in time consumed by the election, and shortening the fault switching time to second level, so as to greatly save time consumed by the election, improve the election efficiency, and further improve high availability and stability of products to a certain extent.
For example, the distributed cluster includes 4 CTDB nodes, which are node 0, node 1, node 2, and node 3, and when node 3 is down, other nodes trigger elections, which is described by taking node 0 as an example, with reference to fig. 2. After the node 0 triggers ELECTION, an ELECTION message ELECTION _ REQ is sent to other normal nodes 2 and 3, after the node 1 and the node 2 receive the ELECTION message, whether the node 0 meets the condition of winning ELECTION (namely whether the ELECTION condition is met) is checked, whether the node 0 is agreed to become the master node is determined, if so, the master node is set to be the node 0, an ELECTION response message ELECTION _ RESP is returned to the node 0 to indicate that the node 0 is agreed to become the master node, and if not, ELECTION is carried out again from the node 1 and the node 2 according to the ELECTION message sent by the node 1 and the node 2, and the corresponding node is elected to be the master node. After receiving ELECTION response messages returned by the nodes 1 and 2, the node 0 sends ELECTION END messages ELECTION _ END to the nodes 1 and 2 if the nodes 1 and 2 agree, after receiving the ELECTION END messages, the nodes 1 and 2 set the master node as 0, END the ELECTION process, and finally elect the node 0 as the master node.
Further, the method may further include:
and determining normal nodes which do not meet the election conditions according to the preset rules and the second election messages, and returning a non-agreed election response message to the normal nodes which do not meet the election conditions.
It should be noted that, when the election response messages of other normal nodes include a message that does not agree to select the target normal node as the next master node, the target normal node may further determine, according to the preset rule and the second election message received from the other normal nodes initiating the election, the normal node that does not satisfy the election condition, and return the different election response message to the normal node that does not satisfy the election condition, so that the normal node that does not satisfy the election condition does not send the election message any longer after receiving the different election response message.
Specifically, the first election message in this embodiment includes CTDB start time and physical node number corresponding to the target normal node;
the second election message includes a CTDB start time and a physical node number corresponding to the corresponding normal node.
That is, each normal node has a corresponding CTDB start time when triggering election, and which normal node is the master node may be determined according to the CTDB start time and the physical node number of each normal node, and all the election messages in this embodiment may include the CTDB start time and the physical node number of the corresponding normal node, where the physical node number may be 0, 1, 2, 3, and the like.
Further, in the step S140, the process of determining, according to the preset rule and each second election message, that the normal node meeting the election condition is the master node may specifically be:
comparing the CTDB starting time of each normal node sending the second election message, judging whether the CTDB starting time of each normal node sending the second election message is the same, if so, selecting the normal node with the smallest physical node number from each normal node sending the second election message as a main node; and if not, taking the normal node with the earliest CTDB starting time as the main node.
Specifically, after the target normal node receives the deprecated election response messages returned by other normal nodes, it indicates that when the CTDB start times of the normal nodes initiating election are different, the CTDB start time of the target normal node is not the earliest, and when the CTDB start times of the normal nodes initiating election are the same, the physical node number of the target normal node is not the smallest, so that only the normal node returns the deprecated election response message, so that one of the other normal nodes initiating election satisfies the election condition, the target normal node may determine the normal node (physical node number) corresponding to the earliest CTDB start time by comparing the CTDB start times carried in the second election messages received by the target normal node, that is, the node satisfying the election condition, and use it as the master node, at this time, an agreed election response message can be returned to the normal node; if the CTDB start time carried in each second election message is the same, then other normal nodes initiating election initiate election at the same time, at this time, the physical node numbers carried in each second election message may be compared, the normal node with the smallest physical number may be elected as the master node, and an agreed election response message is returned to the normal node. Of course, when the CTDB start time carried in each second election message is the same, it may be determined according to actual conditions whether to specifically select the normal node with the smallest physical node number as the master node or to select the normal node with the largest physical node number as the master node.
It should be further noted that, when the target normal node does not receive the election response message returned by other normal nodes after sending the first election message, the target normal node sends a second election message to each other normal node participating in election according to the received second election message, the CTDB start time carried in each second election message may be compared with the CTDB start time of the target normal node itself, if the CTDB start time of each of the other elections initiating normal nodes is less than the CTDB start time of the target normal node itself, the target normal node returns the objected election response message to each of the other normal nodes initiating the election, and when the normal node whose CTDB start time is earliest is not the target normal node itself, then an agreed election response message is returned to the normal node with the earliest CTDB start time, and an anti-election response message is returned to each normal node initiating election.
In addition, if the CTDB start time of each normal node initiating election is the same as the CTDB start time of the target normal node, the target normal node may compare the physical node number carried in each second election message with the physical node number of the target normal node itself, when the physical node number of the target normal node is the smallest, determine that it is the master node, and return an objected election response message to each normal node initiating election, and if the physical node number of the target normal node is not the smallest, select the normal node with the smallest physical node number from each normal node initiating election, and return an agreed election response message to the normal node, and return an objected election response message to each normal node initiating election.
Further, after the target normal node sends the first election message to each of the other normal nodes in S110, the method further includes:
and when the target normal node does not receive the election response message returned by any other normal node within the preset time length, executing the step of sending an election finishing message to each other normal node.
It should be noted that, in order to avoid that the time consumed by the election is long because the target normal node cannot receive the election response message returned by each other normal node in time due to the network anomaly, the target normal node may not receive the election response message returned by the other normal node within a preset time (for example, 3 seconds) after the target normal node sends the first election message to each other normal node, and then each other normal node may agree with the target normal node as the master node, and at this time, the target normal node sends the election end message to each other normal node to end the election, and each other normal node sets the target normal node as the master node after receiving the election end message, so that the master nodes set by each normal node are kept consistent.
In addition, when the target normal node does not receive the election response message returned by any other normal node within the preset time length, each normal node is informed to carry out re-election so as to elect the final master node.
Further, the method further comprises:
and checking whether the target normal node sets itself as the master node or not, and if not, modifying the master node of the target normal node into itself.
It should be noted that, after the target normal node sends the election end message to each of the other normal nodes, the setting condition of the target normal node may also be checked to further determine whether to set the target normal node as the master node, and when the target normal node is not set as the master node, the setting is modified, that is, the setting information is changed to set the target normal node as the master node, so as to further ensure that the master nodes set in all the normal nodes are consistent.
It can be seen that, after the current master node is down, the target normal node sends a first election message to other normal nodes and also receives second election messages sent by other normal nodes, the other normal nodes return election response messages to the target normal node, when each election response message received by the target normal node is agreed, an election finishing message is sent to each other normal node, that is, each other normal node is notified to finish election, each other normal node sets the target normal node as the master node, when each election response message received by the target normal node has an unexpected response message, the target normal node determines a normal node meeting the election condition from the received election messages sent by other normal nodes as the master node and returns the agreed election response message to the normal node, thereby determining the master node. By adding the election response message and the election finishing message, the method and the device avoid ending the election process after the target normal node waits for 3 seconds overtime, thereby greatly shortening the election time, improving the election efficiency and the fault switching efficiency, and further improving the high availability and stability of products to a certain extent.
On the basis of the foregoing embodiments, the present invention correspondingly provides a CTDB master node election device for a distributed cluster, which is applied to a target normal node, where the target normal node is any one of all normal nodes, and specifically refer to fig. 3. The device includes:
the first sending unit 31 is configured to send a first election message to each other normal node after the current master node is down;
a receiving unit 32, configured to receive a second election message sent by each normal node initiating other elections;
a judging unit 33, configured to judge, according to the election response message returned by each other normal node, whether each other normal node agrees to use the target normal node as the master node; if yes, triggering a second sending unit 34; if not, the screening unit 35 is triggered;
a second sending unit 34, configured to send an election end message to each other normal node, so that after each other normal node receives the election end message, a target normal node is set as a master node;
and the first screening unit 35 is configured to determine, according to the preset rule and each second election message, that the normal node meeting the election condition is the master node, and return an agreed election response message to the normal node meeting the election condition.
Further, the method also comprises the following steps:
and the second screening unit is used for determining the normal nodes which do not meet the election conditions according to the preset rules and the second election messages and returning the non-agreed election response messages to the normal nodes which do not meet the election conditions.
It should be noted that the CTDB master node election device of the distributed cluster provided in this embodiment has the same beneficial effects as the CTDB master node election method of the distributed cluster provided in the foregoing embodiment, and for specific introduction of the CTDB master node election method of the distributed cluster related in this embodiment, reference is made to the foregoing embodiment, and details of this application are not described herein again.
On the basis of the foregoing embodiment, an embodiment of the present invention further provides a CTDB master node election system for a distributed cluster, including:
a memory for storing a computer program;
a processor for implementing the steps of the CTDB master node election method of a distributed cluster as described above when executing a computer program.
For example, the processor in this embodiment is configured to implement that, after the current master node is down, the target normal node sends first election messages to other normal nodes, and receives second election messages sent by other normal nodes initiating election; the target node is any one of all normal nodes; the target normal node receives the election response messages returned by other normal nodes, and judges whether the other normal nodes agree to use the target normal node as a main node; if yes, sending election ending messages to other normal nodes, so that after receiving the election ending messages, the other normal nodes set the target normal node as a main node; if not, determining the normal nodes meeting the election conditions as the main nodes according to the preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions.
On the basis of the foregoing embodiments, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the steps of the CTDB master node election method of the distributed cluster as described above.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and 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.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (7)

1. A CTDB main node election method of a distributed cluster is characterized by comprising the following steps:
after the current main node is down, the target normal node sends first election messages to other normal nodes and receives second election messages sent by other normal nodes initiating election; the target node is any one of all normal nodes;
the target normal node receives election response messages returned by other normal nodes, and judges whether the other normal nodes agree to use the target normal node as a main node;
if yes, sending election ending messages to other normal nodes, so that after receiving the election ending messages, the other normal nodes set the target normal node as a main node;
if not, determining normal nodes meeting the election conditions as main nodes according to preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions; wherein:
the first election message comprises CTDB starting time and a physical node number corresponding to the target normal node;
the second election message comprises CTDB starting time and physical node number corresponding to the corresponding normal node;
the process of determining that the normal node meeting the election condition is the main node according to the preset rule and each second election message is as follows:
comparing the CTDB starting time of each normal node sending the second election message, judging whether the CTDB starting time of each normal node sending the second election message is the same, if so, selecting the normal node with the smallest physical node number from each normal node sending the second election message as a main node; if not, the normal node with the earliest CTDB starting time is taken as a main node;
after the target normal node sends the first election message to each other normal node, the method further includes:
and when the target normal node does not receive the election response message returned by any other normal node within a preset time length, executing the step of sending an election finishing message to other normal nodes.
2. The CTDB master node election method of distributed clustering according to claim 1, further comprising:
and determining normal nodes which do not meet the election conditions according to preset rules and the second election messages, and returning different election response messages to the normal nodes which do not meet the election conditions.
3. The CTDB master node election method of distributed clustering according to claim 1, further comprising:
and checking whether the target normal node sets itself as a main node or not, and if not, modifying the main node of the target normal node into itself.
4. A CTDB main node election device of a distributed cluster is applied to a target normal node, wherein the target normal node is any one of all normal nodes; it is characterized by comprising:
the first sending unit is used for sending a first election message to each other normal node after the current main node is down;
the receiving unit is used for receiving second election messages sent by other normal nodes initiating election;
a judging unit, configured to judge whether each of the other normal nodes agrees to use the target normal node as a master node according to election response messages returned by each of the other normal nodes; if yes, triggering a second sending unit; if not, triggering a screening unit;
the second sending unit is configured to send an election end message to each of the other normal nodes, so that after each of the other normal nodes receives the election end message, the target normal node is set as a master node;
the first screening unit is used for determining normal nodes meeting election conditions as main nodes according to preset rules and the second election messages, and returning agreed election response messages to the normal nodes meeting the election conditions; wherein:
the first election message comprises CTDB starting time and a physical node number corresponding to the target normal node;
the second election message comprises CTDB starting time and physical node number corresponding to the corresponding normal node;
the first screening unit is specifically configured to:
comparing the CTDB starting time of each normal node sending the second election message, judging whether the CTDB starting time of each normal node sending the second election message is the same, if so, selecting the normal node with the smallest physical node number from each normal node sending the second election message as a main node; if not, the normal node with the earliest CTDB starting time is taken as a main node;
after the target normal node sends the first election message to each other normal node, the method further includes:
and when the target normal node does not receive the election response message returned by any other normal node within a preset time length, executing the step of sending an election finishing message to other normal nodes.
5. The CTDB master node election apparatus of a distributed cluster according to claim 4, further comprising:
and the second screening unit is used for determining the normal nodes which do not meet the election conditions according to the preset rules and the second election messages and returning the non-agreed election response messages to the normal nodes which do not meet the election conditions.
6. A CTDB master node election system for distributed clustering, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the CTDB master node election method of a distributed cluster according to any of claims 1 to 3 when executing said computer program.
7. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of a CTDB master node election method according to any one of the claims 1 to 3 for a distributed cluster.
CN201811534389.2A 2018-12-14 2018-12-14 CTDB main node election method, device and system of distributed cluster Active CN109379238B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811534389.2A CN109379238B (en) 2018-12-14 2018-12-14 CTDB main node election method, device and system of distributed cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811534389.2A CN109379238B (en) 2018-12-14 2018-12-14 CTDB main node election method, device and system of distributed cluster

Publications (2)

Publication Number Publication Date
CN109379238A CN109379238A (en) 2019-02-22
CN109379238B true CN109379238B (en) 2022-06-17

Family

ID=65374513

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811534389.2A Active CN109379238B (en) 2018-12-14 2018-12-14 CTDB main node election method, device and system of distributed cluster

Country Status (1)

Country Link
CN (1) CN109379238B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110048898A (en) * 2019-05-14 2019-07-23 威创集团股份有限公司 A kind of distribution joined screen system method for realizing redundancy and device
CN111400112B (en) * 2020-03-18 2021-04-13 深圳市腾讯计算机系统有限公司 Writing method and device of storage system of distributed cluster and readable storage medium
CN111538763B (en) * 2020-04-24 2023-08-15 咪咕文化科技有限公司 Method for determining master node in cluster, electronic equipment and storage medium
CN112003755B (en) * 2020-08-25 2022-12-23 北京浪潮数据技术有限公司 Method, device, equipment and medium for selecting cluster master nodes
CN112799867B (en) * 2021-02-03 2022-02-18 柏科数据技术(深圳)股份有限公司 Election method based on distributed storage system and distributed storage system
CN114466081B (en) * 2021-12-23 2024-04-12 东莞市李群自动化技术有限公司 Method, system, equipment and storage medium for managing and controlling nodes of real-time channel group
CN117440031B (en) * 2023-12-15 2024-04-12 广东朝歌智慧互联科技有限公司 Method for cloud platform to issue instruction to intranet equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101217402A (en) * 2008-01-15 2008-07-09 杭州华三通信技术有限公司 A method to enhance the reliability of the cluster and a high reliability communication node
CN106161495A (en) * 2015-03-25 2016-11-23 中兴通讯股份有限公司 A kind of host node electoral machinery, device and storage system
CN106911728A (en) * 2015-12-22 2017-06-30 华为技术服务有限公司 The choosing method and device of host node in distributed system
CN107295080A (en) * 2017-06-19 2017-10-24 北京百度网讯科技有限公司 Date storage method and server applied to distributed server cluster
CN107360025A (en) * 2017-07-07 2017-11-17 郑州云海信息技术有限公司 A kind of distributed memory system cluster monitoring method and apparatus
EP3382946A1 (en) * 2017-03-30 2018-10-03 Thomson Licensing Device and method for performance monitoring

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108810100B (en) * 2018-05-22 2021-06-29 郑州云海信息技术有限公司 Method, device and equipment for electing master node

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101217402A (en) * 2008-01-15 2008-07-09 杭州华三通信技术有限公司 A method to enhance the reliability of the cluster and a high reliability communication node
CN106161495A (en) * 2015-03-25 2016-11-23 中兴通讯股份有限公司 A kind of host node electoral machinery, device and storage system
CN106911728A (en) * 2015-12-22 2017-06-30 华为技术服务有限公司 The choosing method and device of host node in distributed system
EP3382946A1 (en) * 2017-03-30 2018-10-03 Thomson Licensing Device and method for performance monitoring
CN107295080A (en) * 2017-06-19 2017-10-24 北京百度网讯科技有限公司 Date storage method and server applied to distributed server cluster
CN107360025A (en) * 2017-07-07 2017-11-17 郑州云海信息技术有限公司 A kind of distributed memory system cluster monitoring method and apparatus

Also Published As

Publication number Publication date
CN109379238A (en) 2019-02-22

Similar Documents

Publication Publication Date Title
CN109379238B (en) CTDB main node election method, device and system of distributed cluster
CN108810100B (en) Method, device and equipment for electing master node
CN106911728B (en) The choosing method and device of host node in distributed system
JP2002324047A (en) Method and system for automated session resources cleanup in distributed client/server environment
CN111614708B (en) Transaction system based on block chain
CN111901422B (en) Method, system and device for managing nodes in cluster
CN109921942B (en) Cloud platform switching control method, device and system and electronic equipment
CN107360025B (en) Distributed storage system cluster monitoring method and device
CN114268532A (en) Raft protocol-based election method, distributed system and storage medium
CN109495543B (en) Management method and device for monitors in ceph cluster
CN115622713A (en) Consensus method, device, terminal and storage medium
CN111190913A (en) Distributed lock implementation method and system
CN116260707B (en) Block chain node disaster recovery method, device and equipment based on consensus and storage medium
CN111653052B (en) Cash register system and cash register switching method
CN110704245B (en) Service cluster implementation method, device, equipment and readable storage medium
CN110781039B (en) Sentinel process election method and device
CN111538588A (en) Distributed data processing method and related device
CN115878450A (en) Method and device for executing test task
CN109634787B (en) Distributed file system monitor switching method, device, equipment and storage medium
CN113032188B (en) Method, device, server and storage medium for determining main server
CN112035070A (en) Dirty data flushing method, device, equipment and computer readable storage medium
CN114625702A (en) Data storage method, device and system and electronic equipment
CN106897024B (en) Data writing method and device
CN111901210A (en) Voice equipment awakening method, device, medium and equipment based on equipment network
CN112491986B (en) Method, device and system for distributing commands in distributed system

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