Election method and device, computer equipment and storage medium

By receiving fault information from third-party devices and adding to the server blacklist, troubleshooting the faulty server participates in the election, solving the problem of low election success rate in traditional technology, and improving the election success rate and accuracy of fault monitoring of the server cluster.

CN119854093APending Publication Date: 2025-04-18DAWNING INFORMATION IND (BEIJING) CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411734508.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

Traditional technical election methods have the problem of low election success rate in server clusters, especially when the main server has a fake death, the election process is prone to failure.

Method used

By receiving the fault information sent by third-party devices, determine the faulty server in the server cluster and add its information to the server blacklist. Then, the election operations are performed with other servers based on the server blacklist to ensure that the faulty server is excluded from the election candidates, thereby increasing the election success rate.

Benefits of technology

By troubleshooting the server, avoiding election failure, the election success rate of the server cluster is improved. At the same time, determining fault information through third-party equipment improves the timeliness and accuracy of fault monitoring, thereby improving the accuracy of server blacklists.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119854093A_ABST
    Figure CN119854093A_ABST
Patent Text Reader

Abstract

The invention relates to an election method and device, computer equipment and a storage medium. The method comprises the following steps: receiving fault information sent by third-party equipment; determining a fault server in a server cluster according to the fault information, and adding server information of the fault server into a server blacklist; and performing election operation with other servers in the server cluster according to the server blacklist to obtain an election result. The fault server is excluded from the candidate server of the election operation through the server blacklist, the situation that the server cluster cannot work normally due to the fact that the fault server is elected as the main server is avoided, the election success rate of the server is increased, the fault information in the server cluster is determined through the third-party device, and the user experience is improved. The monitoring timeliness and accuracy of determining the fault server are improved, so that the accuracy of the server blacklist is improved, and the election success rate of the server is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of server clusters, and in particular to an election method, apparatus, computer equipment and storage medium. Background Art

[0002] Zookeeper is a distributed small file storage system that provides directory tree-style data storage and can effectively manage servers in the tree to maintain and monitor the state changes of stored data. By monitoring the changes in these data states, it can achieve data-based cluster management, unified naming services, distributed configuration management, distributed message queues, distributed locks, distributed coordination and other functions. When the zookeeper server is suspended, it will cause the zookeeper to be unable to provide services, that is, the disk of the primary server fails abnormally, and the zookeeper network between the primary server and other servers is not interrupted, resulting in no loss and re-election, but due to problems with the disk, the primary server cannot respond to the client's request, which will cause the zookeeper to be unable to provide services.

[0003] The election method using traditional technology has the problem of low election success rate. Summary of the invention

[0004] Based on this, it is necessary to provide an election method, device, computer equipment and storage medium that can improve the success rate of elections in response to the above technical problems.

[0005] In a first aspect, the present application provides an election method, which is applied to any server in a server cluster, comprising:

[0006] Receive fault information sent by third-party equipment;

[0007] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0008] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0009] In one embodiment, based on the server blacklist, an election operation is performed with other servers in the server cluster to obtain an election result, including:

[0010] Interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster;

[0011] Determine the second ballot information according to the server blacklist and the first ballot information;

[0012] The election result is obtained based on the second ballot information and the third ballot information sent by other servers.

[0013] In one embodiment, obtaining the election result according to the second ballot information and the third ballot information sent by each other server includes:

[0014] The target server with the most votes is determined from the second ballot information and all the third ballot information, and the target server is determined as the new main server to obtain the election result.

[0015] In one embodiment, determining the second ballot information according to the server blacklist and the first ballot information includes:

[0016] Determine the server participating in the election according to the first ballot information;

[0017] The servers participating in the election are screened according to the server blacklist to obtain candidate servers;

[0018] The second ballot information is determined based on the first ballot information and the candidate server.

[0019] In one embodiment, the first ballot information includes a ballot server identifier, and term information and transaction information corresponding to the ballot server identifier. The second ballot information is determined based on the first ballot information and the candidate server, including:

[0020] According to the identification, term information and transaction information of each voting server, the server with the highest priority is determined from the candidate servers;

[0021] The second ballot information is generated according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0022] In one embodiment, the method further comprises:

[0023] Receive query requests sent by third-party devices;

[0024] In response to the query request, the local identification information is sent to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0025] In one embodiment, the method further comprises:

[0026] The server information in the blacklist is updated at preset time intervals.

[0027] In a second aspect, the present application also provides an election device, comprising:

[0028] A first receiving module, used for receiving fault information sent by a third-party device;

[0029] A determination module, used to determine a faulty server in a server cluster according to the fault information, and add the server information of the faulty server to a server blacklist;

[0030] The election module is used to perform election operations with other servers in the server cluster according to the server blacklist to obtain the election results.

[0031] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0032] Receive fault information sent by third-party equipment;

[0033] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0034] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0036] Receive fault information sent by third-party equipment;

[0037] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0038] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0039] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0040] Receive fault information sent by third-party equipment;

[0041] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0042] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0043] The above-mentioned election method, device, computer equipment and storage medium receive fault information sent by a third-party device; determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist; perform election operations with other servers in the server cluster according to the server blacklist to obtain election results. The faulty server is excluded from the candidate servers for the election operation through the server blacklist, so as to avoid the faulty server being elected as the main server and causing the server cluster to fail to work normally, thereby improving the election success rate of the server, and determining the fault information in the server cluster through the third-party device improves the timeliness and accuracy of monitoring the faulty server, thereby improving the accuracy of the server blacklist and further improving the election success rate of the server. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0045] Figure 1 is an application environment diagram of an election method in an embodiment;

[0046] Figure 2 is a flowchart of an election method in an embodiment;

[0047] Figure 3 is a flow chart of an election method in another embodiment;

[0048] Figure 4 is a flow chart of an election method in another embodiment;

[0049] Figure 5 is a flow chart of an election method in another embodiment;

[0050] Figure 6 is a flow chart of an election method in another embodiment;

[0051] Figure 7 is a flow chart of an election method in another embodiment;

[0052] Figure 8 is a flow chart of an election method in another embodiment;

[0053] Fig. 9 is a structural block diagram of an election device in one embodiment;

[0054] Fig.10FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0056] Zookeeper is a distributed application coordination service software. The server cluster built based on Zookeeper can determine its own role through the current Zookeeper role to provide services. When the Zookeeper master server has problems, Zookeeper will elect a new master server to ensure the reliability of the cluster. When a server in the server cluster is suspended, Zookeeper will be unable to provide services. Since the internal communication between the servers in the Zookeeper cluster is to determine whether the Zookeeper server has problems by sending heartbeat packets, and the data will be written to the disk when it is written, when the disk of the Zookeeper master server fails abnormally, it may cause the Zookeeper server to be suspended. The Zookeeper network with other servers is not interrupted, resulting in no loss and re-election. However, due to problems with the disk, the master server cannot respond to the client's request. At this time, the Zookeeper cluster can no longer provide services, but the master server will not exit and re-elect the master because there is no problem with the network, which may lead to election failure. For this scenario, this solution proposes an election method that can improve the success rate of elections.

[0057] The election method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the server 102 communicates with the third-party device 104 through the network, and each server 102 communicates with each other through the network. The server 102 receives the fault information sent by the third-party device 104, and the server 102 determines the faulty server according to the fault information, and adds the information of the faulty server to the server blacklist. Then, the server 102 performs an election operation with other servers 102 in the server cluster to obtain the election result. Among them, the third-party device 104 can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0058] In one embodiment, Figure 2 As shown, a voting method is provided, which is applied to Figure 1 The following is an example of a server in the example, including:

[0059] S201, receiving fault information sent by a third-party device.

[0060] The fault information may include information of the faulty server, for example, identification information of the faulty server, or the fault information may indicate whether the current main server of the server cluster is faulty.

