A method and device for creating a server cluster

By deploying a distributed cluster in the server cluster and using slave nodes and supervisory nodes for voting and transaction synchronization, the problem of resource waste and low reliability when the master node fails is solved, and cluster operation with high reliability and data continuity is achieved. .

CN118433017BActive Publication Date: 2024-10-22SHANGHAI FANFANLANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410626415.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-10-22
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

When the existing server cluster fails, the backup node is in standby state, resulting in a waste of resources, and the standby node cannot become the new primary node, resulting in low reliability of the server cluster.

Method used

Deploy a distributed cluster, including the first master node, multiple slave nodes and multiple monitoring nodes. When the first slave node does not receive the heartbeat information of the master node, it determines the master node failure and elects a new master node through voting. Monitor nodes to synchronize transaction information to ensure data continuity.

Benefits of technology

It achieves timely switching after the master node fails, improves the reliability of the cluster and data continuity, reduces the amount of data migration, and improves node balance and system stability through hash mapping and virtual nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118433017B_ABST
    Figure CN118433017B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for creating a server cluster, the method comprising: deploying a distributed cluster, the distributed cluster comprising multiple server nodes, the server nodes comprising a master node, at least one slave node and at least one monitoring node; the master node periodically sends heartbeat information to the slave nodes, when a slave node does not receive the heartbeat information sent by the master node, it is determined that the master node is faulty, and the slave node initiates a voting election request to select a new master node; each slave node responds to the election request and sends voting information according to the set voting rules, a new master node is elected according to the voting information of each slave node, and the new master node is switched to the current master node; the monitoring node synchronizes the transaction information of the original master node to the current master node and related slave nodes. The present invention realizes cluster master node election and data synchronization when the cluster fails, so that the cluster is highly available and ensures the continuity and consistency of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of server clusters, and in particular to a method and device for creating a server cluster. Background Art

[0002] Currently, server clusters usually use the architecture of master nodes, standby nodes, and slave nodes. When the master node fails, the standby node is used as the new master node to ensure high availability of the cluster. The server cluster backs up the data of the master node through the standby node to ensure data consistency.

[0003] For example, the invention patent with publication number CN117667515A and titled "Backup management method, device, computer equipment and storage medium for active-standby cluster" discloses a backup management method, device, computer equipment and storage medium for active-standby cluster. The method includes: in response to obtaining a backup job, the database node sends backup preparation information to the cluster manager; the backup preparation information is used to instruct the cluster manager to send cluster resource lock information to each database node; when the master node currently serving as the backup entry node obtains the cluster resource lock, the backup command in the backup job is executed; the backup command is used to instruct the master node to store the master node data as a backup set to the storage server.

[0004] However, in the above invention patent, since the standby node is always in standby state before the main node fails, it causes waste of resources; in addition, when the standby node fails, the standby node cannot become the new main node, and the reliability of the server cluster is low.

[0005] Therefore, it is necessary to provide a method and device for creating a server cluster to solve the above problems. Summary of the invention

[0006] The present invention aims at solving the problems and shortcomings of the prior art and provides a method and device for creating a server cluster.

[0007] The present invention solves the above technical problems through the following technical solutions:

[0008] The present invention provides a method for creating a server cluster, the method comprising:

[0009] Deploy a distributed cluster, wherein the distributed cluster includes a plurality of server nodes, and the server nodes include a first master node, a plurality of slave nodes, and a plurality of monitoring nodes;

[0010] When the first slave node does not receive the heartbeat information sent by the first master node for more than a first time, it is determined that the master node is faulty, and the first slave node is one of the multiple slave nodes;

[0011] When the first master node fails, the first slave node initiates a voting request to elect a new master node, and the new master node is the second master node;

[0012] The multiple slave nodes send voting information to the first slave node in response to the voting election request according to a preset voting rule;

[0013] The multiple monitoring nodes synchronize the transaction information of the first master node to the second master node and the slave node.

