Method, device and electronic equipment for preventing distributed database split-brain

By working together with the management node and the agent module, the status of business component nodes can be monitored and switched in real time, which solves the split-brain problem caused by network anomalies in distributed databases and improves data security and consistency.

CN116232858BActive Publication Date: 2026-11-20JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211699291.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2026-11-20
Estimated Expiration
2042-12-28

AI Technical Summary

Technical Problem

In a distributed system, network jitter or network partitioning can cause abnormal heartbeat transmission between the management node and business components, leading to misjudgment by the management node, resulting in the activation of two master nodes, triggering a split-brain scenario and data inconsistency.

Method used

The management node sends heartbeat information to the business component nodes and receives feedback from the agent module. If an anomaly is detected, a switchover command is sent to switch the business component node to standby or take it offline. The agent module receives the heartbeat from the management node and switches states when an anomaly occurs to avoid split-brain.

Benefits of technology

When business component nodes malfunction, the proxy module controls and avoids dual-master and split-brain scenarios during network anomalies or partitions, thus improving data security and consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116232858B_ABST
    Figure CN116232858B_ABST
Patent Text Reader

Abstract

The application relates to a method and device for preventing brain split of a distributed database and electronic equipment, which are applied to a management node, and the method comprises the following steps: sending first heartbeat information to a business component node; determining whether the business component node is abnormal based on second heartbeat information received from an agent module corresponding to the business component node within a first preset time period; and sending a switching instruction to the agent module corresponding to the business component node if the business component node is abnormal, wherein the switching instruction is used for instructing the agent module to control the business component node to switch to a backup or offline state. According to the embodiment, when the business component node is abnormal, the management node can automatically offline or set the business component node in the isolation area to a backup state, so that the situation of double master and brain split in network exception or partition is avoided, and the data security and data consistency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a method, apparatus, and electronic device for preventing split-brain in distributed databases. Background Technology

[0002] In distributed systems, primary and backup nodes are often deployed synchronously over a network. The switching between primary and backup nodes is controlled by a management node, which uses heartbeats to detect the status of relevant business components. When the management node cannot detect the status of the primary node in a business component or detects a failure in the primary node, it will perform a primary-backup switch according to the switching strategy.

[0003] However, the heartbeat between the management node and the business components is also transmitted over the network. When a network anomaly occurs, the management node and the business components cannot transmit heartbeats normally, which causes the management node to make a misjudgment, start two master nodes, and trigger a split-brain, resulting in dual writes and data inconsistency between multiple replicas. Summary of the Invention

[0004] To address the technical problem of brain splitting among replicas of business component nodes caused by network jitter or network partitioning during the leadership election of business components by management nodes in existing distributed systems, this application provides a method, apparatus, and electronic device for preventing brain splitting in distributed databases.

[0005] In a first aspect, this application provides a method for preventing split-brain in distributed databases, applied to management nodes, the method comprising:

[0006] Send the first heartbeat message to the business component node;

[0007] If a second heartbeat message is received from the proxy module corresponding to the business component node within a first preset time period, the business component node is determined to be abnormal based on the second heartbeat message.

[0008] If the business component node malfunctions, a switchover instruction is sent to the proxy module corresponding to the business component node. The switchover instruction is used to instruct the proxy module to control the business component node to switch to standby or go offline.

[0009] Optionally, the method further includes:

[0010] If no second heartbeat information is received from the business component node within the first preset time period, it will switch to standby or go offline.

[0011] Optionally, the method further includes:

[0012] If the business component node does not experience any abnormalities, return to the step of sending the first heartbeat information to the business component node and reset the first preset time period.

[0013] Secondly, this application provides a method for preventing split-brain in distributed databases, applied to a proxy module corresponding to a business component node, the method comprising:

[0014] Determine whether a first heartbeat message from the management node is received within the second preset time period;

[0015] If a first heartbeat message is received from the management node within the second preset time period, determine whether a switching instruction has been received from the management node.

[0016] If the switching instruction is received, the business component node to which it belongs will be switched to standby or taken offline.

[0017] Optionally, the method further includes:

[0018] If no first heartbeat information is received from the management node within the second preset time period, the business component node to which it is located will be switched to standby or taken offline.

