Distributed disaster recovery system, server node processing method, device and equipment
By introducing a third server node into the distributed consistency system, which rejects client read and write requests but participates in log synchronization, the problem of service unavailability caused by catastrophic events in the distributed consistency system is solved, and service availability is improved.
Patent Information
- Application Number
- CN202210108149.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2042-01-28
AI Technical Summary
In a distributed consistency system, when a catastrophic event occurs in an availability zone with a large number of server nodes, a majority cannot be formed, resulting in the inability to provide services.
A new role is introduced as a third server node, deployed in a different availability zone. This node rejects read and write requests from clients but participates in log synchronization. This ensures that in the event of a catastrophic event, the probability of the server nodes that have not experienced a catastrophic event forming a majority is increased, thereby maintaining service availability.
By deploying a third server node, service availability during catastrophic events was improved, reducing the likelihood of service disruptions due to disagreements among the majority.
Smart Images

Figure CN114490158B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a distributed disaster recovery system, a server node processing method and device and equipment. BACKGROUND
[0002] With the development of computer technology, distributed consistency systems have been widely used in practical applications, and provide consistency services for daily travel, artificial intelligence, service discovery, subscription notification, etc.
[0003] At present, a distributed consistency system can include a server node with a role as a leader (Leader) and multiple server nodes with a role as a follower (Follower). In the distributed consistency system, a majority can vote for a proposal to reach an agreement, and ensure that the data between different nodes reaches an agreement. In order to realize disaster recovery, the server node with the role as the leader and the server node with the role as the follower can be deployed in two available zones (AZ), and the number of server nodes in one available zone is less than half of the total number of server nodes, and the number of server nodes in the other available zone is greater than half of the total number of server nodes. If a catastrophic event occurs in the available zone with fewer server nodes, since the number of server nodes in the available zone without the catastrophic event is greater than half of the total number of server nodes, a majority can be formed, so that an agreement can be reached through the majority to provide services to the outside.
[0004] However, if a catastrophic event occurs in the available zone with more server nodes, since the number of server nodes in the available zone without the catastrophic event is less than half of the total number of server nodes, a majority cannot be formed, so that an agreement cannot be reached through the majority, resulting in a situation that services cannot be provided to the outside. Therefore, how to improve the service availability when a catastrophic event occurs in an available zone has become a technical problem to be solved. SUMMARY
[0005] Embodiments of the present application provide a distributed disaster recovery system, a server node processing method, device and equipment to solve the problem of improving service availability when a catastrophic event occurs in an available zone in the prior art.
[0006] In a first aspect, embodiments of the present application provide a distributed disaster recovery system, comprising: a first server node with a current role as a leader, a second server node with a current role as a follower, and a third server node with a current role as a new role; the third server node and the first server node and the second server node are deployed in different available zones, and the number of server nodes in any available zone is less than half of the total number of server nodes.
[0007] The first server node is configured to acquire a write request of a client, add a log entry for recording the write request in a log record of the first server node, send a log synchronization request for requesting to synchronize the log entry to the second server node and the third server node, and when a response result of more than half of the nodes to the log synchronization request is successful, commit the log entry and send a commit notification for the log entry to the second server node and the third server node.
[0008] The second server node and the third server node are configured to respond to the log synchronization request, and return a corresponding response result to the first server node, and in response to the commit notification, commit the log entry.
[0009] The second server node is further configured to acquire a read request of a client, and process the read request.
[0010] The third server node is further configured to acquire a read-write request of a client, and reject the read-write request.
[0011] In a second aspect, an embodiment of the present application provides a server node processing method, comprising:
[0012] acquiring a log synchronization request sent by a first server node, the log synchronization request being used for requesting to synchronize a log entry, the log entry being used for recording a write request of a client acquired by the first server node;
[0013] responding to the log synchronization request, and returning a corresponding response result to the first server node;
[0014] acquiring a commit notification for the log entry sent by the first server node according to the response result;
[0015] in response to the commit notification, committing the log entry;
[0016] acquiring a read-write request of a client, and rejecting the read-write request.
[0017] In a third aspect, an embodiment of the present application provides a server node processing apparatus, comprising:
[0018] an acquiring module configured to acquire a log synchronization request sent by a first server node, the log synchronization request being used for requesting to synchronize a log entry, the log entry being used for recording a write request of a client acquired by the first server node;
[0019] a first response module configured to respond to the log synchronization request, and return a corresponding response result to the first server node;
[0020] The obtaining module is further configured to obtain a commit notification for the log entry sent by the first server node according to the response result;
[0021] The second response module is configured to commit the log entry in response to the commit notification.
[0022] The obtaining module is further configured to obtain a read-write request of a client;
[0023] The rejecting module is configured to reject the read-write request.
[0024] In a fourth aspect, an embodiment of the present application provides a computing device, comprising a memory and a processor, wherein the memory is configured to store one or more computer instructions, and the one or more computer instructions are configured to implement the method in any one of the second aspect when executed by the processor.
[0025] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium having a computer program stored thereon, and the computer program is configured to implement the method in any one of the second aspect when executed.
[0026] An embodiment of the present application further provides a computer program configured to implement the method in any one of the first aspect when executed by a computer.
[0027] In an embodiment of the present application, a new role is proposed for a distributed consistency system. The distributed disaster recovery system can include a first server node with a current role as a master, a second server node with a current role as a slave, and a third server node with a current role as a new role. The third server node and the first server node and the second server node are deployed in different availability zones. The number of server nodes in any availability zone is less than half of the total number of server nodes. The third server node can reject read-write requests of a client, but participate in log synchronization. Since the third server node and the first server node and the second server node are deployed in different availability zones, when a catastrophic event occurs in the availability zone where the first server node and / or the second server node is deployed, the probability of the server nodes in the availability zone where no catastrophic event occurs forming a majority can be improved, thereby reducing the situation that a majority cannot reach an agreement and cannot provide services to the outside, and improving the service availability when a catastrophic event occurs in an availability zone. BRIEF DESCRIPTION OF DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced as follows. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those of ordinary skill in the art without creative effort.
[0029] Figure 1 A structural schematic diagram of a distributed disaster recovery system in the prior art is shown in FIG. 1.
[0030] Figure 2 A structural schematic diagram of a distributed disaster recovery system provided by an embodiment of the present application is shown in FIG. 2.
[0031] Figure 3 A structural schematic diagram of a distributed disaster recovery system provided by another embodiment of the present application is shown in FIG. 3.
[0032] Figures 4A-4C A schematic diagram of a disaster recovery process of an embodiment of the present application is shown in FIG. 4.
[0033] Figure 5 A schematic diagram of a processing flow of a third server node provided by an embodiment of the present application is shown in FIG. 5.
[0034] Figure 6 A flowchart of a node processing method provided by an embodiment of the present application is shown in FIG. 6.
[0035] Figure 7 A flowchart of a node processing device provided by an embodiment of the present application is shown in FIG. 7.
[0036] Figure 8 A structural schematic diagram of a computing device provided by an embodiment of the present application is shown in FIG. 8. DETAILED DESCRIPTION
[0037] In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort fall within the scope of the present application.
[0038] The terms used in the embodiments of the present application are only for the purpose of describing the specific embodiments, and are not intended to limit the present application. The singular forms "a", "an" and "the" used in the embodiments of the present application and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. "Plural" generally includes at least two, but does not exclude the case of including at least one.
[0039] It should be understood that the term "and / or" as used herein merely describes an associated relationship, which means that there can be three relationships, for example, A and / or B, which means that A exists alone, A and B exist together, and B exists alone. In addition, the character " / " herein generally represents an "or" relationship between the front and rear associated objects.
[0040] Depending on the context, the word "if" as used herein can be interpreted as meaning "when" or "while" or "in response to determining" or "in response to detecting". Similarly, depending on the context, the phrase "if it is determined" or "if (a stated condition or event) is detected" can be interpreted as meaning "when it is determined" or "in response to determining" or "when (a stated condition or event) is detected" or "in response to detecting (a stated condition or event)".
[0041] It should also be noted that the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusions, so that a product or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such product or system. Without more limitations, the element defined by the phrase "including a" does not exclude the presence of another identical element in the product or system including the element.
[0042] In addition, the step sequence in each of the following method embodiments is only an example, and is not strictly limited.
[0043] Generally, in order to realize disaster recovery, as shown in Figure 1 The server nodes with the role of master and the server nodes with the role of slave can be deployed in AZa and AZb, and the number of server nodes in AZa (i.e., 2) is less than half of the total number of server nodes (i.e., 5), and the number of server nodes in AZb (i.e., 3) is greater than half of the total number of server nodes. If a catastrophic event occurs in AZa, because the number of server nodes in AZb is greater than half of the total number of server nodes, the majority can still reach a consensus, and the distributed consensus system can still provide services to the outside. However, if a catastrophic event occurs in AZb, because the number of server nodes in AZa is less than half of the total number of server nodes, a situation in which the distributed consensus system cannot provide services to the outside due to the failure of the majority to reach a consensus will occur. Therefore, how to improve the service availability when a catastrophic event occurs in an availability zone has become a technical problem to be solved at present.
[0044] To solve the technical problem of how to improve service availability when a disaster occurs in an available zone in the prior art, in the embodiments of the present application, a new role is proposed for a distributed consistency system. The distributed disaster recovery system includes a first server node with a current role as a master, a second server node with a current role as a slave, and a third server node with a current role as a new role. The third server node is deployed in a different available zone from the first server node and the second server node. The number of server nodes in any available zone is less than half of the total number of server nodes. The third server node can reject read and write requests from clients, but participates in log synchronization. Since the third server node is deployed in a different available zone from the first server node and the second server node, when a disaster occurs in the available zone where the first server node and / or the second server node are deployed, the probability of the server nodes that do not experience a disaster forming a majority can be improved, thereby reducing the situation where a majority cannot reach a consensus and service cannot be provided externally, and improving service availability when a disaster occurs in an available zone.
[0045] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. In the case of no conflict, the embodiments described below and the features in the embodiments can be combined with each other.
[0046] Figure 2 The structure diagram of the distributed disaster recovery system provided by an embodiment of the present application is shown in FIG. 1. The disaster recovery system provided by the embodiment can include a first server node 21 with a current role as a master, a second server node 22 with a current role as a slave, and a third server node 23 with a current role as a new role. The third server node 23 is deployed in a different available zone from the first server node 21 and the second server node 22. The number of server nodes in any available zone is less than half of the total number of server nodes. Figure 2
[0047] The available zone can correspond to a machine room. The available zone refers to a physical area in the same region, and the power and network are independent of each other. The network delay between machines in the same available zone is smaller. The available zones in the same region can communicate with each other through an intranet, and the available zones can be fault isolated. According to the geographical location, the infrastructure set in a region, such as Beijing, Shenzhen, etc., can be referred to as a region.
[0048] It should be noted that the number of server nodes in any availability zone is less than half of the total number of server nodes, in order to avoid the situation that a catastrophic event in a certain availability zone causes the server nodes in other availability zones to be unable to form a majority. Among them, the majority refers to more than half of the nodes. It should be understood that in order to realize that the number of server nodes in any availability zone is less than half of the total number of server nodes, the first server node 21, the second server node 22 and the third server node 23 need to be deployed in at least three availability zones, Figure 1 The deployment of the first server node 21, the second server node 22 and the third server node 23 in the AZ1, AZ2 and AZ3 availability zones is only an example.
[0049] The first server node 21, the second server node 22 and the third server node 23 are all server nodes in a distributed consistency system, and the difference mainly lies in the role. The server node can be a physical server node or a cloud server node.
[0050] The client 24 can generate read-write requests and randomly send the generated read-write requests to a certain server node in the distributed consistency system.
[0051] It should be noted that, Figure 1 The number of server nodes, the number of clients and the number of availability zones are only examples. In actual application, the number of first server nodes can be one, the number of second server nodes can be one or more, and the number of third server nodes can be one or more.
[0052] The first server node 21 can process the write request of the client 24, the second server node 22 can process the read request of the client 24, and the third server node 23 can reject the read-write request of the client 24. Among them, the first server node 21 can also process the read request of the client 24, and the second server node 22 can forward the write request of the client 24 to the first server node 21 for processing. It should be noted that the related content of the server node in the distributed consistency system processing the read request of the client can be referred to the specific description in the related technology, which will not be repeated here.
[0053] Among them, the third server node 23 rejecting the read-write request of a certain client can include that the third server node 23 does not reply to the read-write request of the client, and can also include that the communication connection between the third server node 23 and the client is disconnected. It should be noted that after the third server node 23 rejects the read-write request of the client, the client can establish a connection with other server nodes and send read-write requests to other server nodes.
[0054] It should be noted that during the process that the first server node 21 processes the write request of the client 24, log synchronization needs to be performed. Generally, the first server node 21 performs log synchronization with the second server node 22, and in the embodiment of the present application, the third server node 23 also participates in the log synchronization.
[0055] The first server node 21 can be configured to acquire the write request of the client, add a log entry for recording the write request in a log record of the first server node 21, and send a log synchronization request for requesting to synchronize the log entry to the second server node 22 and the third server node 23.
[0056] The second server node 22 and the third server node 23 can be configured to respond to the log synchronization request and return a corresponding response result to the first server node 21. The response result can be a response success or a response failure. When the response result returned by a certain server node (the second server node or the third server node) is a response success, it can mean that the server node successfully adds the log entry to the log record of the server node. When the response result returned by a certain server node is a response success, it can mean that the server node does not successfully add the log entry to the log record of the server node.
[0057] The first server node 21 can also be configured to submit the log entry and send a commit notification for the log entry to the second server node 22 and the third server node 23 when the response result of more than half of the nodes to the log synchronization request is a success. In addition, the first server node 21 can also return an execution result to the client 24, so that the client 24 can know the execution result.
[0058] It can be seen that the first server node 21 submits the log entry based on the majority principle, and the response result of the third server node 23 to the log synchronization request can be used to constitute the majority. It should be noted that since the first server node 21 has added the log entry to the log record of the first server node 21, the response result of the first server node 21 to the log entry is a response success by default.
[0059] The first server node 21 submits the log entry, which can be specifically that the first server node 21 applies the log entry to a state machine, so that the write request recorded in the log entry can be executed. It should be noted that the related content about the first server node 21 submitting the log entry can refer to the specific description in the related art, which will not be described here.
[0060] The second server node 22 and the third server node 23 can also be configured to submit the log entry in response to the submission notification. Specifically, the second server node 22 can submit the log entry by applying the log entry to a state machine, so that the write request recorded in the log entry can be executed. The third server node 23 can submit the log entry by applying the log entry to a state machine, so that the write request recorded in the log entry can be executed. It should be noted that the second server node 22 can submit the log entry in the manner described in the related art, which will not be described herein again. It should be noted that the third server node 23 can submit the log entry in the same manner as the second server node 22, which will not be described herein again.
[0061] With reference to Figure 2 , it is assumed that a catastrophic event occurs in the AZ2 in which the first server node 21 and / or the second server node 22 are deployed, i.e., AZ2 and AZ3, and the AZ2 in which the first server node 21 is not deployed. Since the sum of the number of server nodes in AZ1 and AZ3, i.e., 1+2, is greater than half of the total number of servers, i.e., 5, and the third server node 23 participates in log synchronization, a consensus can be reached by a majority to provide services to the outside, thereby improving service availability.
[0062] In actual applications, the first server node 21 and the second server node 22 can be deployed in the same region, for example, Figure 3 As shown in FIG. 6, the first server node 21 and the second server node 22 can be deployed in region A. In addition, the client 24 can be deployed in the same region as the first server node 21 and the second server node 22, for example, Figure 3 As shown in FIG. 7, the client 24 can also be deployed in region A.
[0063] In one embodiment, the third server node 23 can be deployed in the same region as the first server node 21 and the second server node 22. In another embodiment, the third server node 23 can be deployed in a different region from the first server node 21 and the second server node 22, i.e., the third server node 23 can be cross-regional, for example, Figure 3 As shown in FIG. 8, the first server node 21 and the second server node 22 can be deployed in region A, and the third server node 23 can be deployed in region B.
[0064] In the embodiments of the present application, the third server node 23 can also participate in the election.
[0065] Optionally, the third server node 23 can vote in an election initiated by the second server node 22. Based on this, in one embodiment, the second server node 22 can also be configured to vote for itself and send a voting request to other server nodes except the second server node 22 if no heartbeat message sent by the first server node 21 is received within a preset time, and the other server nodes can include the third server node 23; the third server node 23 can also be configured to determine whether to agree to vote for the second server node 22 in response to the voting request, and return the corresponding voting result to the second server node 22; and the second server node 22 can also be configured to modify its role to master if more than half of the nodes agree to vote for it according to the voting result. Thus, the second server node 22 can be elected as the master.
[0066] As can be seen, the second server node 22 modifies its role to master based on the majority principle, and the voting result of the third server node 23 to the voting request can be used to constitute the majority.
[0067] For example, when no heartbeat message sent by the first server node 21 is received within a preset time, the second server node 22 can start an election process. For example, in the election process, the second server node 22 can increase its election period, obtain its latest log index, and send a voting request to other server nodes except itself based on the increased election period and the obtained latest log index, and the other server nodes can include the third server node 23, and the voting request can include the election period and the latest log index, and the second server node 22 can also vote for itself. It should be noted that the specific implementation of the election process is not limited in the embodiment of the present application.
[0068] Exemplarily, after receiving the voting request, the third server node 23 can first compare the election cycle in the voting request with its own election cycle, if the election cycle in the voting request is greater than its own election cycle, agree to vote, if the election cycle in the voting request is less than its own election cycle, disagree to vote, if the election cycle in the voting request is equal to its own election cycle, compare the latest log index in the voting request with its own latest log index; if the latest log index in the voting request is greater than its own latest log index, agree to vote, if the latest log index in the voting request is less than its own latest log index, disagree to vote, if the latest log index in the voting request is equal to its own latest log index, compare the server identifier (serverId) of the second server node 22 with its own serverId, if the serverId of the second server node 22 is greater than its own serverId, agree to vote, if the serverId of the second server node 22 is less than its own serverId, disagree to vote. Wherein, the serverId of the server node can be calculated based on the IP address of the server node. It should be noted that the specific implementation manner of determining whether to vote is not limited in the embodiment of the application.
[0069] With reference to Figure 2 and Figure 3 , assuming that a catastrophic event occurs in AZ3 in which the first server node 21 is deployed, among the availability zones (namely AZ2 and AZ3) in which the first server node 21 and / or the second server node 22 are deployed, since the sum of the number of server nodes in AZ1 and AZ2 (namely 1+2) is greater than half of the total number of servers (namely 5), and the third server node 23 can vote, therefore, the role of a certain second server node in AZ2 can be modified to master through majority agreement, and the service can be provided externally through majority agreement, thereby improving the service availability.
[0070] and / or optionally, the third server node 23 can also initiate an election. Based on this, in one embodiment, the third server node 23 can also be used for voting for itself and sending a voting request to other server nodes except the third server node 23 if the heartbeat packet sent by the first server node 21 is not received within a preset time, the other server nodes can include the second server node 22; the second server node 22 can also be used for determining whether to agree to vote for the third server node 23 in response to the voting request, and returning the corresponding voting result to the third server node 23; the third server node 23 can also be used for modifying its own role to master if the voting result of more than half of the server nodes is to agree. Therefore, the third server node 23 can be elected as the master.
[0071] Exemplarily, when the heartbeat message sent by the first server node 21 is not received within a preset time, the third server node 23 can start an election process. Exemplarily, in the election process, the third server node 23 can increase its own election term, obtain its latest log index, and send a voting request to other server nodes except itself based on the increased election term and the obtained latest log index, wherein the other server nodes can include the second server node 22, the voting request can include the election term and the latest log index, and the third server node 23 can also vote for itself.
[0072] Exemplarily, the second server node 22 can determine whether to agree to vote for the third server node 23 in response to the voting request, and return the corresponding voting result to the third server node 23. Exemplarily, after receiving the voting request, the second server node 22 can first compare the election term in the voting request with its own election term, if the election term in the voting request is greater than its own election term, it agrees to vote, if the election term in the voting request is less than its own election term, it disagrees to vote, if the election term in the voting request is equal to its own election term, it compares the latest log index in the voting request with its own latest log index; if the latest log index in the voting request is greater than its own latest log index, it agrees to vote, if the latest log index in the voting request is less than its own latest log index, it disagrees to vote, if the latest log index in the voting request is equal to its own latest log index, it compares the serverId of the third server node 23 with its own serverId, if the serverId of the third server node 23 is greater than its own serverId, it agrees to vote, if the serverId of the third server node 23 is less than its own serverId, it disagrees to vote.
[0073] Reference Figure 2 and Figure 3 Suppose a catastrophic event occurs in AZ3 where the first server node 21 and / or the second server node 22 are deployed, since the sum of the number of server nodes in AZ1 and AZ2 (i.e. 1+2) is greater than half of the total number of servers (i.e. 5), and the third server node 23 can initiate an election, the role of the third server node in AZ1 can be modified to master by majority consensus, and services can be provided externally by majority consensus, thereby improving service availability.
[0074] It should be understood that after the role of the third server node 23 is changed from a new role to a master, the functions completed by the third server node also change accordingly.
[0075] In one embodiment, after the role of the third server node 23 is modified to be master, the third server node 23 can handle read and write requests of the client 24, which can be the same as after the role of the second server node 22 is modified to be master.
[0076] In another embodiment, after the role of the third server node 23 is modified to be master, the third server node 23 can disable write and promote the second server node 22 to be master, where the write refers to insert, update, delete and the like.
[0077] Based on this, the third server node 23 can also be configured to disable write requests of the client 24 and periodically send a start election request to a target server node matching the third server node 23 until the role of the target server node is modified to be master. For example, the target server node can be the second server node with the largest latest log index matching the third server node 23. Assuming that the latest log index of the third server node 23 is 10, the latest log index of a second server node 22 is 9, the latest log index of another second server node 22 is 11, and the latest log index of still another second server node 22 is 10, the second server nodes 22 with the latest log indexes of 9 and 10 are the second server nodes matching the third server node 23, and further, the target server node can be the second server node 22 with the latest log index of 10.
[0078] The target server node can be configured to, in response to the start election request sent by the third server node 23, increase an election period of the target server node, obtain a latest log index of the target server node, and send a vote request to other server nodes except the target server node based on the increased election period and the obtained log index to obtain a vote result of the other server nodes, and the target server node can also vote for itself. If the vote result of more than half of the server nodes is agree, the target server node can also modify the role of the target server node to be master.
[0079] It should be noted that the third server node 23 can also be configured to modify the role of the third server node 23 back to the new role after the target server node is elected to be master. It should be understood that after the role of the third server node 23 is modified from master to the new role, the functions of the third server node 23 also change accordingly.
[0080] In the cross-region scenario of the third server node 23, the write is disabled by the third server node 23, and the second server node 22 can be elected as the master, so as to minimize the influence of network delay on service quality. In addition, due to the cross-region, the third server node 23 is slower than the second server node 22 in synchronizing logs, committing logs, etc. In addition, the serverId of the third server node 23 is usually set to be smaller, so that the third server node 23 cannot be elected as the master in general, and can be elected as the master in some extreme cases.
[0081] For example, as shown in Figure 4A , there are five server nodes at the beginning, the current role is the server node of the newly added role, and the other four server nodes are not in the same region, the total number of server nodes is 5, it is assumed that a network partition or other catastrophic event occurs at t1, the two server nodes in AZx are affected, and the election period of the server nodes in AZx, AZy and AZz at t1 is equal to 1, and the latest log index is equal to 2, so that the server node in AZz (i.e. the server node in AZz) and the other two server nodes in AZy still constitute a majority, and because the server node in AZz is cross-region, as shown in Figure 4B , one of the server nodes in AZy can be elected as a new master and provide services, so that the latest log index and the election period can continue to increase. Further, as shown in Figure 4C , it is assumed that at t2, AZx which has a network partition before resumes service, and AZy which is originally normal has a network partition, and at t2, the election period of the server node in AZz is equal to 3, and the latest log index is equal to 3, so that the server node in AZz has the maximum election period and log index, in order to ensure data consistency, the server node in AZz becomes the master. After the server node in AZz becomes the master, it can disable writing, but can provide read service, so that read service can still be provided under the condition of ensuring data consistency. Because the server node in AZz disables writing, after a period of time, the two server nodes in AZx can synchronize the data of the server node in AZz and increase the latest log index, and finally become the master, and the server node in AZz can resume normal working mode and reject read and write requests. It can be seen that the service is always available throughout the process, although the service delay will increase during the election of the server node in AZz as the master, but the influence on the service in this extreme disaster scenario has been controlled to the minimum.
[0082] It should be noted that Figures 4A-4C one circle in may represent one server node.
[0083] In an embodiment of the present application, optionally, in the case that the current role of the third server node 23 is the new role, the user can also modify the role of the third server node 23 to the slave according to the need, which is advantageous to improve flexibility and improve the user experience. Based on this, in an embodiment, the third server node 23 can also be configured to obtain a reconfiguration request of the client, the reconfiguration request being used to request to configure the role of the third server node 23 to the slave, and in response to the reconfiguration request, modify the role of itself to the slave. It should be understood that after the role of the third server node 23 is changed from the new role to the slave, the functions completed by the third server node also change accordingly.
[0084] In an embodiment of the present application, optionally, the third server node 23 can reject all read-write requests; or, optionally, the third server node 23 can selectively reject read-write requests, which is advantageous to improve flexibility. Based on this, the third server node 23 can be specifically configured to determine whether the user corresponding to the obtained read-write request is within the range of releasable users,
[0085] If not, the read-write request is rejected. The range of releasable users can be obtained by configuration. For example, the users in the range of releasable users can include users used to detect the survival state of the server node.
[0086] For example, as shown in Figure 5 In step 51, the third service node 23 can obtain a request. Then, in step 52, the third service node 23 can determine the type of the request, which can be a read-write request or a reconfiguration request. Since the reconfiguration request can be used for capacity expansion, capacity reduction and role change, if the type of the request is the reconfiguration request, in step 53, the third service node 23 can further determine whether it is a reconfiguration request used to configure the role to the slave. If so, in step 54, the third service node 23 can modify the role of itself to the slave, so that the subsequent behavior of itself can be performed according to the slave behavior, realizing the unblocking function of the third server node 23; if the type of the request is the read-write request, in step 55, the third service node 23 can determine whether the user corresponding to the read-write request is within the range of releasable users. If not, in step 56, the read-write request can be rejected and the connection is closed; if so, in step 57, the third service node 23 can directly process the read request, and forward the write request to the server node with the role of the master for processing, so as to cope with some requests of operation and maintenance tools and special needs.
[0087] In contrast to the role being changed from the new role to the slave, the role can also be changed from the slave to the new role. For example, if the reconfiguration request obtained is used to configure the role as a new role, the role of the server node can be modified to the new role in response to the reconfiguration request, so that the subsequent behavior of the server node can be performed according to the behavior of the new role, and the read-write prohibition function of the server node is realized.
[0088] The disaster recovery system provided by the embodiment includes a first server node with a current role as a master, a second server node with a current role as a slave, and a third server node with a current role as a new role. The third server node is deployed in a different availability zone from the first server node and the second server node, and the number of server nodes in any availability zone is less than half of the total number of server nodes. The third server node can reject read-write requests from the client, but participates in log synchronization. Since the third server node is deployed in a different availability zone from the first server node and the second server node, when a catastrophic event occurs in the availability zone where the first server node and / or the second server node are deployed, the probability of the server nodes not experiencing the catastrophic event forming a majority can be improved, thereby reducing the situation that the majority cannot reach a consensus and the service cannot be provided externally, and improving the service availability when a catastrophic event occurs in an availability zone.
[0089] Figure 6 The flowchart of the node processing method provided by an embodiment of the present application can be applied to the second server node in Figure 2 , as shown in Figure 6 , the method provided by the embodiment can include:
[0090] Step 61: A log synchronization request sent by a first server node is obtained, the log synchronization request is used to request to synchronize a log entry, and the log entry is used to record a write request of a client obtained by the first server node;
[0091] Step 62: The log synchronization request is responded to, and a corresponding response result is returned to the first server node;
[0092] Step 63: A commit notification for the log entry sent by the first server node according to the response result is obtained;
[0093] Step 64: The log entry is committed in response to the commit notification;
[0094] Step 65: A read-write request of a client is obtained, and the read-write request is rejected.
[0095] It should be understood that there is no sequence restriction between step 65 and steps 61 and 63.
[0096] In one embodiment, the method provided by the embodiment of the application further includes: in response to the voting request sent by the second server node, determining whether to agree to vote for the second server node, and returning the corresponding voting result to the second server node.
[0097] In one embodiment, the method provided by the embodiment of the application further includes:
[0098] If the heartbeat packet sent by the first server node is not received within a preset time, voting for oneself sends a voting request to other server nodes except itself, so that the other server nodes return the corresponding voting result.
[0099] If the voting result of more than half of the server nodes is agreement, the role of the server node is modified to master.
[0100] In one embodiment, the method provided by the embodiment of the application further includes: prohibiting the write request and periodically sending a start election request to a target server node matched with itself until the role of the target server node is modified to master.
[0101] In one embodiment, the method provided by the embodiment of the application further includes:
[0102] Obtaining a reconfiguration request of the client, the reconfiguration request being used to request to configure the role as slave.
[0103] In response to the reconfiguration request, the role of the server node is modified to slave.
[0104] In one embodiment, the method provided by the embodiment of the application further includes: determining whether the user corresponding to the read-write request is within the range of releasable users, and if not, rejecting the read-write request.
[0105] It should be noted that the specific implementation of the third server node can refer to the specific description in the embodiment shown in Figure 2 Therefore, the description is not repeated here.
[0106] The node processing device provided by the embodiment includes: responding to a log synchronization request sent by a first server node, and returning a corresponding response result to the first server node, the log synchronization request being used to request to synchronize log entries, the log entries being used to record write requests of a client obtained by the first server node, in response to a submission notification for the log entries sent by the first server node according to the response result, submitting the log entries, obtaining read-write requests of the client and rejecting the read-write requests, so that a server node that can reject read-write requests of the client but participates in log synchronization is implemented.
[0107] Figure 7A structural schematic diagram of a node processing device provided by an embodiment of the present application is shown in the figure. The device can execute the above-mentioned Figure 6 The method provided by the embodiment shown in the figure, and specifically, the device can include:
[0108] The obtaining module 71 is configured to obtain a log synchronization request sent by a first server node, the log synchronization request being used to request to synchronize a log entry, the log entry being used to record a write request of a client obtained by the first server node;
[0109] The first response module 72 is configured to respond to the log synchronization request and return a corresponding response result to the first server node;
[0110] The obtaining module 71 is further configured to obtain a commit notification for the log entry sent by the first server node according to the response result;
[0111] The second response module 73 is configured to respond to the commit notification and commit the log entry;
[0112] The obtaining module 71 is further configured to obtain a read-write request of a client;
[0113] The rejection module 74 is configured to reject the read-write request.
[0114] Optionally, the device can further include a first election module configured to respond to a voting request sent by a second server node, determine whether to agree to vote for the second server node, and return a corresponding voting result to the second server node.
[0115] Optionally, the device can further include a second election module configured to, if a heartbeat packet sent by the first server node is not received within a preset time, vote for itself and send a voting request to other server nodes except itself, so that the other server nodes return a corresponding voting result; and if the voting result of more than half of the server nodes is agreement, modify a role of the device to master.
[0116] Optionally, the device can further include a master module configured to prohibit a write request and periodically send a start election request to a target server node matched with the device until a role of the target server node is modified to master.
[0117] Optionally, the device can further include an obtaining module and a third response module;
[0118] The obtaining module is configured to obtain a reconfiguration request of a client, the reconfiguration request being used to request to configure a role to slave.
[0119] The third response module is configured to respond to the reconfiguration request and modify the role of the device to slave.
[0120] Optionally, the rejecting module 74 is specifically configured to: determine whether the user corresponding to the read-write request is within the range of releasable users, and if not, reject the read-write request.
[0121] Figure 7 The apparatus can perform Figure 6 The method of the embodiment is not described in detail, and the related description of the Figure 6 The embodiment can be referred to. The execution process and technical effects of the technical solution are described in the Figure 6 The embodiment, which will not be repeated here.
[0122] In one possible implementation, Figure 7 The structure of the apparatus can be implemented as a computing device. As Figure 8 The computing device can include a processor 81 and a memory 82. The memory 82 is configured to store programs supporting the computing device to execute the method provided in the above Figure 6 The processor 81 is configured to execute the programs stored in the memory 82.
[0123] The programs include one or more computer instructions, wherein the one or more computer instructions are executed by the processor 81 to implement the following steps:
[0124] Obtain the log synchronization request sent by the first server node, the log synchronization request is used to request to synchronize log entries, and the log entries are used to record the write request of the client obtained by the first server node;
[0125] Respond to the log synchronization request and return a corresponding response result to the first server node,
[0126] Obtain the commit notification for the log entries sent by the first server node according to the response result;
[0127] In response to the commit notification, the log entries are committed;
[0128] Obtain the read-write request of the client, and reject the read-write request.
[0129] Optionally, the processor 81 is further configured to execute all or part of the steps in the foregoing Figure 6 The embodiment.
[0130] The structure of the computing device can further include a communication interface 83, which is configured to communicate with other devices or communication networks.
[0131] In addition, the embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed to implement the method provided by the embodiment of the present application. Figure 6 The method provided by the embodiment.
[0132] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, that is, can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. Those skilled in the art can understand and implement without creative labor.
[0133] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of a general hardware platform as necessary, and of course can also be realized by means of combination of hardware and software. Based on such understanding, the above technical solutions can be embodied in the form of a computer product, and the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.
[0134] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system), and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be realized by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable devices to produce a machine, so that the instructions executed by the computer or other programmable devices produce a device implemented in the flowcharts and / or block diagrams. Figure One The device that implements the function specified in one flow or multiple flows and / or blocks. Figure One The device that implements the function specified in one flow or multiple flows and / or blocks.
[0135] These computer program instructions can also be stored in a computer readable storage medium, which can guide the computer or other programmable devices to work in a specific way, so that the instructions stored in the computer readable storage medium produce a product including instruction devices, which implement the flowcharts and / or block diagrams. Figure One The device that implements the function specified in one flow or multiple flows and / or blocks. Figure One The device that implements the function specified in one flow or multiple flows and / or blocks.
[0136] These computer program instructions can also be loaded onto a computer or other programmable device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that the instructions which execute on the computer or other programmable device provide steps for implementing the functions specified in the flowchart block or blocks. Figure One Figure One Figure One The computer program instructions can also be loaded onto a computer or other programmable device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that the instructions which execute on the computer or other programmable device provide steps for implementing the functions specified in the flowchart block or blocks.
[0137] In one typical configuration, the computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0138] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory, etc. The memory is an example of computer readable media.
[0139] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.
[0140] Finally, it should be noted that the above-described embodiments are merely intended for describing and illustrating, but not limiting the technical solutions of the present application; although the present application has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above-described embodiments, or make equivalent replacements to some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A distributed disaster recovery system, characterized by, The application relates to a method for realizing a multi-server node cluster, and belongs to the technical field of distributed database. The method comprises the following steps: A first server node is a master node, a second server node is a slave node, and a third server node is a new node; The first server node, the second server node and the third server node are deployed in different availability zones, and the number of server nodes in any availability zone is less than half of the total number of server nodes; The first server node is used for obtaining a write request of a client, adding a log entry for recording the write request in a log record of the first server node, sending a log synchronization request for requesting to synchronize the log entry to the second server node and the third server node, and submitting the log entry and sending a commit notification for the log entry to the second server node and the third server node when more than half of the nodes respond to the log synchronization request successfully; The second server node and the third server node are used for responding to the log synchronization request and returning corresponding response results to the first server node, and responding to the commit notification and submitting the log entry; The second server node is further used for obtaining a read request of a client and processing the read request; 2. The system of claim 1, wherein, The third server node is further used for obtaining a read-write request of a client and rejecting the read-write request. The second server node is further used for voting for itself and sending a voting request to other server nodes except the second server node if a heartbeat packet sent by the first server node is not received within a preset time, wherein the other server nodes include the third server node; The third server node is further used for responding to the voting request, determining whether to agree to vote for the second server node, and returning a corresponding voting result to the second server node; 3. The system of claim 1, wherein, The second server node is further used for modifying a role of the second server node to a master node if more than half of the nodes agree to vote. The third server node is further used for voting for itself and sending a voting request to other server nodes except the third server node if a heartbeat packet sent by the first server node is not received within a preset time, wherein the other server nodes include the second server node; The second server node is further used for responding to the voting request, determining whether to agree to vote for the third server node, and returning a corresponding voting result to the third server node; 4. The system of claim 3, wherein, The third server node is further used for modifying a role of the third server node to a master node if more than half of the server nodes agree to vote.
5. The system according to any of claims 1-4, characterized in that, The third server node is further used for prohibiting a write request of a client and periodically sending a start election request to a target server node matched with the third server node until a role of the target server node is modified to a master node. The third server node is further used for obtaining a reconfiguration request of a client, the reconfiguration request is used for requesting to configure a role of the third server node to a slave node, and the role of the third server node is modified to a slave node in response to the reconfiguration request.
6. The system according to any one of claims 1-4, characterized in that, The third server node is specifically configured to determine whether a user corresponding to the read-write request is within a range of releasable users, and if not, reject the read-write request.
7. A method of processing in a server node, characterized by The distributed disaster recovery system includes a first server node currently serving as a master, a second server node currently serving as a slave, and a third server node currently serving as a newly added role; the third server node is deployed in a different availability zone from the first server node and the second server node, and the number of server nodes in any availability zone is less than half of the total number of server nodes. The method is executed by the third server node and includes: obtaining a log synchronization request sent by the first server node, the log synchronization request being used to request synchronization of a log entry, the log entry being used to record a write request of a client obtained by the first server node; responding to the log synchronization request and returning a corresponding response result to the first server node; obtaining a commit notification for the log entry sent by the first server node according to the response result; responding to the commit notification and committing the log entry; obtaining a read-write request of a client and rejecting the read-write request.
8. The method of claim 7, wherein, The method further includes: responding to a voting request sent by the second server node, determining whether to agree to vote for the second server node, and returning a corresponding voting result to the second server node; and / or if a heartbeat packet sent by the first server node is not received within a preset time, voting for oneself and sending a voting request to other server nodes except itself, so that the other server nodes return a corresponding voting result; if the voting result of more than half of the server nodes is agreement, modifying the role of the self to a master.
9. The method of claim 8, wherein, After the role of the self is modified to the master, the method further includes: prohibiting a write request and periodically sending a start election request to a target server node matched with the self until the role of the target server node is modified to a master.
10. The method according to any one of claims 7-9, characterized in that, The method further includes: obtaining a reconfiguration request of a client, the reconfiguration request being used to request configuration of a role to a slave; responding to the reconfiguration request and modifying the role of the self to a slave.
11. The method according to any one of claims 7-9, characterized in that, The rejection of the read-write request includes: determining whether a user corresponding to the read-write request is within a range of releasable users, and if not, rejecting the read-write request.
12. A server node processing device, comprising: The distributed disaster recovery system includes a first server node currently serving as a master, a second server node currently serving as a slave, and a third server node currently serving as a newly added role; the third server node is deployed in a different availability zone from the first server node and the second server node, and the number of server nodes in any availability zone is less than half of the total number of server nodes. The apparatus is used for the third server node and includes: an obtaining module configured to obtain a log synchronization request sent by the first server node, the log synchronization request being used to request synchronization of a log entry, the log entry being used to record a write request of a client obtained by the first server node; a first response module configured to respond to the log synchronization request and return a corresponding response result to the first server node; and a second response module configured to obtain a commit notification for the log entry sent by the first server node according to the response result. The obtaining module is further configured to obtain a submission notification for the log entry sent by the first server node according to the response result; The second response module is configured to submit the log entry in response to the submission notification; The obtaining module is further configured to obtain a read-write request of a client; The rejection module is configured to reject the read-write request.
13. A computing device, comprising: Comprise: A memory and a processor; wherein the memory is configured to store one or more computer instructions; wherein the one or more computer instructions, when executed by the processor, implement the method in any one of claims 7 to 11.
14. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed, the method in any one of claims 7 to 11 is implemented.
Citation Information
Patent Citations
Implementation method of flattened high-availability namenode model
CN107832138A
Fault Rectification Method, Device, and System
US20190386893A1