[0014] Preferably, a first hash mapping is performed on the first master node, multiple slave nodes and multiple monitoring nodes, and the first hash mapping is hashed according to the IP addresses of the first master node, multiple slave nodes and multiple monitoring nodes; a second hash mapping is performed on the data when the first master node, multiple slave nodes and multiple monitoring nodes store or access the data; the first master node, multiple slave nodes and multiple monitoring nodes and the data are mapped to a hash ring connected end to end.

[0015] Preferably, the first master node, multiple slave nodes and multiple monitoring nodes are numbered to obtain multiple virtual nodes, and the multiple virtual nodes are subjected to a third hash mapping to be mapped to the hash ring, and a mapping relationship is formed between the multiple virtual nodes and the first master node, multiple slave nodes and multiple monitoring nodes.

[0016] Preferably, the first hash map and the second hash map are calculated by the following formula:

[0017] ,

[0018] in, Indicates the data With the first master node, multiple slave nodes and multiple supervisory nodes The mapping relationship, Indicates the data data, Indicates the node number, represents the conditional function, Indicates The position on the hash ring corresponding to the data, a value representing a position on the hash ring, Indicates that the node number corresponds to The total current load of the nodes, Represents the summation symbol.

[0019] Preferably, the multiple slave nodes sending voting information to the first slave node in response to the voting election request according to a preset voting rule includes:

[0020] The first slave node confirms the number of slave nodes participating in the voting election and the node information of the slave nodes participating in the voting election according to the voting information;

[0021] The first slave node checks the voting information, and when the number of votes obtained by a slave node participating in the voting election exceeds half of the number of slave nodes participating in the voting election, the slave node is elected as the new master node.

[0022] Preferably, the second master node starts a process, starts data synchronization and begins to send heartbeat information; closes the process of the first master node by remote calling, and the first master node closes data synchronization and stops sending heartbeat information; when the first slave node does not receive the heartbeat information sent by the first master node within a first time, it includes: the first slave node records the heartbeat timestamp when receiving the heartbeat information, if new heartbeat information is received within the first time, the heartbeat timestamp is updated, if no new heartbeat information is received within the first time, the first master node is deemed to be faulty, and the last updated heartbeat timestamp is used as the last timestamp.

[0023] Preferably, the multiple monitoring nodes monitor the status of the first master node and the multiple slave nodes, and the multiple monitoring nodes back up the transaction information of the first master node. When the second master node switches to a new master node, the multiple monitoring nodes synchronize the transaction information of the first master node before the last timestamp to the second master node and the multiple slave nodes.

[0024] Preferably, before the second master node is switched to a new master node, the method further includes:

[0025] storing the node identifier of the second master node as a target identifier of the master node, wherein the target identifier is used to identify the current master node;

[0026] The second master node sends synchronization information to the multiple slave nodes, where the synchronization information is used to instruct the multiple slave nodes to set a storage identifier to the node identifier of the second master node, where the storage identifier is used to identify a node for data storage.

[0027] Preferably, when the multiple monitoring nodes monitor that the first master node has recovered, the first master node joins the distributed cluster as a new slave node and receives the heartbeat information of the second master node. When the heartbeat information of the second master node is not received, the first master node initiates a voting election request. When the second master node fails, the first master node responds to the voting election requests of the multiple slave nodes and participates in the voting election.

[0028] The present invention also provides a device for creating a server cluster, the device comprising:

[0029] A distributed cluster deployment module, which is used to deploy a distributed cluster, wherein the distributed cluster includes a plurality of server nodes, and the server nodes include a first master node, a plurality of slave nodes, and a plurality of monitoring nodes;

[0030] A master node failure judgment module, configured to judge that the master node is faulty when a first slave node fails to receive heartbeat information sent by the first master node for a first period of time, wherein the first slave node is one of the plurality of slave nodes;

[0031] A new master node election module, which is used for the first slave node to initiate a voting election request to elect a new master node when the first master node fails, and the new master node is the second master node;

[0032] A voting information sending module, which is used to enable the multiple slave nodes to send voting information to the first slave node in response to the voting election request according to a preset voting rule;