[0061] In an embodiment of the present application, the third-party device can be a monitoring device, which is used to monitor the working status of each server in the server cluster, and send the fault information of the server cluster to the server and other servers in the server cluster through a communication connection established with each server in the server cluster.

[0062] Optionally, the third-party device may store the identity information of all servers in the server cluster. Before the third-party device sends fault information to the server, the third-party device may send a request to each server in the server cluster. In response to the request, each server sends its own identity information to the third-party device. The third-party device may compare the received identity information with the pre-stored identity information of all servers, determine the identity information of the server that has not been received, and thus determine the server that has failed. Exemplarily, the third-party device may store the identity information of server 1, server 2, and server 3, and the third-party device receives its own identity information sent by server 1 and server 2, which indicates that server 3 cannot interact with the third-party device, and server 3 is determined to be a failed server.

[0063] S202: Determine a faulty server in the server cluster according to the fault information, and add the server information of the faulty server to a server blacklist.

[0064] Among them, the faulty server may be a pseudo-death fault, that is, the network connection between the faulty server and other servers is normal, but the faulty server has a disk abnormality and cannot provide read and write services to the user end; the server information may be the identity identification information of the server.

[0065] In an embodiment of the present application, a server in which a fault occurs is determined based on fault information. Further, server information of the faulty server can be read from a preset information base, and the server information of the faulty server can be added to a server blacklist; or, server information of the faulty server can be extracted from the fault information, and the server information of the faulty server can be added to a server blacklist.

[0066] Exemplarily, if the fault information is the identity information of the faulty server, such as the ID of the faulty server, the identity information of the faulty server is added to the server blacklist; if the fault information is the hardware serial number of the faulty server, the identity information of the faulty server is determined from a preset identity information library based on the hardware serial number, and the server information of the faulty server is added to the server blacklist.

[0067] S203, performing an election operation with other servers in the server cluster according to the server blacklist to obtain an election result.

[0068] The election result is the information of the next master server that succeeds in the election.

[0069] In the embodiment of the present application, the server generates ballot information based on the election information of each server and the server blacklist, sends the ballot information to other servers in the server cluster, and receives ballot information sent by other servers in the server cluster, so as to conduct an election based on all ballot information and obtain the election result. Optionally, each server can conduct one round of voting to obtain the election result; or, each server can conduct multiple rounds of voting and obtain the election votes based on the results of multiple rounds of voting.

[0070] As an optional implementation, the server can send acquisition requests to other servers to obtain the election information of other servers, and remove the servers in the server blacklist from the preset candidate server list to obtain an updated candidate server list. Further, all servers are sorted according to their election information, so as to generate voting information based on the information of the server ranked first.

[0071] As another optional implementation, a preset server information library may be stored in the server, and the server information library may include at least one of the election priority, performance information, and historical election information of each server in the server cluster, so that each server in the server cluster is scored according to the server information library, wherein servers in the server blacklist receive zero points. Furthermore, voting information is generated based on the information of the server with the highest score.

[0072] In the above election method, fault information sent by a third-party device is received; the faulty server in the server cluster is determined based on the fault information, and the server information of the faulty server is added to the server blacklist; and the election operation is performed with other servers in the server cluster based on the server blacklist to obtain the election result. The faulty server is excluded from the candidate servers for the election operation through the server blacklist, so as to avoid the faulty server being elected as the main server and causing the server cluster to fail to work normally, thereby improving the election success rate of the server. Moreover, the fault information in the server cluster is determined by a third-party device, which improves the timeliness and accuracy of monitoring the faulty server, thereby improving the accuracy of the server blacklist and further improving the election success rate of the server.

[0073] In one embodiment, an implementation of the above S203 is provided, such as Figure 3 As shown, the above “performing election operations with other servers in the server cluster according to the server blacklist to obtain election results” includes:

[0074] S301, interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster.