[0019] Optionally, the method further includes:

[0020] If the switching instruction is not received, obtain its own status information;

[0021] Send a second heartbeat message containing the status information to the management node.

[0022] Thirdly, this application provides a device for preventing split-brain in distributed databases, applied to a management node, the device comprising:

[0023] The first sending module is used to send the first heartbeat information to the business component node;

[0024] The first determining module is used to determine whether the business component node is abnormal if it receives second heartbeat information from the proxy module corresponding to the business component node within a first preset time period;

[0025] The second sending module is used to send a switching instruction to the proxy module corresponding to the service component node if the service component node malfunctions. The switching instruction is used to instruct the proxy module to control the service component node to switch to standby mode or go offline.

[0026] Optionally, the device further includes:

[0027] The first switching module is used to switch itself to standby or go offline if it does not receive a second heartbeat message from the business component node within a first preset time period.

[0028] Optionally, the device further includes:

[0029] The execution module is used to return to the step of sending the first heartbeat information to the business component node if no abnormality occurs, and to reset the first preset time period.

[0030] Fourthly, this application provides a device for preventing split-brain in distributed databases, applied to a proxy module corresponding to a business component node, the device comprising:

[0031] The second determining module is used to determine whether a first heartbeat message from the management node is received within a second preset time period.

[0032] The third determining module is used to determine whether a switching instruction from the management node has been received if a first heartbeat information from the management node is received within the second preset time period.

[0033] The second switching module is used to switch its own business component node to standby or offline if it receives the switching instruction.

[0034] Optionally, the device further includes:

[0035] The third switching module is used to switch its own business component node to standby or offline if it does not receive the first heartbeat information from the management node within the second preset time period.

[0036] Optionally, the device further includes:

[0037] The acquisition module is used to acquire its own status information if it does not receive the switching instruction.

[0038] The third sending module is used to send a second heartbeat message containing the status information to the management node.

[0039] Fifthly, this application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0040] Memory, used to store computer programs;

[0041] When a processor executes a program stored in memory, it implements the method for preventing distributed database split-brain as described in either the first aspect or the method for preventing distributed database split-brain as described in either the second aspect.

[0042] In a sixth aspect, this application provides a computer-readable storage medium storing a method program for preventing distributed database split-brain, wherein the method program for preventing distributed database split-brain, when executed by a processor, implements the steps of the method for preventing distributed database split-brain as described in any of the first aspects, or the method for preventing distributed database split-brain as described in any of the second aspects.

[0043] The technical solutions provided in this application have the following advantages compared with the prior art:

[0044] In this embodiment of the application, when a business component node malfunctions, the proxy module can instruct the business component node to switch to standby or go offline. This enables the management node to automatically take the business component node in the isolation zone offline or set it to standby protection mode when a business component node malfunctions (such as a network malfunction). This avoids dual-master and split-brain situations during network malfunctions or partitions, and improves data security and data consistency. Attached Figure Description

[0045] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 A flowchart illustrating a method for preventing split-brain in a distributed database, as provided in this application embodiment;

[0048] Figure 2 Another flowchart of a method for preventing split-brain in a distributed database provided in this application embodiment;

[0049] Figure 3 A flowchart illustrating another method for preventing split-brain in a distributed database, as provided in this application embodiment;

[0050] Figure 4 Another flowchart of a method for preventing split-brain in a distributed database provided in an embodiment of this application;

[0051] Figure 5 A schematic diagram illustrating the principle of a method for preventing split-brain in a distributed database, provided in an embodiment of this application;

[0052] Figure 6A schematic diagram illustrating the principle of a method for preventing split-brain in a distributed database, provided in an embodiment of this application;

[0053] Figure 7 A schematic diagram illustrating the principle of a method for preventing split-brain in a distributed database, provided in an embodiment of this application;

[0054] Figure 8 A structural diagram of a device for preventing split-brain in a distributed database, provided in an embodiment of this application;

[0055] Figure 9 A structural diagram of another device for preventing split-brain in distributed databases provided in an embodiment of this application;