[0033] A transaction information synchronization module is used to enable the multiple monitoring nodes to synchronize the transaction information of the first master node to the second master node and the slave node.

[0034] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0035] The server cluster creation method and device provided in the embodiment of the present invention deploy a distributed cluster, wherein the distributed cluster includes multiple server nodes, and the server nodes include a first master node, multiple slave nodes and multiple monitoring nodes; when the first slave node fails to receive the heartbeat information sent by the first master node for more than a first time, it is determined that the master node is faulty, and the first slave node is one of the multiple slave nodes; when the first master node fails, the first slave node initiates a voting election request to elect a new master node, and the new master node is a second master node; the multiple slave nodes respond to the voting election request according to a preset voting rule and send voting information to the first slave node; the multiple monitoring nodes synchronize the transaction information of the first master node to the second master node and the slave nodes; the monitoring node synchronizes the transaction information of the original master node to the current master node and the related slave nodes; the failure of the first master node is discovered in time by receiving the heartbeat information; a new second master node is generated by cluster election, and the second master node is switched in time after the failure of the first master node, so as to ensure the reliability of cluster operation; the transaction information is synchronized by multiple monitoring nodes to ensure the continuity and integrity of cluster data;

[0036] Further, a first hash mapping is performed on the first master node, multiple slave nodes, and multiple monitoring nodes, and the first hash mapping is hashed according to the IP addresses of the first master node, multiple slave nodes, and multiple monitoring nodes; a second hash mapping is performed on the data when the first master node, multiple slave nodes, and multiple monitoring nodes store or access the data; the first master node, multiple slave nodes, multiple monitoring nodes, and the data are mapped to a hash ring connected end to end, and by performing the first hash mapping and the second hash mapping, when the first master node fails, the amount of data migration is reduced;

[0037] Further, the first master node, multiple slave nodes and multiple monitoring nodes are numbered to obtain multiple virtual nodes, the multiple virtual nodes are subjected to a third hash mapping to be mapped to the hash ring, and a mapping relationship is formed between the multiple virtual nodes and the first master node, multiple slave nodes and multiple monitoring nodes. By setting multiple virtual nodes, the balance of nodes is improved, and the stability of the system is improved;

[0038] Furthermore, the first slave node confirms the number of slave nodes participating in the voting election and the node information of the slave nodes participating in the voting election according to the voting information; the first slave node checks the voting information, and when the number of votes obtained by a slave node participating in the voting election exceeds half of the number of slave nodes participating in the voting election, the slave node is elected as the new master node, and some slave nodes that are not suitable as master nodes are excluded through preset voting rules, thereby improving the reliability of the cluster;

[0039] Furthermore, the multiple monitoring nodes monitor the status of the first master node and the multiple slave nodes, and the multiple monitoring nodes back up the transaction information of the first master node. When the second master node switches to a new master node, the multiple monitoring nodes synchronize the transaction information of the first master node before the last timestamp to the second master node and the multiple slave nodes, with the last timestamp of the heartbeat information as the data synchronization point for the master node switching, thereby further ensuring the continuity and integrity of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0041] Figure 1 A schematic diagram of a process for implementing a highly available distributed cluster provided by an embodiment of the present invention;

[0042] Figure 2 A schematic diagram of the structure of a high-availability distributed cluster system provided for one embodiment of the present invention.

[0043] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0044] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0045] Based on the problems existing in the existing technology, such as Figure 1 As shown, the present invention provides a method for creating a server cluster, the method comprising:

[0046] Step S101: deploying a distributed cluster, wherein the distributed cluster includes a plurality of server nodes, and the server nodes include a first master node, a plurality of slave nodes, and a plurality of monitoring nodes;

[0047] Step S102: when the first slave node does not receive the heartbeat information sent by the first master node for more than a first time, it is determined that the master node is faulty, and the first slave node is one of the multiple slave nodes;

[0048] Step S103: when the first master node fails, the first slave node initiates a voting request to elect a new master node, and the new master node is the second master node;

[0049] Step S104: the multiple slave nodes respond to the voting request and send voting information to the first slave node according to a preset voting rule;

