Data disaster recovery method, electronic equipment and storage medium
By removing some nodes in the cluster of the RAFT protocol to achieve the preset proportion, it ensures that the backup computer room replaces the main computer room to provide services. This solves the service interruption problem caused by the failure of the RAFT protocol cluster under dual computer room deployment and realizes active-active data capacity. The effect of disaster.
Patent Information
- Application Number
- CN202311435021.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2024-10-18
AI Technical Summary
Existing RAFT protocol clusters will stop distributed services when half of the nodes fail, resulting in the need to deploy three computer rooms to achieve disaster recovery. However, in many application scenarios, operators can only deploy two computer rooms to meet disaster recovery needs.
By removing some nodes when the main computer room fails, the nodes in the backup computer room reach the preset proportion, thereby complying with the RAFT protocol and ensuring that the backup computer room replaces the primary computer room to provide distributed services and continue services.
It achieves compliance with the RAFT protocol under dual computer room deployment, ensures the continuity of distributed services, avoids service interruptions due to single computer room failures, and meets the needs of dual-active data disaster recovery.
Smart Images

Figure CN118802478A_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of data disaster recovery technology, and in particular to a data disaster recovery method, electronic equipment and storage medium. Background Art
[0002] RAFT is an algorithm for achieving multi-copy consistency in a non-Byzantine environment, as a distributed cluster protocol. A cluster using the RAFT protocol will stop distributed services when half of the nodes fail.
[0003] Deploying nodes in multiple computer rooms is a very common data disaster recovery method. For a RAFT protocol cluster, the number of computer rooms must be more than three. This is because in a two-computer room deployment solution, one computer room must have more than or equal to half of the nodes. Once this computer room fails (such as a power outage, natural disaster, etc.), the distributed service will be interrupted regardless of whether the other computer room is normal.
[0004] In many application scenarios, the operator only needs to deploy two computer rooms to meet the disaster recovery requirements. Therefore, how to achieve active-active (dual computer room) data disaster recovery in a RAFT protocol cluster is a technical problem to be solved by this application. Summary of the invention
[0005] The purpose of the present application is to provide a data disaster recovery method, an electronic device and a storage medium, which can realize active-active data disaster recovery of a cluster under the RAFT protocol.
[0006] In order to achieve the above purpose, the embodiment of the present application is implemented as follows:
[0007] In a first aspect, a data disaster recovery method is provided, which is applied to a target cluster of a distributed consistency RAFT protocol, wherein the target cluster is composed of a plurality of nodes deployed in a primary computer room and a plurality of nodes deployed in a backup computer room, and the method comprises:
[0008] When providing distributed services based on the primary computer room, if the primary computer room fails, at least some of the nodes in the primary computer room are removed from the target cluster, so that the surviving nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes in the target cluster corresponding to the preset proportion is the minimum number of nodes for providing the distributed service; and,
[0009] Based on the RAFT protocol, the standby computer room is controlled to replace the main computer room to provide the distributed service.
[0010] In a second aspect, an electronic device comprises: a processor; and a memory arranged to store computer executable instructions, wherein when the executable instructions are executed, the processor performs the following operations:
[0011] When providing distributed services based on the primary computer room, if the primary computer room fails, at least some of the nodes in the primary computer room are removed from the target cluster so that the nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes in the target cluster corresponding to the preset proportion is the minimum number of nodes for providing the distributed service; and,
[0012] The standby computer room and the main computer room are controlled based on the RAFT protocol to provide the distributed service.
[0013] In a third aspect, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
[0014] When providing distributed services based on the primary computer room, if the primary computer room fails, at least some of the nodes in the primary computer room are removed from the target cluster so that the nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes in the target cluster corresponding to the preset proportion is the minimum number of nodes for providing the distributed service; and,
[0015] The standby computer room and the main computer room are controlled based on the RAFT protocol to provide the distributed service.
[0016] This application deploys the nodes in the cluster of the RAFT protocol in different locations according to the main computer room and the backup computer room. When providing distributed services based on the main computer room, if the main computer room fails, at least some of the nodes in the main computer room will be removed from the target cluster, so that the faulty nodes in the entire target cluster do not exceed the proportion of stopped distributed services required by the RAFT protocol, so as to still comply with the RAFT protocol to control the backup computer room to replace the main computer room to continue the distributed service. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0018] Figure 1 The figure is a flow chart of the data disaster recovery method according to the embodiment of the present application.
[0019] Figure 2 This is a schematic diagram of a first node state of a target cluster in the data disaster recovery method of an embodiment of the present application.
[0020] Figure 3 This is a schematic diagram of a second node state of a target cluster in the data disaster recovery method of an embodiment of the present application.
[0021] Figure 4 This is a schematic diagram of a third node state of a target cluster in the data disaster recovery method according to an embodiment of the present application.
[0022] Figure 5 This is a schematic diagram of a fourth node state of a target cluster in the data disaster recovery method according to an embodiment of the present application.
[0023] Figure 6 A schematic diagram of the data status of a target cluster in the data disaster recovery method according to an embodiment of the present application.
[0024] Figure 7 This is a schematic diagram of the fifth node state of the target cluster in the data disaster recovery method according to an embodiment of the present application.
[0025] Figure 8 This is a schematic diagram of the sixth node state of the target cluster in the data disaster recovery method according to an embodiment of the present application.
[0026] Fig. 9 This is a schematic diagram of the seventh node state of the target cluster in the data disaster recovery method of an embodiment of the present application.
[0027] Fig.10 This is a schematic diagram of the eighth node state of the target cluster in the data disaster recovery method according to an embodiment of the present application.
[0028] Fig.11 A schematic diagram of the structure of a data disaster recovery device according to an embodiment of the present application.
[0029] Fig.12 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] As mentioned above, a cluster using the RAFT protocol will stop distributed services when half of the nodes fail. To this end, the operator needs to deploy at least three computer rooms to achieve disaster recovery. This is because in the dual-computer room deployment solution, one computer room must have more than or equal to half of the nodes. Once this computer room fails, the distributed service will be interrupted regardless of whether the other computer room is normal. In many application scenarios, the operator does not have the conditions to deploy three computer rooms, or deploying two computer rooms can meet the disaster recovery requirements.
[0031] To this end, the present application aims to propose a technical solution for realizing active-active data disaster recovery in a RAFT protocol cluster. Specifically, the present application deploys the nodes in the RAFT protocol cluster in different locations according to the main computer room and the backup computer room. When providing distributed services based on the main computer room, if a failure occurs in the main computer room, at least some of the nodes in the main computer room are removed from the target cluster, so that the proportion of failed nodes in the entire target cluster does not exceed the proportion of stopped distributed services required by the RAFT protocol, thereby still complying with the RAFT protocol to control the backup computer room to replace the main computer room to continue the distributed service.
[0032] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0033] An embodiment of the present application provides a data disaster recovery method. Figure 1 This is a flowchart of the data disaster recovery method, including:
[0034] S102, when providing distributed services based on the main computer room, if the main computer room fails, at least some of the nodes in the main computer room are removed from the target cluster, so that the surviving nodes in the backup computer room reach a preset proportion in the target cluster; wherein the number of nodes corresponding to the preset proportion in the target cluster is the minimum number of nodes for providing distributed services.
[0035] In this embodiment, the target cluster includes only one main computer room and one backup computer room, and at least more than half of the nodes provide distributed services (the type of distributed services is not specifically limited). When both the main computer room and the backup computer room can provide distributed services independently, the main computer room is preferred to provide distributed services to achieve the goal of saving resources.
[0036] Here, the provision of distributed services by the main computer room is considered normal. A failure in the main computer room refers to a sudden accident such as a power outage or a natural disaster that causes all nodes in the main computer room to be in a non-survivable failure state.
[0037] In this embodiment, after a failure occurs in the primary computer room, at least some nodes in the primary computer room are removed from the target cluster, so that the number of surviving nodes in the standby computer room can meet the requirement of the target cluster to provide distributed services.
[0038] Take the case where the RAFT protocol is not changed as an example. As mentioned above, the target cluster using the RAFT protocol will stop distributed services when half of the nodes fail. Here, the main computer room is defined as computer room A, and the backup computer room is defined as computer room B;
[0039] Assume that the total number of nodes in the target cluster is 101, of which 51 are in room A and 50 are in room B. When room A fails, the remaining surviving nodes in the target cluster are the 50 nodes in room B. In order to prevent half of the nodes in the target cluster from failing, at least two nodes in room A need to be removed from the cluster.
[0040] Here we take the example of removing two nodes from computer room A. The total number of nodes in the target cluster becomes 99, and the nodes in computer room B account for 50 / 99 of the target cluster, which is more than half. At this point, distributed services can continue to be provided based on computer room B.
[0041] S104, based on the RAFT protocol, the standby computer room is controlled to replace the main computer room to provide distributed services.
[0042] Based on the above, when the number of surviving nodes in computer room B (backup computer room) reaches half of the total number of nodes in the cluster, the existing RAFT protocol can be followed to control computer room B to provide distributed services for computer room A (primary computer room), so that the target cluster can continue to provide distributed services after computer room A fails.
[0043] In addition, during the failure recovery of the main computer room, the nodes removed from the target cluster can be added back to the target cluster. After the failure recovery of the main computer room, if the surviving nodes of the main computer room reach the preset proportion in the target cluster, and the latest data of at least one surviving node in the main computer room is consistent with the latest data of the current core node, then the main computer room is controlled based on the RAFT protocol to replace the backup computer room to provide distributed services. That is, when both the main computer room and the backup computer room can provide distributed services independently, the distributed services are provided based on the main computer room first, so as to achieve the goal of saving resources.
[0044] The following describes how to achieve strong data synchronization between nodes in the target cluster.
[0045] Specifically, the nodes of the target cluster of this embodiment include: a core node deployed in a primary computer room or a backup computer room; multiple non-core nodes deployed in the primary computer room; and multiple non-core nodes deployed in the backup computer room.
[0046] Among them, the core node is responsible for writing data for distributed services, and all other non-core nodes synchronize data with the core node. In the case that the core node is not alive (for example, the core node is in computer room A, and computer room A fails), a surviving one with the latest data is elected from all non-core nodes as the new core node. If the latest data of the surviving node in the main computer room is consistent with the latest data of the surviving node in the standby computer room, a surviving node with the latest data is elected from the computer room currently providing the distributed service as the new core node. In addition, after the main computer room fails and the distributed service is provided by the main computer room controlled by the RAFT protocol, the core node needs to be re-elected.
[0047] Specifically, the data synchronization method can adopt the existing RAFT protocol, which mainly includes the following two methods:
[0048] 1) Snapshot overwrite: When the core node cannot find the term number and offset of the non-core node, or there is a difference with the core node, the core node will use the snapshot overwrite method to send its own snapshot data to the non-core node, completely overwriting the data of the non-core node.
[0049] 2) Log append: When the core node can find the term number and offset of the non-core node, it will send all the data between the offset of the non-core node and the latest offset of the core node to the non-core node, and the non-core node will append the log.
[0050] For ease of understanding, the nodes in the target cluster are classified into the following categories for introduction:
[0051] 1) Core node: It is selected from all the surviving nodes in the target cluster. The node selected as the core node is the one with the latest data in the target cluster. It can be from computer room A or computer room B. The data between nodes can be determined by term number and / or offset.
[0052] 2) Node B in the computer room: The non-core nodes in computer room B have a higher priority for data synchronization with the core nodes than the non-core nodes in computer room A.
[0053] 3) Non-core nodes in computer room A: These nodes have the lowest priority in data synchronization with core nodes. That is, the data in the non-core nodes in computer room A will not be newer than the nodes in computer room B.
[0054] 4) Temporary core node; that is, a re-elected core node relative to the original core node.
[0055] 5) Temporarily discarded nodes; that is, nodes removed from the target cluster; temporarily discarded nodes belong to nodes in computer room A.
[0056] 6) Faulty nodes; that is, non-surviving nodes.
[0057] Take the example that computer room A has one more node than computer room B. Figure 2 This is a schematic diagram of the nodes in the target cluster under normal circumstances. The dotted lines only describe the reachability between nodes and do not represent the connection for heartbeat and data synchronization.
[0058] When a failure occurs in computer room B, the node status of the target cluster becomes Figure 3 At this time, based on the RAFT protocol, if the number of surviving nodes in the target cluster is more than half, then computer room A can still provide distributed services normally.
[0059] When A and computer room B are both healthy, but (N-1) / 2 nodes fail, the node status of the target cluster is as follows: Figure 4 As shown in the figure, based on the RAFT protocol, more than half of the nodes in the target cluster survive, so services can be provided.
[0060] When a failure occurs in computer room A, the node status of the target cluster becomes Figure 5 As shown in the figure, the target cluster has less than half of its surviving nodes. Correspondingly, the offset of the surviving nodes in the target cluster is Figure 6 Three types of situations are shown. Figure 6 In the figure, a square represents a piece of data, and the number in the square represents the offset, where the larger the offset, the newer the data. Based on the aforementioned data synchronization priority strategy, the core node has the largest offset, and the nodes in computer room B may all synchronize to the data of the core node, or they may be partially synchronized. However, under RAFT, the protocol is effective only when more than half of the nodes write the same data. Therefore, the data write is effective only when all the nodes in computer room B are synchronized with the core node.
[0061] Further references Figure 7 As shown. Due to the failure of computer room A, the number of surviving nodes in the target cluster is less than half. Under the unchanged RAFT protocol, in order to ensure the continued provision of distributed services, it is necessary to temporarily discard two nodes in computer room A. At this time, there are a total of (N-1) / 2 nodes surviving in the remaining computer room B, which is more than half of the target cluster, and distributed services can continue to be provided. At the same time, the election mechanism is triggered, and the node with the largest offset in computer room B will receive votes from all nodes in computer room B, so the node with the largest offset in computer room B serves as a temporary core node. Among them, computer room A will re-select the core node in computer room A after the failure, and the temporary core node in computer room B will be downgraded to a non-master node.
[0062] In addition, when computer room A is restored, the node status of the target cluster is as follows Figure 8As shown. The nodes in computer room A that have not been discarded automatically join the target cluster and start to recover data. At this time, the master mechanism can be used for recovery, and the current term and offset can be synchronized to the temporary core node in computer room B. If the temporary core node finds the term and offset, the data from this offset to the current offset will be sent to the slave node by log appending. If it cannot be found, the data snapshot of the temporary core node will be synchronized to the slave node, overwriting the slave node data to help the slave node recover data. In general, the node in computer room A that was the core node before the failure needs the temporary core node to synchronize the data snapshot to this node, overwriting the node data. The write priority of the core node before the failure is high. It is possible that the core node before the failure was successfully written, but the node in computer room B was not successfully written, so the offset of the core node may be different from the offset of the current cluster; due to the synchronization priority strategy, the offsets of other nodes except the core node are always smaller than the offsets of the nodes in computer room B, and the data can be recovered by log appending.
[0063] While synchronizing data, the temporary core node will send a master message to inform Room A that any node has been upgraded to a master node and the current running status of the cluster, such as the status, term, and offset of each Follower. At the same time, the new master node information needs to be synchronized to other slave nodes to ensure that the master node is transferred to Room A and becomes a core node. The stage status of the target cluster is as follows: Fig. 9 As shown in the figure, the reason why any node is selected is that before the core node is selected in computer room A, all nodes are equivalent. Only after the core node is selected, there will be a difference in writing priority.
[0064] After the core node election is completed, the temporarily discarded node will be added to the cluster again. Since the temporarily discarded node is in the faulty computer room and its offset lags behind other nodes, data recovery will be performed in the same way as the non-discarded nodes in the faulty computer room. The data of the core nodes will be synchronized by log append or snapshot. When the discarded node joins the cluster, it sends its current term and offset to the core node. If the core node can find this term and offset in its own log, it will synchronize the missing data of the discarded node to the discarded node by log append. If it cannot find it, it will send a data snapshot of the core node to overwrite the data of the lost node. At this point, the node status of the target cluster has been restored. Fig.10 Normal starting state shown.
[0065] The following is an analysis of the special situations in the above disaster recovery.
[0066] During the recovery process of computer room A, if computer room B suddenly fails, if the core node has been elected in computer room A, computer room A is recovering the temporarily discarded node and continuing the recovery. When the node in computer room A is recovered, the number of surviving nodes is greater than half of the total number of nodes, and distributed services can continue to be provided; if the core node has not been elected, it means that computer room A has not yet synchronized the data of computer room B. At this time, to prevent data inconsistency, the cluster should be in a state of being unable to serve.
[0067] The following is an analysis of several core continuous failures in the above disaster recovery.
[0068] From the normal state analysis, the node that fails first must be the core node, located in computer room A. At this time, the data status of the nodes in the target cluster is Figure 6 In scenario 1, the node A in computer room or the node B in computer room may be elected as the next core node. In scenarios 2 and 3, the node B in computer room may be elected as the next core node.
[0069] To keep the system simple, the election priority of the node in computer room A is set higher than that of the node in computer room B. When the nodes in computer rooms A and B meet the core node conditions, the node in computer room A is selected as the core node. In scenario 1, the node in computer room A is elected as the core node. Since it is in computer room A, this node is the core node. At this time, the target cluster returns to normal and can continue to provide distributed services.
[0070] In scenarios 2 and 3, since the offset of the node in computer room A lags behind, only the node in computer room B can be elected as the core node. At this time, it is necessary to continue to synchronize data to the remaining nodes in computer room A. After the synchronization of the node in computer room A is completed, the core node can be switched to computer room A through the master mechanism. One of the surviving nodes in computer room A can be used as the core node. At this time, the target cluster returns to normal and can continue to provide distributed services.
[0071] If a temporary core node failure occurs in computer room B during the synchronization process, a new vote will be held. At this time, it is expected that the node in computer room B will be elected as the temporary node, so that the previous logic can be continued to restore the target cluster. In order to achieve the purpose of computer room B being elected, a logic needs to be added. The temporary core node also gives priority to writing to the node in computer room B during its term of office, and then to the node in computer room A. The result is returned after more than half of the writes are completed, so that when the temporary core node fails, the node in computer room B can take over this core node and start the next term. This rule will only fail to elect when all nodes in computer room B fail. At this time, the failed nodes of the entire target cluster are the core nodes and all nodes in computer room B. If more than half of them are failed, the failure of the target cluster is allowed. Before all nodes in computer room B fail, the temporary core node data is synchronized successfully, and the core node of computer room A is restored by letting the main mechanism. The target cluster will return to normal and can continue to provide distributed services.
[0072] The following is an analysis of the performance of the above disaster recovery
[0073] The main difference from the traditional RAFT protocol is the priority strategy. The traditional Raft protocol sends synchronization messages to all nodes and considers the write successful after receiving replies from half of the nodes. This theory is to first notify the nodes in computer room B, and consider the write successful after receiving replies from all nodes in computer room B, and then synchronize the non-core nodes in computer room A. Assume that the time for a single node to send a synchronization message is N, the maximum response time of the node is M, and the number of nodes excluding the core nodes is X.
[0074] Nodes call each other through the remote procedure call protocol. Based on the NIO network model, the time required for traditional Raft synchronization is about N*X+M, and the time required for Raft six-state theory is about (N*X / 2+M)*2. However, since the write success can be responded after synchronization to more than half of the nodes, the response can be made in N*X / 2+M time, and the subsequent N*X / 2+M time can be asynchronously operated, so the overall performance is not significantly reduced.
[0075] With the above Figure 1 Corresponding to the method shown, another embodiment of the present application further provides a data disaster recovery device. Fig.11 1 is a schematic diagram of the structure of the data disaster recovery device 1100 of this embodiment, including:
[0076] A node changing module 1110 is used to remove at least some of the nodes in the main computer room from the target cluster when providing distributed services based on the main computer room, if the main computer room fails, so that the surviving nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes corresponding to the preset proportion in the target cluster is the minimum number of nodes for providing the distributed service; and,
[0077] The disaster recovery execution module 1120 is used to control the standby computer room to replace the main computer room to provide the distributed service based on the RAFT protocol.
[0078] Optionally, the nodes of the target cluster include: a core node deployed in the main computer room or the backup computer room, multiple non-core nodes deployed in the main computer room, and multiple non-core nodes deployed in the backup computer room; wherein, the core node is responsible for writing data for the distributed service, the non-core nodes synchronize data with the core nodes, and the data synchronization priority of the non-core nodes in the backup computer room to the core nodes is higher than that of the non-core nodes in the main computer room.
[0079] Optionally, the device of this embodiment further includes:
[0080] The election module is used to elect a surviving node with the latest data from all the non-core nodes as a new core node when the core node is not alive.
[0081] Among them, if the latest data of the surviving nodes in the main computer room is consistent with the latest data of the surviving nodes in the backup computer room, the election module selects a surviving node with the latest data from all the non-core nodes as the new core node, including: selecting a surviving node with the latest data from the computer room currently providing the distributed service as the new core node.
[0082] Optionally, the node changing module 1110 is further configured to add the nodes removed from the target cluster back into the target cluster during the process of failure recovery of the primary computer room.
[0083] Optionally, the disaster recovery execution module 1120 is also used for: after the fault of the main computer room is recovered, if the surviving nodes of the main computer room reach the preset proportion in the target cluster, and the latest data of at least one surviving node in the main computer room is consistent with the latest data of the current core node, then based on the RAFT protocol, controlling the main computer room to replace the backup computer room to provide the distributed service.
[0084] The election module re-elects the core node after controlling the main computer room to replace the backup computer room to provide the distributed service based on the RAFT protocol.
[0085] Optionally, the main computer room has one more node than the standby computer room; and the partial nodes are two nodes.
[0086] Obviously, the data disaster recovery device of this embodiment can be used as Figure 1The execution subject of the method shown can thus realize Figure 1 The steps and functions in the method shown will not be repeated here.
[0087] Fig.12 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Fig.12 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0088] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.12 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0089] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0090] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming the above-mentioned data disaster recovery device at the logical level. Correspondingly, the processor executes the program stored in the memory and is specifically used to execute:
[0091] When providing distributed services based on the main computer room, if the main computer room fails, at least some of the nodes in the main computer room are removed from the target cluster, so that the nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes corresponding to the preset proportion in the target cluster is the minimum number of nodes for providing the distributed service. And,
[0092] The standby computer room and the main computer room are controlled based on the RAFT protocol to provide the distributed service.
[0093] The above is as in this manual Figure 1 The method disclosed in the illustrated embodiment can be applied to a processor and implemented by the processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0094] It should be understood that the electronic device of the embodiment of the present application can enable the service processing device to implement the corresponding Figure 1 The steps and functions in the method shown in the figure are not repeated in this article because the principles are the same.
[0095] Of course, in addition to software implementation, the electronic device of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0096] In addition, an embodiment of the present application also proposes a computer-readable storage medium, which stores one or more programs, and the one or more programs include instructions.
[0097] When the above instructions are executed by a portable electronic device including multiple application programs, the portable electronic device can execute Figure 1 The steps of the method shown include:
[0098] When providing distributed services based on the main computer room, if the main computer room fails, at least some of the nodes in the main computer room are removed from the target cluster, so that the nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes corresponding to the preset proportion in the target cluster is the minimum number of nodes for providing the distributed service. And,
[0099] The standby computer room and the main computer room are controlled based on the RAFT protocol to provide the distributed service.
[0100] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take 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 code.
[0101] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0102] The above are only embodiments of this specification and are not intended to limit this specification. For those skilled in the art, this specification may be subject to various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the scope of the claims of this specification. In addition, all other embodiments obtained by ordinary technicians in this field without creative work shall fall within the scope of protection of this document.
Claims
1. A data disaster recovery method, applied to a target cluster of a distributed consistency RAFT protocol, characterized in that: The target cluster is composed of a plurality of nodes deployed in a primary computer room and a plurality of nodes deployed in a backup computer room, and the method includes: When providing distributed services based on the primary computer room, if the primary computer room fails, at least some of the nodes in the primary computer room are removed from the target cluster, so that the surviving nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes in the target cluster corresponding to the preset proportion is the minimum number of nodes for providing the distributed service; and, Based on the RAFT protocol, the standby computer room is controlled to replace the main computer room to provide the distributed service.
2. The method according to claim 1, characterized in that The nodes of the target cluster include: a core node deployed in the primary computer room or the backup computer room, a plurality of non-core nodes deployed in the primary computer room, and a plurality of non-core nodes deployed in the backup computer room; The core node is responsible for writing data for the distributed service, the non-core node synchronizes data with the core node, and the non-core node in the standby computer room has a higher priority for data synchronization with the core node than the non-core node in the main computer room.
3. The method according to claim 2, characterized in that Also includes: In the case that the core node is not alive, a alive node with the latest data is selected from all the non-core nodes as the new core node.
4. The method according to claim 3, characterized in that Also includes: If the latest data of the surviving node in the primary computer room is consistent with the latest data of the surviving node in the standby computer room, then selecting a surviving node with the latest data from all the non-core nodes as the new core node includes: A surviving node with the latest data is selected from the computer room currently providing the distributed service as the new core node.
5. The method according to any one of claims 1 to 4, characterized in that: Also includes: During the failure recovery process of the primary computer room, the nodes removed from the target cluster are added back to the target cluster.
6. The method according to claim 5, characterized in that Also includes: After the failure of the main computer room is recovered, if the surviving nodes of the main computer room reach the preset proportion in the target cluster, and the latest data of at least one surviving node in the main computer room is consistent with the latest data of the current core node, the main computer room is controlled based on the RAFT protocol to replace the backup computer room to provide the distributed service.
7. The method according to claim 6, characterized in that Also includes: After the main machine room is controlled to replace the standby machine room to provide the distributed service based on the RAFT protocol, the core node is re-elected.
8. The method according to any one of claims 1 to 4, characterized in that: Also includes: The main computer room has one more node than the standby computer room; and some of the nodes are two nodes.
9. An electronic device, comprising: processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to perform the following operations: When providing distributed services based on the primary computer room, if the primary computer room fails, at least some of the nodes in the primary computer room are removed from the target cluster so that the nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes in the target cluster corresponding to the preset proportion is the minimum number of nodes for providing the distributed service; and, The standby computer room and the main computer room are controlled based on the RAFT protocol to provide the distributed service.
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 following steps are implemented: When providing distributed services based on the primary computer room, if the primary computer room fails, at least some of the nodes in the primary computer room are removed from the target cluster so that the nodes in the standby computer room reach a preset proportion in the target cluster; wherein the number of nodes in the target cluster corresponding to the preset proportion is the minimum number of nodes for providing the distributed service; and, The standby computer room and the main computer room are controlled based on the RAFT protocol to provide the distributed service.