[0056] Figure 10 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0058] Since heartbeats between management nodes and business component nodes are also transmitted over the network, a network anomaly can prevent the management node from transmitting heartbeats properly. This can lead to misjudgment by the management node, causing it to activate two master nodes, triggering a split-brain scenario, resulting in dual writes and data inconsistencies among multiple replicas. Therefore, this application provides a method, apparatus, and electronic device for preventing split-brain in distributed databases.

[0059] In this embodiment, the method for preventing split-brain in a distributed database can be applied to the management node, which is managed by a majority-party management component such as ZooKeeper. If the management node, which is the master node, fails, a new management node can be re-elected as the master node; similarly, if a network partition occurs, a new master node can also be elected based on a majority-party management component.

[0060] The agent module for both business component nodes and management nodes is co-located. The agent does not communicate with the business component nodes via the network. The management node controls the primary / standby status of business component nodes, such as data nodes, through the agent. The agent can monitor and control the status of business component nodes, including setting the current business component node to primary, setting the current business component node to standby, restarting the business component node, and taking the business component node offline.

[0061] A heartbeat connection is established between the management node and the agent. The management node obtains the status of the business component node in real time from the agent through the heartbeat information. If the business component node is the master and is in a healthy state, it maintains its current state. If a certain amount of data is lost in the heartbeat within a specified time, a master-slave switchover is initiated according to the switchover policy. Alternatively, a master-slave switchover will also be triggered if there is a problem with the component health information transmitted in the heartbeat information.

[0062] Agents on the business component nodes receive heartbeat information from the management node in real time. They also statistically analyze this heartbeat information. If a normal heartbeat is received, the agent probes the database node status and replies to the management node. If the management node receives a certain number of abnormal statuses, it will perform a primary / standby switchover according to the failover strategy. If the agent does not receive heartbeat information from the management node within the specified window, an exception handling process will be triggered. The most likely scenario is that the management node has experienced a network partition. To prevent a split-brain scenario, the agent will make the business component node a standby or read-only node, maintaining the state it was in when it last lost contact with the management node. Once the network or management node recovers, further actions will be taken based on the management node's information. This may involve connecting it to a new cluster as a standby node or resetting it as the primary node.

[0063] like Figure 1 and Figure 2 As shown, the method for preventing split-brain in distributed databases includes the following steps:

[0064] Step S101: Send the first heartbeat information to the business component node;

[0065] The management node confirms the heartbeat information with each agent and sends the first heartbeat information to the business component node.

[0066] Step S102: If a second heartbeat message is received from the proxy module corresponding to the business component node within a first preset time period, determine whether the business component node is abnormal based on the second heartbeat message.

[0067] If a second heartbeat message is received from the proxy module corresponding to the business component node within the first preset time period, it indicates that the management node itself is not abnormal, and it is necessary to further determine whether the status of the business component node is abnormal.

[0068] Step S103: If the service component node malfunctions, a switching instruction is sent to the proxy module corresponding to the service component node. The switching instruction is used to instruct the proxy module to control the service component node to switch to standby or go offline.

[0069] In this embodiment of the application, when it is determined that a business component node is abnormal, it can be further determined whether the abnormal business component node is the host among the business component nodes. If the business component node is the host among the business component nodes, then the business component node is set as a standby machine or taken offline. If the business component node is the standby machine among the business component nodes, no processing is performed.

[0070] In other words, if the heartbeat information on the business component node acting as the master node is abnormal, the master-slave switchover action will be triggered after the relevant switching strategy (such as three unhealthy states within a specified time) is determined. This means that the business component node acting as the master node will be switched to the standby node or taken offline, and a switchover command will be sent to that business component node.

[0071] In this embodiment of the application, when a business component node malfunctions, the proxy module can instruct the business component node to switch to a standby or go offline. This enables the management node to automatically take the business component node in the isolation zone offline or set it to a standby protection state when a business component node malfunctions (such as a network malfunction). This avoids dual-master and split-brain situations during network malfunctions or partitions, and improves data security and data consistency.

[0072] In yet another embodiment of this application, as Figure 2 As shown, the method further includes:

[0073] If no second heartbeat information is received from the business component node within the first preset time period, it will switch to standby or go offline.

[0074] If no second heartbeat information is received from the proxy module corresponding to the business component node within the first preset time period, it indicates that the management node itself may be abnormal (such as network abnormality). In this case, it is necessary to switch itself to standby or go offline.