[0075] In an embodiment of the present application, the server generates first ballot information based on its own server information, sends its own first ballot information to other servers in the server cluster, and receives other first ballot information sent by other servers.

[0076] As another optional implementation, the server determines any server in the server cluster as a voting server, generates first voting information based on the information of the voting server, sends its own first voting information to other servers in the server cluster, and accepts other first voting information sent by other servers.

[0077] S302, determining second ballot information according to the server blacklist and the first ballot information.

[0078] In an embodiment of the present application, the first ballot information may include ballot information corresponding to a faulty server in a server blacklist. The server aggregates all the first ballot information and combines it with the server blacklist to determine the second ballot information that does not correspond to the faulty server, and sends the second ballot information to other servers in the server cluster.

[0079] Optionally, multiple candidate second ballot information may be generated based on all the first ballot information, and further, the multiple candidate second ballot information may be screened based on the server blacklist to obtain the second ballot information.

[0080] S303, obtaining the election result according to the second voting information and the third voting information sent by other servers.

[0081] Among them, the third ballot information is determined by other servers based on the server blacklist and the first ballot information.

[0082] In an embodiment of the present application, the third ballot information sent by other servers is received, and the second ballot information and the third ballot information are parsed to obtain ballot parsing data, thereby obtaining the election result based on the ballot parsing data.

[0083] Optionally, the ballot parsing data may include the server corresponding to each ballot information and the election weight of each server, so as to determine the number of ballot information corresponding to each server. Furthermore, the score of each server can be determined based on the election weight and the number of ballot information of each server, and then the election result can be obtained based on the score of each server. Exemplarily, when the election weight of server 1 is 2 and the number of ballot information is 3, the election weight of server 2 is 2 and the number of ballot information is 1, and the election weight of server 3 is 3 and the number of ballot information is 4, it is determined that the score of server 1 is 6, the score of server 2 is 2, and the score of server 3 is 24, then the election result is to elect server 3 with the highest score as the main server.

[0084] In the above-mentioned application embodiment, compared with only one round of voting, the accuracy of the election results is improved through two rounds of voting, and the second ballot information and the third ballot information are determined based on the first ballot information and the server blacklist, thereby avoiding the presence of ballot information of a faulty server in the second ballot information and the third ballot information, and improving the reliability of the second round of elections, thereby improving the success rate of elections by the server cluster.

[0085] In one embodiment, the above-mentioned "obtaining the election result based on the second voting information and the third voting information sent by each other server" includes: determining the target server with the largest number of votes from the second voting information and all the third voting information, and determining the target server as the new main server to obtain the election result.

[0086] In an embodiment of the present application, the second voting information and the third voting information may be the same or different. The server corresponding to the second voting information and the server corresponding to the third voting information are determined in turn to obtain the number of votes for each server, and the target server with the highest number of votes is determined as the main server.

[0087] Exemplarily, if the server obtains the second voting information and 5 copies of the third voting information, where the server corresponding to the second voting information is server 1, and the third voting information includes 2 copies of server 1's voting information, 2 copies of server 2's voting information, and 1 copy of server 3's voting information, then the number of votes for server 1 is 3, the number of votes for server 2 is 2, and the number of votes for server 3 is 1, then Server 1 with the highest number of votes is determined as the main server.

[0088] In an embodiment of the present application, the target server with the highest number of votes is obtained by counting the number of votes of each server in the second ballot information and the third ballot information. The determination method is simple and error-prone. While ensuring the accuracy of the election, it saves the computing resources of the server and improves the election efficiency of the server.

[0089] In one embodiment, an implementation of the above S303 is provided, such as Figure 4 As shown, the above “determining the second ballot information according to the server blacklist and the first ballot information” includes:

[0090] S401, determining the servers participating in the election according to the first ballot information.