[0050] Step S105: The multiple monitoring nodes synchronize the transaction information of the first master node to the second master node and the slave node.

[0051] In a specific implementation, a first hash mapping is performed on the first master node, multiple slave nodes and multiple monitoring nodes, and the first hash mapping is hashed according to the IP addresses of the first master node, multiple slave nodes and multiple monitoring nodes; a second hash mapping is performed on the data when the first master node, multiple slave nodes and multiple monitoring nodes store or access the data; the first master node, multiple slave nodes, multiple monitoring nodes and the data are mapped to a hash ring connected end to end.

[0052] For example, there is one first master node, two slave nodes, and two supervisory nodes. A first hash mapping is performed on one first master node, two slave nodes, and two supervisory nodes. The first hash mapping is hashed according to the IP addresses of one first master node, two slave nodes, and two supervisory nodes. One first master node, two slave nodes, two supervisory nodes, and the data are mapped to a hash ring connected end to end. For example, the IP address of the first master node can be queried first to determine the first position of the hash ring to which it is mapped, and then the IP addresses of the two slave nodes are queried, and the positions of the following two nodes are found clockwise from the first position, i.e., the second position and the third position, and the IP addresses of the two slave nodes are mapped to the second position and the third position, and so on, and the IP addresses of the two supervisory nodes are queried, and the positions of the following two nodes are found clockwise from the third position, i.e., the fourth position and the fifth position, and the IP addresses of the two supervisory nodes are mapped to the fourth position and the fifth position. When there are more nodes, the first hash mapping is performed by analogy.

[0053] For another example, when one first master node, two slave nodes, and two monitoring nodes store or access data, a second hash mapping is performed on the data. When one first master node stores or accesses data, a second hash mapping is performed on the data, and the mapping position is between the first position and the second position. When two slave nodes store or access data, a second hash mapping is performed on the data, and the mapping position is between the second position and the third position, and between the third position and the fourth position. When two monitoring nodes store or access data, a second hash mapping is performed on the data, and the mapping position is between the fourth position and the fifth position, and between the fifth position and the first position. When there are more nodes storing or accessing data, a second hash mapping is performed by analogy.

[0054] In this way, by performing the first hash mapping and the second hash mapping, when the first master node fails, the data of the first master node can be migrated in a clockwise direction to the location of the next data, thereby reducing the amount of data migration.

[0055] In a specific implementation, the first master node, multiple slave nodes and multiple monitoring nodes are numbered to obtain multiple virtual nodes, and the multiple virtual nodes are subjected to a third hash mapping to be mapped to a hash ring, and a mapping relationship is formed between the multiple virtual nodes and the first master node, multiple slave nodes and multiple monitoring nodes.

[0056] The real nodes of the first master node, multiple slave nodes and multiple monitoring nodes are no longer mapped to the hash ring. Instead, multiple virtual nodes of the first master node, multiple slave nodes and multiple monitoring nodes are mapped to the hash ring, and the multiple virtual nodes are mapped to the real nodes of the first master node, multiple slave nodes and multiple monitoring nodes.

[0057] For example, 3 virtual nodes are set for 1 first master node, 2 slave nodes and 2 supervisory nodes respectively. 1 first master node is numbered as virtual node: first master node-01, first master node-02, first master node-03; 2 slave nodes are numbered as virtual nodes: first slave node-01, first slave node-02, first slave node-03, second slave node-01, second slave node-02, third slave node-03; 2 supervisory nodes are numbered as virtual nodes: first supervisory node-01, first supervisory node-02, first supervisory node-03, second supervisory node-01, second supervisory node-02, second supervisory node-03. In this way, there are only 5 nodes on the hash ring originally. After the introduction of virtual nodes, 15 virtual nodes will be mapped to the hash ring. In this way, if there is an access request to the virtual node of the first master node-01, the real node first master node is found from the virtual node of the first master node-01 through the mapping relationship, and the access request can access the real node first master node.

