A method, device and storage medium for optimizing Raft cluster
By adding auxiliary nodes to the Raft cluster and ensuring that the number of nodes is an odd number, the problem of low election efficiency of the Raft algorithm in Border Leaf switches and the cluster stopping working is solved, achieving more stable operation and an efficient election process.
Patent Information
- Application Number
- CN202110389798.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-12
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-04-12
AI Technical Summary
In the Raft algorithm, the number of nodes in Border Leaf switches does not satisfy an odd number, resulting in low election efficiency. When more than half of the nodes fail, the cluster stops working and user configuration storage cannot be completed.
By adding auxiliary nodes, we ensure that the number of nodes in the cluster is an odd number, and introduce the concept of auxiliary nodes into the Raft cluster to optimize the election process so that the cluster can still run normally when working nodes fail.
It improves the operational stability and election efficiency of Border Leaf group switches, ensuring that the cluster can still provide normal services when working nodes fail, and meets the operational requirements of the Raft algorithm.
Smart Images

Figure CN113204424B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of distributed databases, and in particular to a method, device and storage medium for optimizing a Raft cluster. Background Art
[0002] In the current database construction scheme, a group of Border Leaf switches are usually built inside the data center and connected to external routing devices to achieve the connection between the data center network and the external network. This group of Border Leaf switches has the same functions and can adopt a multi-virtual-one form, which appears to the outside as a powerful logical switch for carrying communication traffic between the inside and outside of the data center. Since the configuration information stored in each Border Leaf switch needs to be consistent, OVSDB is stored in each Border Leaf switch to store the configuration information. Through unified management, a distributed cluster database is formed to achieve the purpose of consistent configuration storage information in multiple switches;
[0003] Raft is a widely used decentralized, highly available distributed protocol in engineering. The OVSDB distributed cluster database uses the Raft algorithm based on distributed consensus to achieve high availability of the cluster. However, according to the Raft algorithm, in order to facilitate the generation of election results, the cluster requires three or more participating nodes, and the number of participating nodes usually requires an odd number, and when more than half of the nodes fail, the cluster will stop working.
[0004] However, in actual use, the number of Border Leaf switches often does not meet an odd number, resulting in low election efficiency when using the Raft algorithm, and often failing to elect a cluster leader node at one time. Moreover, due to the constraints of the Raft algorithm, when more than half of the nodes fail, the cluster will stop working, resulting in the inability to continue to complete the storage of user configurations when nearly half of the switch database nodes in the cluster are normal. These problems urgently need to be optimized and resolved. Summary of the invention
[0005] The embodiments of the present invention provide a method, device and storage medium for optimizing a Raft cluster, which improve the operation stability of a borderleaf group switch and keep the number of nodes in the cluster as an odd number, so as to facilitate the stable operation of the Raft algorithm.
[0006] To achieve the above object, the embodiments of the present invention adopt the following technical solutions:
[0007] In a first aspect, an embodiment of the present invention provides a method comprising:
[0008] S1. Start the nodes in the cluster, wherein the types of nodes in the cluster after the startup operation are completed include: working nodes and auxiliary nodes, and the total number of working nodes and auxiliary nodes is an odd number;
[0009] S2. After initiating the election, the working nodes and auxiliary nodes run the voting rules and determine the node that serves as the leader from the working nodes;
[0010] S3. The node serving as the leader sends a heartbeat message to other nodes in the cluster, and the working nodes and auxiliary nodes that receive the heartbeat message follow the node serving as the leader.
[0011] In a second aspect, an embodiment of the present invention provides a device, comprising:
[0012] An initialization module is used to start the nodes in the cluster, wherein the types of nodes in the cluster after the startup operation are completed include: working nodes and auxiliary nodes, and the total number of working nodes and auxiliary nodes is an odd number;
[0013] The election module is used to run the voting rules on the working nodes and auxiliary nodes after the election is initiated, and determine the node that serves as the leader from the working nodes;
[0014] The management module is used for the node serving as the leader to send heartbeat messages to other nodes in the cluster, and the working nodes and auxiliary nodes that receive the heartbeat messages follow the node serving as the leader.
[0015] In a third aspect, an embodiment of the present invention provides a storage medium that stores a computer program or instructions. When the computer program or instructions are executed, the method provided by the embodiment of the present invention in the first aspect is implemented.
[0016] The method, device and storage medium for optimizing the Raft cluster provided by the embodiment of the present invention expand the database node base by adding auxiliary nodes. As long as there is a Leader node among the database nodes actually in use, the entire OVSDB database cluster can still operate normally, thereby improving the operating stability of the border leaf group switch. And when the border leaf group switch is an even number, the number of nodes in the cluster can be made odd by adding auxiliary nodes, so as to facilitate the operation of the Raft algorithm, thereby improving the election efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A schematic diagram of the operation flow of a working node provided in an embodiment of the present invention;
[0019] Figure 2 A schematic diagram of the auxiliary node operation process provided by an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of a specific example provided for an embodiment of the present invention;
[0021] Figure 4 , Figure 5 A schematic diagram of another specific example provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present invention will be described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention. It can be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "one", "said" and "the" used herein may also include plural forms. It should be further understood that the term "including" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say that an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used here may include wireless connection or coupling. The term "and / or" used herein includes any unit and all combinations of one or more associated listed items. It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as generally understood by those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless defined as herein.
[0023] The design idea of this embodiment is mainly to propose the concept of auxiliary nodes and apply them in the Raft cluster. The specific approach is to expand a certain number of auxiliary nodes to participate in the Raft cluster election, and further improve and optimize the Raft algorithm to achieve the effect of normal service when the cluster has only the last working node Leader left. Through auxiliary nodes, the total number of nodes in the cluster can also be easily expanded from an even number to an odd number, improving election efficiency.
[0024] An embodiment of the present invention provides a method for optimizing a Raft cluster, including:
[0025] S1. Start the nodes in the cluster, wherein the types of nodes in the cluster after the startup operation are completed include: working nodes and auxiliary nodes, and the total number of working nodes and auxiliary nodes is an odd number.
[0026] S2. After initiating the election, the working nodes and auxiliary nodes run the voting rules and determine the node that serves as the Leader from the working nodes.
[0027] S3. The node serving as the leader sends a heartbeat message to other nodes in the cluster, and the working nodes and auxiliary nodes that receive the heartbeat message follow the node serving as the leader.
[0028] Specifically, step S2 may include:
[0029] When a working node starts, it is in the Follower state. If a Leader already exists, it follows the Leader and remains in the Follower state. If it does not receive a heartbeat message from the Leader within a preset time period, it switches from the Follower state to the Candidate state and initiates an election. After the auxiliary node starts, it remains in the Follower state. If it does not receive a heartbeat message from the Leader within a preset time period, it remains silent and waits for other nodes to initiate an election.
[0030] Step S3 may include: if a working node in the Candidate state receives more than half of the votes, it switches to the Leader state. If it finds that other nodes are newer than itself during the election process, it actively switches to the Follower state and follows the existing Leader. After receiving the voting request, the auxiliary node runs the voting rules to determine whether to vote or reject, and then detects again whether it has received the heartbeat message from the Leader. If so, it follows the Leader that sent the heartbeat message.
[0031] For example: After the cluster nodes are started, the operation process of the working nodes is as follows: Figure 1 As shown, it is in Follower state at startup. If a Leader already exists, it follows the existing Leader and maintains the Follower state. If no heartbeat is received from the Leader within a period of time, it switches from Follower to Candidate and initiates an election. If the Candidate receives more than half of the votes, it switches to Leader state, where the votes received by the Candidate include its own vote. If it is found during the election that other nodes are newer than itself, it actively switches to Follower and follows the existing Leader. This process is consistent with the state migration method specified by Raft. After the cluster nodes are started, the operation process of the auxiliary nodes is as follows: Figure 2 As shown, it always stays in the Follower state after startup. If it does not receive a heartbeat from the Leader within a period of time, it will remain silent and wait for other nodes to initiate an election and then vote immediately. If a voting request is received, it will determine the vote or reject it according to the voting rules. If it receives a heartbeat from the Leader, it will follow the Leader.
[0032] Furthermore, the cluster startup operation described in this embodiment includes: detecting that the number of working nodes in the cluster is N, where N is a positive integer. Establishing N-1 auxiliary nodes and adding them to the cluster. If after completing the startup operation, an auxiliary node in the cluster fails, destroying the failed auxiliary node, and rebuilding the same number of auxiliary nodes as destroyed, and adding the rebuilt auxiliary nodes to the cluster. For example: Figure 3 As shown in the figure, when the number of cluster working nodes is N, N-1 additional auxiliary nodes are added, and the total number of cluster nodes after expansion becomes 2N-1. The effect is achieved: when N-1 working nodes of the original cluster fail and only the last working node Leader is left, the cluster can still work normally. Because at this time the cluster still has 1 Leader and N-1 auxiliary nodes among the working nodes, and more than half of the total N nodes are working normally, the cluster will continue to run. If an individual auxiliary node fails, the same number of auxiliary nodes will be immediately destroyed and rebuilt to supplement it, so that the number of auxiliary nodes always remains at N-1.
[0033] In this embodiment, the nodes participating in the cluster can be divided into two categories: 1) Working nodes: data storage nodes running inside the switch, the working state machine is consistent with the definition of the Raft algorithm, and can switch between the three states of leader (Leader), follower (Follower) and candidate (Candidate) defined by Raft. 2) Auxiliary nodes: running inside the server, this is a node used to improve the reliability of the working node. Its operating state is different from the operating state machine defined by Raft. It always works in the Follower state, will never become the leader in the cluster, and will never actively initiate an election. That is, the auxiliary node can be set on an external server. On the one hand, the reliability of the cluster is further enhanced by storing copies outside the device; on the other hand, it saves precious device memory on the borderleaf switch.
[0034] Specifically, the OVSDB node in the Borderleaf switch that supports the operation of the data center equipment, or other types of distributed cluster storage nodes implemented using the raft algorithm, are configured as working nodes in the cluster, and an OVSDB node is established on the server to join the cluster as an auxiliary node of the cluster; or other types of distributed cluster storage nodes implemented using the raft algorithm are joined to the cluster as auxiliary nodes of the cluster.
[0035] Furthermore, the present embodiment is also designed for the log consistency problem in cluster operation, wherein: in the cluster after the startup operation is completed, the number of working nodes operating normally is ≥2. When the leader receives a request sent by the client, the leader will add the request as new content to the log. Then the log is sent to other followers in the network through a message, thereby copying the log. After receiving the log message, the follower will return a reply of successful copying. When the leader receives confirmation of successful copying from most followers in the network, and the confirmed nodes include a working node other than the leader, the leader believes that the log can be submitted in the process of updating the log, and the nodes confirmed by the log include a working node other than the leader. It can be understood that the requirements of the data consistency constraints within the cluster of this embodiment are extended on the basis of the original Raft. Specifically, the Raft data consistency constraints include: 1) When a log is copied to most nodes, the log submission will be confirmed to ensure that it will not roll back. 2) The leader must contain the latest confirmed log, so the leader will only append the log and will not delete the overwrite log. 3) If the logs at a certain position of different nodes are the same, then all logs before this position must be the same. After adding auxiliary nodes, since only working nodes will actively initiate elections, and even if the auxiliary nodes have the latest log copies, they will not actively initiate elections to become new leaders when the leader fails, the following constraint rules need to be extended: When the number of working nodes in the cluster that are operating normally is greater than or equal to 2, the majority of nodes confirmed by the logs must include a working node other than the leader, so that Raft can ensure that the logs copied to the majority of nodes will not be rolled back. Because when the leader fails, other working nodes with the latest logs can become new leaders through elections. From the perspective of voters, giving votes requires two conditions to be met at the same time: 1) First come, first served. 2) The logs owned by the candidate who sends the election request cannot be lower than its own. Point 7 combined with point 6 ensures that only working nodes with the latest logs are eligible to be elected as new leaders. Therefore, a constraint is added to the original raft consistency guarantee requirement - when the number of normally operating working nodes in the cluster is greater than or equal to 2, the majority of nodes confirmed by the log must include a working node other than the Leader, so that Raft can ensure that the logs copied to the majority of nodes will not be rolled back.
[0036] The following is an example of the implementation of this embodiment in combination with a specific application scenario in actual application:
[0037] In terms of architecture design, there are 11 AK nodes in the entire distributed database cluster, of which 6 are AF nodes on BorderLeaf and 5 are GK nodes on the server, meeting the requirement of N working nodes and N-1 auxiliary nodes.
[0038] In terms of node operation, the Raft algorithm divides time into terms, and each term begins with a Leader election. After the Leader is successfully elected, the Leader will manage the entire cluster during the entire term. Currently, we are in term 3, and Node A has become the Leader through election, and other nodes are in the Follow state. After the Leader is elected, it starts to receive configuration requests from clients. The Leader assigns a Log index to the configuration request, numbers and marks the logs by the Log index, and then replicates the log entries to other nodes in parallel. When this log is copied to most servers, the Leader applies this log to its state machine and returns the execution result to the client. The cluster internally confirms that the log corresponding to Logindex is committed and will not be rolled back. The log submission of Logindex=5 has been completed in the current cluster, because Log5 has been confirmed by more than half of the nodes A, B, G, H, I, J, and K, and when the number of working nodes in the cluster that are operating normally is greater than or equal to 2, the majority of nodes confirmed by the log must include a working node other than the Leader. Here, Node B confirms the log submission of Logindex=5, which satisfies this constraint.
[0039] If at a certain moment, Figure 4 As shown, node A fails, and all followers have not received a heartbeat from the Leader for a period of time. The working nodes B, C, D, E, and F switch from Follower to Candidate and initiate an election. The auxiliary nodes G, H, I, J, and K know that the primary node has failed, and will continue to remain silent and will not actively initiate an election. According to the timeout of the Leader's heartbeat, B, C, D, E, and F successively enter the Candidate state and start to vote. When G, H, I, J, and K receive voting requests from C, D, E, and F, they find that the Logindex carried in the voting request is smaller than their own, indicating that the log is not as new as their own, and they will not give their votes. When they receive B's voting request, they find that the Logindex carried in the voting request is the same size as their own, which meets the voting requirements, and cast their votes for B; B obtains more than half of the votes (B, G, H, I, J, and K), is successfully elected as the new Leader, and continues to receive configuration requests from clients. Due to a new election, we are currently entering Term 4. During this term, if Figure 5 In that case, the worst case scenario occurs, and the C, D, E, and F working nodes also fail one after another and cannot work. At this time, there are still B, G, H, I, J, and K nodes that are normal. More than half of the nodes in the cluster are working normally, so the cluster continues to run.
[0040] The new configuration request submitted by the user is assigned log index = 7. Since B, G, H, and K have all confirmed the log, the result of successful configuration is returned to the user. At this time, the number of normal working nodes in the cluster is less than 2, and the majority of nodes confirmed by the log are no longer required to include a working node other than the Leader.
[0041] From the implementation of the above embodiment in the application scenario, it can be seen that when the original working nodes of the database cluster are even, auxiliary nodes can be added on the external server to make the number of nodes after expansion an odd number, thereby improving the election efficiency. By expanding an appropriate number of auxiliary nodes, when a working node in the cluster fails and only the last working node Leader is left, the cluster can still work normally.
[0042] In this embodiment, the node roles in the distributed cluster database are divided into two categories: working nodes and auxiliary nodes. Among them, the main function of the auxiliary node is to expand the cluster node base, support cluster work, and only participate in elections, but not actively initiate elections. The number of working nodes and auxiliary nodes in the cluster is stipulated as follows: when the number of cluster working nodes is N, an additional N-1 auxiliary nodes are added, and the total number of cluster nodes after expansion becomes 2N-1. In addition, the auxiliary node is set on the server, and can be quickly restarted in case of failure, ensuring that more than half of the nodes in the cluster are operating normally.
[0043] This embodiment also expands the log consistency strategy: based on the original raft consistency guarantee requirement, a constraint is added - when the number of normal working nodes in the cluster is greater than or equal to 2, the majority of nodes confirmed by the log must include a working node other than the leader, so that Raft can ensure that the logs copied to the majority of nodes will not be rolled back. When the original working nodes of the database cluster are even, auxiliary nodes can be added on the external server to make the number of nodes after expansion an odd number, thereby improving election efficiency.
[0044] The solution of this embodiment expands an appropriate number of auxiliary nodes. When a working node in the cluster fails, and in extreme cases only the last working node Leader is left, the cluster can still work normally.
[0045] In an embodiment of the present invention, a device for optimizing a Raft cluster is also provided. The device can be specifically written and encapsulated into various virtual modules through a computer program, and run on a management node for managing servers. From a hardware perspective, the management node can be specifically implemented as a server device in a cluster, or a virtual machine established in the server device, or a node established in a server cluster by other common means and generally understood by those skilled in the art. The device for optimizing a Raft cluster includes:
[0046] The initialization module is used to start the nodes in the cluster, wherein the types of nodes in the cluster after the startup operation are completed include: working nodes and auxiliary nodes, and the total number of working nodes and auxiliary nodes is an odd number.
[0047] The election module is used to run the voting rules on the working nodes and auxiliary nodes after the election is initiated, and determine the node that serves as the Leader from the working nodes.
[0048] The management module is used for the node serving as the leader to send heartbeat messages to other nodes in the cluster, and the working nodes and auxiliary nodes that receive the heartbeat messages follow the node serving as the leader.
[0049] The election module is specifically used for the working node to be in the Follower state when it starts up. If it does not receive a heartbeat message from the Leader within a preset time period, it switches from the Follower state to the Candidate state and initiates an election; the auxiliary node remains in the Follower state after it starts up. If it does not receive a heartbeat message from the Leader within a preset time period, it remains silent and waits for other nodes to initiate an election;
[0050] The management module is specifically used to switch a working node in the Candidate state to the Leader state if it receives more than half of the votes; the auxiliary node runs the voting rules after receiving the voting request, and then detects again whether the heartbeat message of the Leader is received, and if so, follows the Leader that sends the heartbeat message;
[0051] The OVSDB node in the Borderleaf switch is configured as a working node in the cluster; an auxiliary node is established on the server, and when the number of working nodes is N, N-1 auxiliary nodes are established and added to the cluster, where N is a positive integer.
[0052] In an embodiment of the present invention, a storage medium is also provided, in which a computer program or instruction is stored. When the computer program or instruction is executed, the method flow mentioned in the embodiment of the present invention is implemented, such as the above-mentioned method flow S1-S3 and the specific process details therein.
[0053] In practical applications, this embodiment optimizes the Raft algorithm by innovatively adding auxiliary nodes to the Raft algorithm to meet the use requirements of the Border Leaf switch group in the data center. The addition of auxiliary nodes expands the base number of cluster nodes. When the total number of original working nodes in the cluster is N, N-1 additional auxiliary nodes are added, and the total number of cluster nodes after expansion becomes 2N-1. The following improvement purposes are achieved: 1) When the original working nodes of the database cluster are even, auxiliary nodes can be added on the external server so that the number of nodes after expansion is odd, thereby improving the election efficiency; 2) When the original cluster N-1 working nodes fail and only the last working node Leader is left, the cluster can still work normally. Because at this time the cluster still has 1 Leader working node and N-1 auxiliary nodes, a total of N nodes are working normally, and more than half of the nodes are still working. If an individual auxiliary node fails, it is immediately destroyed and rebuilt so that the number of auxiliary nodes remains stable at N-1.
[0054] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The above is only a specific implementation method of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or replacements that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for optimizing a Raft cluster, characterized in that: include: S1. Start the nodes in the cluster, wherein the types of nodes in the cluster after the startup operation are completed include: working nodes and auxiliary nodes, and the total number of working nodes and auxiliary nodes is an odd number; S2. After initiating the election, the working nodes and auxiliary nodes run the voting rules and determine the node that serves as the leader from the working nodes; S3, the node serving as the leader sends a heartbeat message to other nodes in the cluster, and the working nodes and auxiliary nodes that receive the heartbeat message follow the node serving as the leader; The OVSDB node in the Borderleaf switch is configured as a working node in the cluster; the OVSDB node established on the server joins the cluster and serves as an auxiliary node of the cluster; after the auxiliary node is started, it remains in the Follower state. If it does not receive a heartbeat message from the Leader within a preset time period, it remains silent and waits for other nodes to initiate an election; When a secondary node fails, the failed secondary node is destroyed and then rebuilt, and then the rebuilt secondary node is added to the cluster.
2. The method according to claim 1, characterized in that: Step S2 includes: When a working node starts, it is in Follower state. If it does not receive a heartbeat message from the Leader within a preset time period, it switches from Follower state to Candidate state and initiates an election.
3. The method according to claim 1, characterized in that Step S3 includes: If a working node in the Candidate state receives more than half of the votes, it switches to the Leader state; After receiving the voting request, the auxiliary node runs the voting rules, and then checks again whether it has received the heartbeat message from the Leader. If so, it follows the Leader that sent the heartbeat message.
4. The method according to claim 1, characterized in that: The cluster startup operations include: It is detected that the number of working nodes in the cluster is N, where N is a positive integer; Create N-1 auxiliary nodes and add them to the cluster.
5. The method according to claim 1, characterized in that Also includes: In the cluster after the startup operation is completed, the number of working nodes operating normally is ≥ 2; When the Leader receives a request sent by a client, it adds the request as new content to the log and then sends the log to the Follower in the network via a message.
6. A device for optimizing a Raft cluster, characterized in that: include: An initialization module is used to start the nodes in the cluster, wherein the types of nodes in the cluster after the startup operation are completed include: working nodes and auxiliary nodes, and the total number of working nodes and auxiliary nodes is an odd number; The election module is used to run the voting rules on the working nodes and auxiliary nodes after the election is initiated, and determine the node that serves as the leader from the working nodes; A management module, configured for a node serving as a leader to send a heartbeat message to other nodes in the cluster, and the working nodes and auxiliary nodes receiving the heartbeat message follow the node serving as the leader; The OVSDB node in the Borderleaf switch is configured as a working node in the cluster; the OVSDB node established on the server joins the cluster and serves as an auxiliary node of the cluster; after the auxiliary node is started, it remains in the Follower state. If it does not receive a heartbeat message from the Leader within a preset time period, it remains silent and waits for other nodes to initiate an election; When a secondary node fails, the failed secondary node is destroyed and then rebuilt, and then the rebuilt secondary node is added to the cluster.
7. The device according to claim 6, characterized in that The election module is specifically used for switching from the Follower state to the Candidate state and initiating an election if the working node does not receive a heartbeat message from the Leader within a preset time period when the working node starts. The management module is specifically used to switch a working node in the Candidate state to the Leader state if it receives more than half of the votes; the auxiliary node runs the voting rules after receiving the voting request, and then detects again whether the heartbeat message of the Leader is received, and if so, follows the Leader that sends the heartbeat message; An auxiliary node is established on the server. When the number of working nodes is N, N-1 auxiliary nodes are established and added to the cluster, where N is a positive integer.
8. A storage medium, characterized in that: A computer program or instruction is stored, and when the computer program or instruction is executed, the method according to any one of claims 1 to 5 is implemented.