[0091] In the embodiment of the present application, the server corresponding to each first ballot information is determined as a server participating in the election. Optionally, the server corresponding to each first ballot information is the server that generates the first ballot information. For example, server 1 generates the first ballot information and receives the first ballot information sent by server 2, server 3 and server 4 respectively, then server 1, server 2, server 3 and server 4 are determined as servers participating in the election.

[0092] S402: Screen the servers participating in the election according to the server blacklist to obtain candidate servers.

[0093] In an embodiment of the present application, it is determined whether there is a faulty server in the server blacklist among the servers participating in the election. If so, the faulty server is removed from the servers participating in the election, and the remaining servers participating in the election are determined as candidate servers; if not, the servers participating in the election are determined as candidate servers.

[0094] S403, determining second ballot information according to the first ballot information and the candidate server.

[0095] In an embodiment of the present application, the initial number of votes for each candidate server can be determined from all the first voting information, and the second voting information can be generated based on the information of the server with the highest initial number of votes; alternatively, the voting information corresponding to the candidate server in the first voting information can be first screened out, and the screened out voting information can be further parsed to obtain the information of each candidate server, thereby sorting or screening the candidate servers according to the information of each candidate server, determining the intermediate server, and generating the second voting information based on the information of the intermediate server.

[0096] In the above application embodiment, the servers participating in the election are first determined, and then the servers participating in the election are screened according to the server blacklist to avoid the failure of the election caused by the participation of faulty servers, thereby improving the election success rate of the server. Furthermore, the second ballot information is determined based on the screened candidate servers and the first ballot information, thereby improving the reliability of the second ballot information and further improving the election success rate of the server.

[0097] In one embodiment, an implementation of the above S403 is provided, such as Figure 5 As shown, the first ballot information includes a ballot server identifier, and term information and transaction information corresponding to the ballot server identifier. The above “determining the second ballot information based on the first ballot information and the candidate server” includes:

[0098] S501, determining the server with the highest priority from the candidate servers according to the identification, term information and transaction information of each voting server.

[0099] The ballot server identifier is the identity identifier of the server corresponding to the ballot, such as the server ID; the term information is the number of times the server corresponding to the ballot serves as the primary server; and the transaction information is the number of times the server corresponding to the ballot writes data in the process of providing read and write services. The first ballot information is in the form of an array including the ballot server identifier, term information, and transaction information. For example, when the term information corresponding to the first ballot information is 3, the transaction information is 10, and the ballot server identifier is 5, the first ballot information can be expressed as (3, 10, 5).

[0100] In the embodiment of the present application, by parsing all the first ballot information, the ballot server identification, term information and transaction information of all the servers participating in the election are obtained, and then according to the identification of the candidate server, the ballot server identification, term information and transaction information of all the servers participating in the election are determined. Further, the priority of each candidate server is determined according to the ballot server identification, term information and transaction information of each candidate server.

[0101] As an optional implementation, first compare the term information of each candidate server, determine the candidate server with the highest term information as the first candidate server, then compare the transaction information of each first candidate server, determine the first candidate server with the highest transaction information as the second candidate server, and further determine the second candidate server with the highest vote server identifier among the second candidate servers as the server with the highest priority. For example, if the term information of server 1 is 3, the transaction information is 10, and the vote server identifier is 5, the term information of server 2 is 3, the transaction information is 8, and the vote server identifier is 6, the term information of server 3 is 3, the transaction information is 10, and the vote server identifier is 7, and the term information of server 4 is 2, the transaction information is 10, and the vote server identifier is 8, then the first candidate servers are determined to be server 1, server 2, and server 3 based on the term information of each server, and then the second candidate servers are determined to be server 1 and server 3 based on the transaction information of each server, and further, the server with the highest priority is determined to be server 3 based on the vote server identifier.

[0102] As another optional implementation, the sum of the voting server identification, term information and transaction information of each candidate server may be used as the target value, and further, the candidate server with the largest target value may be determined as the server with the highest priority.