[0058] In this way, by setting up multiple virtual nodes, the balance of nodes can be improved and the stability of the system can be improved.

[0059] In a specific implementation, the first hash map and the second hash map are calculated using the following formula:

[0060] ,

[0061] in, Indicates the data With the first master node, multiple slave nodes and multiple supervisory nodes The mapping relationship, Indicates the data data, Indicates the node number, represents the conditional function, Indicates The position on the hash ring corresponding to the data, a value representing a position on the hash ring, Indicates that the node number corresponds to The total current load of the nodes, Represents the summation symbol.

[0062] In a specific implementation, the multiple slave nodes sending voting information to the first slave node in response to the voting election request according to a preset voting rule includes:

[0063] The first slave node confirms the number of slave nodes participating in the voting election and the node information of the slave nodes participating in the voting election according to the voting information;

[0064] The first slave node checks the voting information, and when the number of votes obtained by a slave node participating in the voting election exceeds half of the number of slave nodes participating in the voting election, the slave node is elected as the new master node.

[0065] In a specific implementation, the second master node starts a process, starts data synchronization and begins to send heartbeat information; by remotely calling to close the process of the first master node, the first master node closes data synchronization and stops sending heartbeat information; when the first slave node does not receive the heartbeat information sent by the first master node within a first time, it includes: when the first slave node receives the heartbeat information, it records the heartbeat timestamp, if new heartbeat information is received within the first time, it updates the heartbeat timestamp, if no new heartbeat information is received within the first time, it is determined that the first master node is faulty, and the last updated heartbeat timestamp is used as the last timestamp.

[0066] In a specific implementation, the multiple monitoring nodes monitor the status of the first master node and the multiple slave nodes, and the multiple monitoring nodes back up the transaction information of the first master node. When the second master node switches to a new master node, the multiple monitoring nodes synchronize the transaction information of the first master node before the last timestamp to the second master node and the multiple slave nodes.

[0067] In a specific implementation, before the second master node is switched to a new master node, the method further includes:

[0068] storing the node identifier of the second master node as a target identifier of the master node, wherein the target identifier is used to identify the current master node;

[0069] The second master node sends synchronization information to the multiple slave nodes, where the synchronization information is used to instruct the multiple slave nodes to set a storage identifier to the node identifier of the second master node, where the storage identifier is used to identify a node for data storage.

[0070] In a specific implementation, when the multiple monitoring nodes monitor that the first master node has recovered, the first master node joins the distributed cluster as a new slave node and receives the heartbeat information of the second master node. When the heartbeat information of the second master node is not received, the first master node initiates a voting election request. When the second master node fails, the first master node responds to the voting election requests of the multiple slave nodes and participates in the voting election.

[0071] The present invention also provides a device for creating a server cluster, such as Figure 2 As shown, the device comprises:

[0072] A distributed cluster deployment module 21, which is used to deploy a distributed cluster, wherein the distributed cluster includes a plurality of server nodes, and the server nodes include a first master node, a plurality of slave nodes, and a plurality of monitoring nodes;

[0073] A master node failure judgment module 22, configured to judge that the master node is faulty when a first slave node fails to receive the heartbeat information sent by the first master node for a first period of time, wherein the first slave node is one of the plurality of slave nodes;

[0074] A new master node election module 23, which is used for the first slave node to initiate a voting election request to elect a new master node when the first master node fails, and the new master node is the second master node;

[0075] A voting information sending module 24, which is used to enable the multiple slave nodes to send voting information to the first slave node in response to the voting election request according to a preset voting rule;

[0076] The transaction information synchronization module 25 is used to enable the multiple monitoring nodes to synchronize the transaction information of the first master node to the second master node and the slave node.