[0075] In other words, if the management node fails to receive heartbeat information a certain number of times within the corresponding window period (e.g., losing 3 heartbeats within 10 seconds), it indicates that the management node itself may be experiencing an anomaly (such as network anomaly). This will trigger a switchover between the primary and backup management nodes, avoiding dual-primary and split-brain situations during network anomalies or partitions, thus improving data security and data consistency.

[0076] In yet another embodiment of this application, as Figure 2 As shown, the method further includes:

[0077] If the business component node does not experience any abnormalities, return to the step of sending the first heartbeat information to the business component node and reset the first preset time period.

[0078] If the management node receives a heartbeat message within a specified time and the status of the business component node is normal, it will maintain the status quo and wait for the next round of heartbeats to be sent after a certain period of time, without triggering the switching mechanism.

[0079] In another embodiment of this application, a method for preventing split-brain in a distributed database is also provided, applied to a proxy module corresponding to a business component node, such as... Figure 3 and Figure 4 As shown, the method includes:

[0080] Step S201: Determine whether a first heartbeat message from the management node has been received within the second preset time period;

[0081] Step S202: If a first heartbeat message is received from the management node within the second preset time period, determine whether a switching instruction has been received from the management node.

[0082] In other words, if the agent receives the heartbeat information normally, it will determine whether there is a switching instruction. If so, it will reset the component information according to the instruction in the heartbeat information.

[0083] Step S203: If the switching instruction is received, the business component node to which it is located is switched to standby or taken offline.

[0084] The management node sends heartbeat information to the agent component. After receiving the heartbeat information, the agent component determines whether there is an instruction. If there is a switchover or offline instruction, it will take the agent component offline or reset the primary / standby status.

[0085] In this embodiment of the application, when a switching instruction is received from the management node, the agent component controls the business component node to switch to standby or go offline. This enables the management node to automatically take the business component node in the isolation zone offline or set it to standby protection mode when an abnormality occurs in the business component node (such as network abnormality). This avoids dual-master and split-brain situations when there is a network abnormality or partition, and improves data security and data consistency.

[0086] In yet another embodiment of this application, as Figure 4 As shown, the method further includes:

[0087] If no first heartbeat information is received from the management node within the second preset time period, the business component node to which it is located will be switched to standby or taken offline.

[0088] In this embodiment of the application, if no first heartbeat information is received from the management node within the second preset time period, the agent further determines whether the business component node it is located on is the host in the business component node. If so, the agent switches the business component node it is located on to the backup or goes offline. If not, no action is taken.

[0089] In other words, if the agent loses a certain amount of heartbeat information from the management node within a specified time window, and the current node is the primary node, the agent will demote or take the node offline to avoid causing dual writes or split-brain scenarios. If the node is determined to be a backup node, no action will be taken.

[0090] In this embodiment, if network isolation occurs, the network agent will not receive heartbeat information from the management node, meaning it will not receive the first heartbeat information from the management node within a second preset time period. If the failure to receive heartbeat information within a specified time exceeds a certain threshold, the component's state will be set to unavailable or standby, avoiding dual-master and split-brain scenarios during network anomalies or partitions, thus improving data security and data consistency.

[0091] In yet another embodiment of this application, as Figure 4 As shown, the method further includes:

[0092] If the switching instruction is not received, obtain its own status information;

[0093] Send a second heartbeat message containing the status information to the management node.

[0094] After receiving the heartbeat information, the agent obtains the status of the business component node and feeds the status back to the management node.

[0095] For ease of understanding, this application is illustrated in the figures. Figure 5 , Figure 6 and Figure 7 Furthermore, an embodiment in a practical application is also provided.

[0096] Figure 5 This indicates a normal system state. The master node, the management node, communicates with the agent component via heartbeat messages and obtains the status of each node. If the master node's status is abnormal, a master-slave switch will be performed according to the failover policy. If the standby node's status is abnormal, the master-slave status will remain unchanged.

[0097] Figure 6 When a network partition occurs, the management node cluster will perform a master-slave switch according to the majority protocol, and the management node will switch to the network zone where the management node holds a majority. Once the switch occurs, the management node will detect and trigger the switch of the business component nodes.