[0103] S502, generating second ballot information according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0104] In the embodiment of the present application, the voting server identifier of the server with the highest priority, as well as the term information and transaction information of the server with the highest priority, are converted into an array form to obtain the second voting information. For example, when the term information of the server with the highest priority is 3, the transaction information is 10, and the voting server identifier is 7, the second voting information generated is (3, 10, 7).

[0105] In the above-mentioned application embodiment, based on information of multiple dimensions including each voting server identification, term information and transaction information, the server with the highest priority is determined from the candidate servers, thereby improving the accuracy of the server with the highest priority, thereby improving the accuracy of the second ballot information, and further improving the success rate of server elections.

[0106] In one embodiment, Figure 6 As shown, the above election method also includes:

[0107] S204: Receive a query request sent by a third-party device.

[0108] In the embodiment of the present application, the third-party device can send a query request to each server in the server cluster according to the preset interval time. For example, when the preset interval time is 5s, the third-party device sends a query request every 5s.

[0109] Send a query request to each server in the server cluster; or, when a third-party device detects that the working status of the server cluster is abnormal, send a query request to each server in the server cluster, for example, the processing speed of the server cluster is reduced, the server cluster fails to write data, etc.

[0110] S205, in response to the query request, sending the local identification information to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0111] In the embodiment of the present application, in response to the query request, each server sends its own identity information to the third-party device, and the third-party device determines the identity information of the server that has not been received by comparing the received identity information with the identity information of all servers stored in advance, thereby determining the server that has failed based on the identity information of the server that has not been received. Exemplarily, the identity information of server 1, server 2, and server 3 may be stored in the third-party device. When the third-party device receives its own identity information sent by server 1 and server 2, it determines that the identity information of server 3 has not been received, that is, server 3 cannot exchange information with the third-party device, and determines server 3 as a failed server, and sends the corresponding fault information of server 3 to each server in the server cluster.

[0112] In the above application embodiment, the fault information in the server cluster is determined by a third-party device, which improves the timeliness and accuracy of monitoring the faulty server, thereby improving the accuracy of the server blacklist and further improving the success rate of server election.

[0113] In one embodiment, Figure 7 As shown, the above election method also includes:

[0114] S206: Update the server information in the blacklist every preset time period.

[0115] In an embodiment of the present application, the writing time of each server information in the blacklist is recorded, and at every preset time period, it is determined whether the time of each server information in the blacklist reaches a preset timeout period based on the current time and the writing time of each server information. If the preset timeout period is reached, the server information is deleted from the blacklist.

[0116] In the above application embodiment, the server information in the blacklist is updated regularly so that the servers whose faults have been repaired can participate in the election in time, thereby improving the utilization rate of each server and thus improving the service performance of the server cluster.

[0117] In one embodiment, a complete election method is also provided, such as Figure 8 As shown, including:

[0118] S1, receiving a query request sent by a third-party device.

[0119] S2, in response to the query request, sending the local identification information to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0120] S3, receiving fault information sent by a third-party device.

[0121] S4, determining the faulty server in the server cluster according to the fault information, and adding the server information of the faulty server to a server blacklist.

[0122] S5, interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster.

[0123] S6: Determine the server participating in the election according to the first ballot information.

[0124] S7, filtering the servers participating in the election according to the server blacklist to obtain candidate servers.

[0125] S8, determining the server with the highest priority from the candidate servers according to the identification, term information and transaction information of each voting server.

[0126] S9, generating second ballot information according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0127] S10, determining the target server with the most votes from the second ballot information and all the third ballot information, and determining the target server as the new main server to obtain the election result.

[0128] S11, updating the server information in the blacklist every preset time period.

[0129] In the above election method, fault information sent by a third-party device is received; the faulty server in the server cluster is determined based on the fault information, and the server information of the faulty server is added to the server blacklist; and the election operation is performed with other servers in the server cluster based on the server blacklist to obtain the election result. The faulty server is excluded from the candidate servers for the election operation through the server blacklist, so as to avoid the faulty server being elected as the main server and causing the server cluster to fail to work normally, thereby improving the election success rate of the server. Moreover, the fault information in the server cluster is determined by a third-party device, which improves the timeliness and accuracy of monitoring the faulty server, thereby improving the accuracy of the server blacklist and further improving the election success rate of the server.