[0077] In summary, the server cluster creation method and device provided in the embodiment of the present invention deploy a distributed cluster, wherein the distributed cluster includes multiple server nodes, and the server nodes include a first master node, multiple slave nodes and multiple monitoring nodes; when the first slave node fails to receive the heartbeat information sent by the first master node for more than a first time, it is determined that the master node is faulty, and the first slave node is one of the multiple slave nodes; when the first master node fails, the first slave node initiates a voting election request to elect a new master node, and the new master node is a second master node; the multiple slave nodes respond to the voting election request according to a preset voting rule and send voting information to the first slave node; the multiple monitoring nodes synchronize the transaction information of the first master node to the second master node and the slave nodes; the monitoring node synchronizes the transaction information of the original master node to the current master node and the related slave nodes; the failure of the first master node is discovered in time by receiving the heartbeat information; a new second master node is generated by cluster election, and the second master node is switched in time after the failure of the first master node, so as to ensure the reliability of cluster operation; the transaction information is synchronized by multiple monitoring nodes to ensure the continuity and integrity of cluster data;

[0078] Further, a first hash mapping is performed on the first master node, multiple slave nodes, and multiple monitoring nodes, and the first hash mapping is hashed according to the IP addresses of the first master node, multiple slave nodes, and multiple monitoring nodes; a second hash mapping is performed on the data when the first master node, multiple slave nodes, and multiple monitoring nodes store or access the data; the first master node, multiple slave nodes, multiple monitoring nodes, and the data are mapped to a hash ring connected end to end, and by performing the first hash mapping and the second hash mapping, when the first master node fails, the amount of data migration is reduced;

[0079] Further, the first master node, multiple slave nodes and multiple monitoring nodes are numbered to obtain multiple virtual nodes, the multiple virtual nodes are subjected to a third hash mapping to be mapped to the hash ring, and a mapping relationship is formed between the multiple virtual nodes and the first master node, multiple slave nodes and multiple monitoring nodes. By setting multiple virtual nodes, the balance of nodes is improved, and the stability of the system is improved;

[0080] Furthermore, the first slave node confirms the number of slave nodes participating in the voting election and the node information of the slave nodes participating in the voting election according to the voting information; the first slave node checks the voting information, and when the number of votes obtained by a slave node participating in the voting election exceeds half of the number of slave nodes participating in the voting election, the slave node is elected as the new master node, and some slave nodes that are not suitable as master nodes are excluded through preset voting rules, thereby improving the reliability of the cluster;

[0081] Furthermore, the multiple monitoring nodes monitor the status of the first master node and the multiple slave nodes, and the multiple monitoring nodes back up the transaction information of the first master node. When the second master node switches to a new master node, the multiple monitoring nodes synchronize the transaction information of the first master node before the last timestamp to the second master node and the multiple slave nodes, with the last timestamp of the heartbeat information as the data synchronization point for the master node switching, thereby further ensuring the continuity and integrity of the data.

[0082] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0083] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for creating a server cluster, characterized in that: The method comprises: Deploy a distributed cluster, the distributed cluster comprising a plurality of server nodes, the server nodes comprising a first master node, a plurality of slave nodes and a plurality of monitoring nodes; When the first slave node does not receive the heartbeat information sent by the first master node for more than a first time, it is determined that the master node is faulty, and the first slave node is one of the multiple slave nodes; When the first master node fails, the first slave node initiates a voting request to elect a new master node, and the new master node is the second master node; The multiple slave nodes send voting information to the first slave node in response to the voting election request according to a preset voting rule; The multiple monitoring nodes synchronize the transaction information of the first master node to the second master node and the slave node; A first hash mapping is performed on the first master node, multiple slave nodes and multiple monitoring nodes, and the first hash mapping is hashed according to the IP addresses of the first master node, multiple slave nodes and multiple monitoring nodes; a second hash mapping is performed on the data when the first master node, multiple slave nodes and multiple monitoring nodes store or access the data; the first master node, multiple slave nodes, multiple monitoring nodes and the data are mapped to a hash ring connected end to end.

2. The method for creating a server cluster according to claim 1, characterized in that: The first master node, multiple slave nodes and multiple monitoring nodes are numbered to obtain multiple virtual nodes, and the multiple virtual nodes are subjected to a third hash mapping to be mapped to a hash ring, and a mapping relationship is formed between the multiple virtual nodes and the first master node, multiple slave nodes and multiple monitoring nodes.