[0098] Figure 7 When a management node switches to another partition and finds that there is no master node in that area, it will start a new master node according to the switchover policy. Within the original master node's network partition, the management node will automatically degrade, and heartbeat information between the original master node and business nodes or data nodes will be lost. If the agent node does not receive a sufficient number of heartbeats within a specified time, it will assume that the management node has formed a partition and will automatically degrade the business component nodes.

[0099] In another embodiment of this application, a device for preventing split-brain in distributed databases is also provided, for managing nodes, such as... Figure 8 As shown, the device includes:

[0100] The first sending module 11 is used to send the first heartbeat information to the service component node;

[0101] The first determining module 12 is used to determine whether the business component node is abnormal if it receives second heartbeat information from the proxy module corresponding to the business component node within a first preset time period;

[0102] The second sending module 13 is used to send a switching instruction to the proxy module corresponding to the service component node if the service component node is abnormal. The switching instruction is used to instruct the proxy module to control the service component node to switch to standby or go offline.

[0103] Optionally, the device further includes:

[0104] The first switching module is used to switch itself to standby or go offline if it does not receive a second heartbeat message from the business component node within a first preset time period.

[0105] Optionally, the device further includes:

[0106] The execution module is used to return to the step of sending the first heartbeat information to the business component node if no abnormality occurs, and to reset the first preset time period.

[0107] In another embodiment of this application, a device for preventing split-brain in a distributed database is also provided, applied to a proxy module corresponding to a business component node, such as... Figure 9 As shown, the device includes:

[0108] The second determining module 21 is used to determine whether the first heartbeat information from the management node is received within the second preset time period;

[0109] The third determining module 22 is used to determine whether a switching instruction from the management node has been received if the first heartbeat information from the management node is received within the second preset time period.

[0110] The second switching module 23 is used to switch its own business component node to standby or offline if it receives the switching instruction.

[0111] Optionally, the device further includes:

[0112] The third switching module is used to switch its own business component node to standby or offline if it does not receive the first heartbeat information from the management node within the second preset time period.

[0113] Optionally, the device further includes:

[0114] The acquisition module is used to acquire its own status information if it does not receive the switching instruction.

[0115] The third sending module is used to send a second heartbeat message containing the status information to the management node.

[0116] In another embodiment of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0117] Memory, used to store computer programs;

[0118] When a processor executes a program stored in memory, it implements either the aforementioned method for preventing distributed database split-brain as applied to a management node or the aforementioned method for preventing distributed database split-brain as applied to a business component node.

[0119] The electronic device provided in this embodiment of the invention enables the processor to execute a program stored in the memory. When a business component node malfunctions, the processor can instruct the business component node to switch to standby or go offline via a proxy module. This allows the management node to automatically take the business component node in the isolation zone offline or set it to standby protection mode when a business component node malfunctions (such as a network malfunction). This avoids dual-master and split-brain situations during network malfunctions or partitions, and improves data security and data consistency.

[0120] Alternatively, upon receiving a switchover command from the management node, the agent component will control the business component node to switch to standby or go offline. This allows the management node to automatically take the business component node in the isolation zone offline or set it to standby protection mode when an abnormality occurs (such as a network abnormality). This avoids dual-master and split-brain situations during network abnormalities or partitions, and improves data security and data consistency.

[0121] The communication bus 1140 mentioned in the above-mentioned electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 1140 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0122] The communication interface 1120 is used for communication between the above-mentioned electronic device and other devices.

[0123] The memory 1130 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0124] The processor 1110 mentioned above 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 gate or transistor logic devices, or discrete hardware components.

[0125] In another embodiment of this application, a computer-readable storage medium is also provided, on which a method program for preventing distributed database split-brain is stored. When the method program for preventing distributed database split-brain is executed by a processor, it implements the steps of the aforementioned method for preventing distributed database split-brain applied to a management node, or the aforementioned method for preventing distributed database split-brain applied to a business component node.