[0130] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0131] Based on the same inventive concept, the embodiment of the present application also provides an election device for implementing the election method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more election device embodiments provided below can refer to the limitations on the election method above, and will not be repeated here.

[0132] In one embodiment, Fig. 9 As shown, an election device is provided, comprising: a receiving module 10, a determining module 11 and an election module 12, wherein:

[0133] The first receiving module 10 is used to receive fault information sent by a third-party device.

[0134] The determination module 11 is used to determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist.

[0135] The election module 12 is used to perform election operations with other servers in the server cluster according to the server blacklist to obtain election results.

[0136] In one embodiment, the election module 12 includes: an acquisition unit, a determination unit and an election unit, wherein:

[0137] The acquisition unit is used to interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster.

[0138] The determination unit is used to determine the second ballot information according to the server blacklist and the first ballot information.

[0139] The election unit is used to obtain the election result according to the second ballot information and the third ballot information sent by other servers.

[0140] In one embodiment, the election unit is specifically used to determine the target server with the most votes from the second ballot information and all the third ballot information, and determine the target server as the new main server to obtain the election result.

[0141] In one embodiment, the above-mentioned determination unit is specifically used to determine the servers participating in the election according to the first ballot information; screen the servers participating in the election according to the server blacklist to obtain candidate servers; and determine the second ballot information according to the first ballot information and the candidate servers.

[0142] In one embodiment, the first ballot information includes a ballot server identifier, and term information and transaction information corresponding to the ballot server identifier. The above-mentioned determination unit is specifically used to determine the server with the highest priority from the candidate servers based on each ballot server identifier, term information and transaction information; and generate the second ballot information based on the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0143] In one embodiment, the election device further includes: a second receiving module and a sending module, wherein:

[0144] The second receiving module is used to receive a query request sent by a third-party device.

[0145] The sending module is used to send the local identification information to the third-party device in response to the query request; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0146] In one embodiment, the election module further includes: an updating module, configured to update the server information in the blacklist every preset time period.

[0147] Each module in the above-mentioned election device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0148] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Fig.10 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store election data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an election method is implemented.

[0149] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0150] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0151] Receive fault information sent by third-party equipment;

[0152] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0153] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0154] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0155] Interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster;

[0156] Determine the second ballot information according to the server blacklist and the first ballot information;

[0157] The election result is obtained based on the second ballot information and the third ballot information sent by other servers.

[0158] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0159] The target server with the most votes is determined from the second ballot information and all the third ballot information, and the target server is determined as the new main server to obtain the election result.

[0160] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0161] Determine the server participating in the election according to the first ballot information;

[0162] The servers participating in the election are screened according to the server blacklist to obtain candidate servers;

[0163] The second ballot information is determined based on the first ballot information and the candidate server.

[0164] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0165] According to the identification, term information and transaction information of each voting server, the server with the highest priority is determined from the candidate servers;

[0166] The second ballot information is generated according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0167] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0168] Receive query requests sent by third-party devices;

[0169] In response to the query request, the local identification information is sent to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0170] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0171] The server information in the blacklist is updated at preset time intervals.

[0172] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0173] Receive fault information sent by third-party equipment;

[0174] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0175] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0176] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0177] Interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster;

[0178] Determine the second ballot information according to the server blacklist and the first ballot information;

[0179] The election result is obtained based on the second ballot information and the third ballot information sent by other servers.

[0180] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0181] The target server with the most votes is determined from the second ballot information and all the third ballot information, and the target server is determined as the new main server to obtain the election result.

[0182] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0183] Determine the server participating in the election according to the first ballot information;

[0184] The servers participating in the election are screened according to the server blacklist to obtain candidate servers;