3. The method for creating a server cluster according to claim 1, characterized in that: The first hash map and the second hash map are calculated by the following formula: , in, Indicates the data With the first master node, multiple slave nodes and multiple supervisory nodes The mapping relationship, Indicates the data data, Indicates the node number, represents the conditional function, Indicates The position on the hash ring corresponding to the data, a value representing a position on the hash ring, Indicates that the node number corresponds to The total current load of the nodes, Represents the summation symbol.

4. The method for creating a server cluster according to claim 1, characterized in that: The multiple slave nodes sending voting information to the first slave node in response to the voting election request according to the preset voting rule includes: The first slave node confirms the number of slave nodes participating in the voting election and the node information of the slave nodes participating in the voting election according to the voting information; The first slave node checks the voting information, and when the number of votes obtained by a slave node participating in the voting election exceeds half of the number of slave nodes participating in the voting election, the slave node is elected as the new master node.

5. The method for creating a server cluster according to claim 1, characterized in that: The second master node starts a process, starts data synchronization and starts sending heartbeat information; the process of the first master node is closed by remote calling, and the first master node closes data synchronization and stops sending heartbeat information; When the first slave node does not receive the heartbeat information sent by the first master node within a first time, it includes: the first slave node records the heartbeat timestamp when receiving the heartbeat information, if new heartbeat information is received within the first time, the heartbeat timestamp is updated; if no new heartbeat information is received within the first time, the first master node is deemed to be faulty, and the last updated heartbeat timestamp is used as the last timestamp.

6. The method for creating a server cluster according to claim 5, characterized in that: The multiple monitoring nodes monitor the status of the first master node and the multiple slave nodes, and the multiple monitoring nodes back up the transaction information of the first master node. When the second master node switches to a new master node, the multiple monitoring nodes synchronize the transaction information of the first master node before the last timestamp to the second master node and the multiple slave nodes.

7. The method for creating a server cluster according to claim 1, characterized in that: Before the second master node is switched to a new master node, the following steps are also included: storing the node identifier of the second master node as a target identifier of the master node, wherein the target identifier is used to identify the current master node; The second master node sends synchronization information to the multiple slave nodes, where the synchronization information is used to instruct the multiple slave nodes to set a storage identifier to the node identifier of the second master node, where the storage identifier is used to identify a node for data storage.

8. The method for creating a server cluster according to claim 1, characterized in that: When the multiple monitoring nodes monitor that the first master node has recovered, the first master node joins the distributed cluster as a new slave node and receives the heartbeat information of the second master node. When the heartbeat information of the second master node is not received, the first master node initiates a voting election request. When the second master node fails, the first master node responds to the voting election requests of the multiple slave nodes and participates in the voting election.

9. A device for creating a server cluster, characterized in that: The device comprises: A distributed cluster deployment module, which is used to deploy a distributed cluster, wherein the distributed cluster includes a plurality of server nodes, and the server nodes include a first master node, a plurality of slave nodes, and a plurality of monitoring nodes; A master node failure judgment module, configured to judge that the master node is faulty when a first slave node fails to receive heartbeat information sent by the first master node for a first period of time, wherein the first slave node is one of the plurality of slave nodes; A new master node election module, which is used for the first slave node to initiate a voting election request to elect a new master node when the first master node fails, and the new master node is the second master node; A voting information sending module, which is used to enable the multiple slave nodes to send voting information to the first slave node in response to the voting election request according to a preset voting rule; A transaction information synchronization module, used to enable the multiple monitoring nodes to synchronize the transaction information of the first master node to the second master node and the slave node; A first hash mapping is performed on the first master node, multiple slave nodes and multiple monitoring nodes, and the first hash mapping is hashed according to the IP addresses of the first master node, multiple slave nodes and multiple monitoring nodes; a second hash mapping is performed on the data when the first master node, multiple slave nodes and multiple monitoring nodes store or access the data; the first master node, multiple slave nodes, multiple monitoring nodes and the data are mapped to a hash ring connected end to end.