[0126] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0127] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for preventing split-brain in distributed databases, characterized in that, Applied to management nodes, the method includes: Send the first heartbeat message to the business component node; If a second heartbeat message is received from the proxy module corresponding to the business component node within a first preset time period, it is determined whether the business component node is abnormal based on the second heartbeat message. The proxy module of the business component node and the management node are co-located. The proxy module and the business component node do not communicate with each other through the network. The management node controls the primary and backup status of the business component node through the proxy module. The proxy module is used to monitor the status of the business component node and control the status of the business component node, including setting the current status of the business component node as the primary, setting the current status of the business component node as the backup, restarting the business component node, and controlling the business component node to go offline. If the business component node malfunctions, a switching instruction is sent to the proxy module corresponding to the business component node. The switching instruction is used to instruct the proxy module to control the business component node to switch to standby or go offline. The method further includes: If no second heartbeat information is received from the business component node within the first preset time period, it will switch to standby or go offline.

2. The method according to claim 1, characterized in that, The method further includes: If the business component node does not experience any abnormalities, return to the step of sending the first heartbeat information to the business component node and reset the first preset time period.

3. A method for preventing split-brain in distributed databases, characterized in that, An agent module corresponding to a business component node is provided. The agent modules for the business component node and the management node are co-located. The agent module and the business component node do not communicate via network. The management node controls the primary / standby status of the business component node through the agent module. The agent module monitors and controls the status of the business component node, including setting the current business component node's status to primary, setting the current business component node's status to standby, restarting the business component node, and taking the business component node offline. The method includes: Determine whether a first heartbeat message from the management node is received within the second preset time period; If a first heartbeat message is received from the management node within the second preset time period, determine whether a switching instruction has been received from the management node. If the switching instruction is received, the business component node to which it belongs will be switched to standby or taken offline; The method further includes: If no first heartbeat information is received from the management node within the second preset time period, the business component node to which it is located will be switched to standby or taken offline.

4. The method according to claim 3, characterized in that, The method further includes: If the switching instruction is not received, obtain its own status information; Send a second heartbeat message containing the status information to the management node.

5. A device for preventing split-brain in distributed databases, characterized in that, Applied to a management node, the device includes: The first sending module is used to send the first heartbeat information to the business component node; The first determining module is used to determine whether the business component node is abnormal if it receives a second heartbeat message from the proxy module corresponding to the business component node within a first preset time period. The proxy module of the business component node and the management node are co-located, and the proxy module and the business component node do not communicate through the network. The management node controls the primary / backup status of the business component node through the proxy module. The proxy module is used to monitor the status of the business component node and control the status of the business component node, including setting the current status of the business component node as the primary node, setting the current status of the business component node as the backup node, restarting the business component node, and controlling the business component node to go offline. If it does not receive a second heartbeat message from the business component node within the first preset time period, it switches itself to the backup node or goes offline. The second sending module is used to send a switching instruction to the proxy module corresponding to the service component node if the service component node malfunctions. The switching instruction is used to instruct the proxy module to control the service component node to switch to standby mode or go offline.

6. A device for preventing split-brain in distributed databases, characterized in that, An agent module corresponding to a business component node is provided. The agent modules for the business component node and the management node are co-located. The agent module and the business component node do not communicate via network. The management node controls the primary / standby status of the business component node through the agent module. The agent module monitors and controls the status of the business component node, including setting the current business component node's status to primary, setting the current business component node's status to standby, restarting the business component node, and controlling the business component node to go offline. The device includes: The second determining module is used to determine whether a first heartbeat message from the management node is received within a second preset time period. The third determining module is used to determine whether a switching instruction from the management node has been received if a first heartbeat message from the management node is received within the second preset time period; if no first heartbeat message from the management node is received within the second preset time period, the business component node to which it is located is switched to a standby machine or taken offline. The second switching module is used to switch its own business component node to standby or offline if it receives the switching instruction.

7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method for preventing split-brain in a distributed database as described in any one of claims 1 to 2 or the method for preventing split-brain in a distributed database as described in any one of claims 3 to 4.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a method program for preventing distributed database split-brain, which, when executed by a processor, implements the method for preventing distributed database split-brain as described in any one of claims 1 to 2, or the steps of the method for preventing distributed database split-brain as described in any one of claims 3 to 4.

Citation Information

Patent Citations

  • Management equipment of dual-computer hot standby system, management method and dual-computer hot standby system

    CN102916825A

  • Cloud Stack cloud platform

    CN109600264A