[0185] The second ballot information is determined based on the first ballot information and the candidate server.

[0186] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0187] According to the identification, term information and transaction information of each voting server, the server with the highest priority is determined from the candidate servers;

[0188] The second ballot information is generated according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0189] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0190] Receive query requests sent by third-party devices;

[0191] In response to the query request, the local identification information is sent to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0192] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0193] The server information in the blacklist is updated at preset time intervals.

[0194] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0195] Receive fault information sent by third-party equipment;

[0196] Determine the faulty server in the server cluster according to the fault information, and add the server information of the faulty server to the server blacklist;

[0197] According to the server blacklist, election operations are performed with other servers in the server cluster to obtain the election results.

[0198] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0199] Interact with other servers in the server cluster to obtain the first vote information of all servers in the server cluster;

[0200] Determine the second ballot information according to the server blacklist and the first ballot information;

[0201] The election result is obtained based on the second ballot information and the third ballot information sent by other servers.

[0202] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0203] The target server with the most votes is determined from the second ballot information and all the third ballot information, and the target server is determined as the new main server to obtain the election result.

[0204] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0205] Determine the server participating in the election according to the first ballot information;

[0206] The servers participating in the election are screened according to the server blacklist to obtain candidate servers;

[0207] The second ballot information is determined based on the first ballot information and the candidate server.

[0208] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0209] According to the identification, term information and transaction information of each voting server, the server with the highest priority is determined from the candidate servers;

[0210] The second ballot information is generated according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

[0211] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0212] Receive query requests sent by third-party devices;

[0213] In response to the query request, the local identification information is sent to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

[0214] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:

[0215] The server information in the blacklist is updated at preset time intervals.

[0216] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0217] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0218] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method of election, characterized in that: Applied to any server in a server cluster, the method comprises: Receive fault information sent by third-party equipment; Determine a faulty server in the server cluster according to the fault information, and add server information of the faulty server to a server blacklist; According to the server blacklist, an election operation is performed with other servers in the server cluster to obtain an election result.

2. The method according to claim 1, characterized in that The step of performing an election operation with other servers in the server cluster according to the server blacklist to obtain an election result includes: Interacting with other servers in the server cluster to obtain first ballot information of all servers in the server cluster; Determining second ballot information according to the server blacklist and the first ballot information; The election result is obtained according to the second ballot information and the third ballot information sent by each of the other servers.

3. The method according to claim 2, characterized in that The step of obtaining the election result according to the second ballot information and the third ballot information sent by each of the other servers includes: The target server with the largest number of votes is determined from the second ballot information and all the third ballot information, and the target server is determined as the new main server to obtain the election result.

4. The method according to claim 2, characterized in that: The determining the second ballot information according to the server blacklist and the first ballot information includes: Determining a server participating in the election according to the first ballot information; Screening the servers participating in the election according to the server blacklist to obtain candidate servers; The second ballot information is determined according to the first ballot information and the candidate server.

5. The method according to claim 4, characterized in that The first ballot information includes a ballot server identifier, and term information and transaction information corresponding to the ballot server identifier. The determining the second ballot information according to the first ballot information and the candidate server includes: Determine a server with the highest priority from the candidate servers according to each of the voting server identifiers, the term information and the transaction information; The second ballot information is generated according to the ballot server identifier of the server with the highest priority, and the term information and transaction information of the server with the highest priority.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Receiving a query request sent by the third-party device; In response to the query request, the local identification information is sent to the third-party device; the local identification information is used to instruct the third-party device to determine the fault information according to the identification information of each server.

7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: The server information in the blacklist is updated at every preset time period.

8. An election device, characterized in that: The device comprises: A first receiving module, used for receiving fault information sent by a third-party device; A determination module, configured to determine a faulty server in the server cluster according to the fault information, and add server information of the faulty server to a server blacklist; The election module is used to perform an election operation with other servers in the server cluster according to the server blacklist to obtain an election result.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.