Main and standby node election method and system and first node equipment
By using two-way and one-way detection messages between node devices to determine the detection status based on parameter values, and directly performing main and standby elections in the system, the problem of requiring third-party arbitration nodes in the existing technology is solved, and efficient and reliable Main node election avoids split brain phenomenon.
Patent Information
- Application Number
- CN202411391019.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-10
AI Technical Summary
In a system composed of multiple node devices, the prior art requires the use of third-party arbitration nodes to elect the master node device, which leads to inconvenience in process and is prone to split brain phenomena, increasing system complexity and error risk.
Through the two-way detection messages and one-way detection messages between node devices, the detection status is determined based on the parameter values, and the main and alternate elections are performed directly in the system, avoiding the participation of third-party devices, simplifying the election process, and passing the dual state The detection avoids the occurrence of split brain phenomenon.
It realizes efficient election of master node equipment, simplifies the process, improves processing efficiency, and effectively avoids the occurrence of split brain phenomena, and improves the reliability and convenience of the system.
Smart Images

Figure CN119109768A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing, and in particular to a node master / slave election method, system and first node device. Background Art
[0002] In a system composed of multiple node devices, it is usually necessary to select a master node device from the multiple node devices, and the other node devices serve as slave node devices.
[0003] In the process of selecting the master node device, it is usually necessary to use a third-party arbitration node to complete the election of the master node device. Such a process requires the addition of a third-party device, which brings inconvenience to the election of the master node device. Summary of the invention
[0004] In view of this, the present application provides a node master / slave election method, system and first node device, and the specific scheme thereof is as follows:
[0005] A node master / slave election method, comprising:
[0006] The first node device determines a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device;
[0007] If the detection status is normal, determining the master node device and the slave node device in the first node device and the second node device according to the first parameter value;
[0008] If the detection state is abnormal, a master node device and a slave node device in the first node device and the second node device are determined based on a second parameter value in a unidirectional detection message between the first node device and the second node device.
[0009] Further, if the detection state is abnormal, determining the master node device and the slave node device in the first node device and the second node device based on the second parameter value in the unidirectional detection message between the first node device and the second node device includes:
[0010] If the first node device is a slave node device and the second node device is a master node device, if the detection state is abnormal, determining whether the second node device is abnormal based on a second parameter value in a unidirectional detection message between the first node device and the second node device;
[0011] If it is determined that the second node device is abnormal, the first node device is adjusted to be a master node device.
[0012] Further, the determining whether the second node device is abnormal based on a second parameter value in a unidirectional detection message between the first node device and the second node device includes:
[0013] Reading a second parameter value in a one-way detection message from a storage structure at intervals of a specific duration, wherein the one-way detection message stored in the storage structure is sent to and stored by the second node device at intervals of a specific duration;
[0014] Determine whether the second node device is abnormal based on the second parameter value.
[0015] Further, determining whether the second node device is abnormal based on the second parameter value includes:
[0016] Comparing the second parameter value in the one-way detection message read from the storage structure at the current moment with the second parameter value in the one-way detection message read from the storage structure before the specific time period to obtain a comparison result;
[0017] If the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read before the specific time period meet a specific rule, it is determined that the second node device is normal;
[0018] If the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read before the specific time do not meet the specific rule, it is determined that the second node device is abnormal.
[0019] Further, determining whether the second node device is abnormal based on the second parameter value includes:
[0020] If no one-way detection message is read from the storage structure within a specific time period, it is determined that the second node device is abnormal.
[0021] Furthermore, it also includes:
[0022] Detecting the interface status of the first node device;
[0023] If the interface status of the first node device is abnormal, if the first node device is a master node device, the first node device is adjusted to a slave node device.
[0024] Further, if the detection state is normal, determining a master node device and a slave node device in the first node device and the second node device according to the first parameter value includes:
[0025] In the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message output by the first node device in the bidirectional detection message represents the master node state, and the target state bit determined by the first parameter value in the second message output by the second node device in the bidirectional detection message represents the non-master node state, it is determined that the first node device is the master node device and the second node device is the slave node device;
[0026] In the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message represents the master node state, and the target state bit determined by the first parameter value in the second message represents the master node state, based on the address information of the first node device and the address information of the second node device, the master node device and the slave node device are determined from the first node device and the second node device;
[0027] When the detection status is normal, if it is determined that the target status bit determined by the first parameter value in the first message represents a non-master node status, and the target status bit determined by the first parameter value in the second message represents a non-master node status, based on the address information of the first node device and the address information of the second node device, the master node device and the slave node device are determined from the first node device and the second node device.
[0028] A node master / slave election system, comprising:
[0029] Second node device;
[0030] A first node device can determine a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device; if the detection state is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection state is abnormal, the master node device and the slave node device in the first node device and the second node device are determined based on a second parameter value in a unidirectional detection message between the first node device and the second node device.
[0031] A first node device includes:
[0032] A processor, configured to determine a detection state based on a first parameter value in a bidirectional detection message between a first node device and a second node device; if the detection state is normal, determine a master node device and a slave node device in the first node device and the second node device by using the first parameter value; if the detection state is abnormal, determine a master node device and a slave node device in the first node device and the second node device based on a second parameter value in a unidirectional detection message between the first node device and the second node device;
[0033] The memory is used to store the program for the processor to execute the above processing flow.
[0034] A readable storage medium for storing at least one set of instructions;
[0035] The instruction set is used to be called and to execute at least the node master / standby election method as described in any one of the above items. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 A flowchart of a node master / slave election method disclosed in an embodiment of the present application;
[0038] Figure 2 A flowchart of a node master / slave election method disclosed in an embodiment of the present application;
[0039] Figure 3 A schematic diagram of sending a bidirectional detection message and a unidirectional detection message between a master node device and a slave node device disclosed in an embodiment of the present application;
[0040] Figure 4 A flowchart of a node master / slave election method disclosed in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of the composition of a first parameter value disclosed in an embodiment of the present application;
[0042] Figure 6 A schematic diagram of the active / standby state represented by different combinations of values of different bits disclosed in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of determining a primary and standby node based on a target status bit of a local end and a target status bit of a remote end disclosed in an embodiment of the present application;
[0044] Figure 8 A schematic diagram of the structure of a node master-slave election system disclosed in an embodiment of the present application
[0045] Fig. 9 A schematic diagram of the structure of a node master / slave election device disclosed in an embodiment of the present application;
[0046] Fig.10 A schematic diagram of the structure of a first node device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] This application discloses a node master / slave election method, the flow chart of which is as follows: Figure 1 As shown, including:
[0049] Step S11: The first node device determines a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device;
[0050] Step S12: If the detection state is normal, determining a master node device and a slave node device in the first node device and the second node device by using the first parameter value;
[0051] Step S13: If the detection state is abnormal, determine the master node device and the slave node device in the first node device and the second node device based on the second parameter value in the unidirectional detection message between the first node device and the second node device.
[0052] In a system composed of multiple node devices, it is usually necessary to select a master node device from the multiple node devices, and the other node devices serve as slave node devices.
[0053] In some scenarios, it may cause a split-brain problem. The split-brain phenomenon refers to the situation in which a high-availability system is divided into two or more independent subsystems due to network partitions or other failures. Each subsystem may independently elect its own master node. For example, a slave node device sends a message to a master node device, requiring a response within 30 milliseconds. If no response is received four times, the slave node device determines that the master node device has a fault. At this time, the slave node device sets itself as the master node device. However, if the original master node device does not respond to the message because a thread is blocked, resulting in an untimely response, when the blocked thread of the original master node device is executed, there will be two master node devices. This is the split-brain phenomenon.
[0054] In the existing solution, in order to avoid this problem, it is usually necessary to use a third-party arbitration node to complete the election of the master node device. This process requires the addition of a third-party device, which brings inconvenience to the election of the master node device.
[0055] Based on this, in this scheme, the node devices included in the system perform the master-slave election themselves. The first node device in the system determines the detection status based on the first parameter value in the two-way detection message between the first node device and the second node device. If the detection status is normal, the master-slave election is directly implemented based on the first parameter value. If the detection status is abnormal, the master-slave election is implemented based on the second parameter value in the unidirectional detection message. In this process, the node devices included in the system are directly used to implement the election, and there is no need to add third-party equipment, which simplifies the election process and improves convenience. In addition, the node devices included in the system complete the election based on the two-way detection message or the unidirectional detection message, which effectively avoids the occurrence of brain split.
[0056] The first node device and the second node device are both node devices included in the system. The system may only include the first node device and the second node device. When the first node device is a master node device, the second node device is a slave node device. If the first node device is a slave node device, then the second node device is the master node device.
[0057] A bidirectional detection message is a message that can be sent bidirectionally and implements status detection based on bidirectional sending, that is, the first node device can send a message to the second node device, and the second node device can also send a message to the first node device, and perform status detection based on the message sent by the first node device to the second node device and the message sent by the second node device to the first node device.
[0058] The bidirectional detection message may be a Bidirectional Forwarding Detection (BFD) message. The BFD protocol is a network protocol used to detect faults between two forwarding points. The BFD protocol establishes a BFD session between two devices in the same system and periodically sends BFD detection messages. For example, a cycle of 1000 ms is used. If no BFD message is received from the other party within a specified time (for example, 3000 ms), it can be determined that the link between the two devices is faulty.
[0059] The bidirectional detection message includes a first parameter value, and the detection status can be determined by the first parameter value in the bidirectional detection message, and the detection status can determine whether the first node device and the second node device send the bidirectional detection message normally; in addition, the first parameter value can also determine the active and standby status of the node device sending the message.
[0060] If the bidirectional detection message is a BFD message, the BFD message needs to be encapsulated and transmitted using an IP header during transmission. Specifically, the BFD message is encapsulated using the UDP protocol, and the corresponding source port and destination port are specified in the IP to ensure that the BFD message can be correctly received and processed. The IP header contains information such as the source IP address, destination IP address, protocol type (such as UDP), source port and destination port. At the same time, the IP header also contains some other important fields, such as version number, header length, service type, etc.
[0061] In this embodiment, what is needed is the first parameter value in the bidirectional detection message, which can specifically be: a specific field in the IP header of the BFD message, such as: the TTL (Time To Live) field, which is part of the IP data packet header and is an 8-bit field used to limit the survival time of the data packet in the network to prevent the data packet from being endlessly forwarded in a loop in the network.
[0062] The detection state can characterize whether the bidirectional detection message between the first node device and the second node device is sent and received normally, such as: the bidirectional detection message includes: a first message sent by the first node device to the second node device, and a first message sent by the second node device to the first node device. When the first node device sends the first message to the second node device and receives a response from the second node device within a target time after the moment of sending the first message, and the second node device sends the second message to the first node device, and receives a response from the first node device within the target time after the moment of sending the second message, it can be determined that the detection state is normal. At this time, the detection state characterizes that the first node device and the second node device are running normally, and at this time, the master-slave election can be performed;
[0063] When a first node device sends a first message to a second node device and does not receive a response from the second node device within a target time period after sending the first message, then at this time, regardless of whether the second node device receives a response from the first node device after sending the second message to the first node device, it can be determined that the detection status is abnormal, and the detection status indicates that the operation of the first node device or the second node device is abnormal.
[0064] When the detection state is normal, the master-slave election can be performed directly based on the first parameter value, that is, the master node device and the slave node device are selected from the first node device and the second node device.
[0065] When the detection state is normal, based on the first parameter value, it is possible to directly determine whether the device sending the first parameter value is a master node device or a slave node device. For example, the first node device sends a first message to the second node device, and receives a response from the second node device within a target time period after the moment of sending the first message. The second node device sends a second message to the first node device, and receives a response from the first node device within a target time period after the moment of sending the second message. For the first node device, it receives the second message, and the second message includes the first parameter value. The first parameter value in the second message is sent by the second node device. Then, based on the first parameter value received, the first node device can determine whether the second node device is a master node device or a slave node device. For the second node device, it receives the first message, and the first message includes the first parameter value. The first parameter value in the first message is sent by the first node device. Then, based on the first parameter value received, the second node device can determine whether the first node device is a master node device or a slave node device.
[0066] When determining the master node device and the slave node device in the first node device and the second node device based on the first parameter value, what is determined is the master-slave status of the opposite device, that is, the first node device determines the master-slave status of the second node device, and the second node device determines the master-slave status of the first node device. If the first node device determines that the second node device is the master node device, the first node device determines that the first node device is a slave node device; if the second node device determines that the first node device is a slave node device, the second node device determines that the second node device is the master node device. Determine the master-slave status of the opposite end, and determine the master-slave status of this end based on the master-slave status of the opposite end. This process does not require the participation of third-party devices, simplifies the election process, and improves processing efficiency.
[0067] In addition, the detection state is determined by bidirectional message detection, and when the detection state is normal, the master / slave election is performed based on the first parameter value in the bidirectional detection message. The detection time granularity is small, and the processing efficiency is improved.
[0068] When the detection status is abnormal, since the detection status abnormality is caused by at least two situations, one is the failure of the node device, and the other is the thread blocking, and the thread blocking does not belong to the situation of node device failure, it is not necessary to update the master and standby node status at this time. Therefore, it is necessary to use a one-way detection message for detection to avoid the situation of thread blocking, that is, further perform master-slave election through the second parameter value in the one-way detection message between the first node device and the second node device to determine whether the master and standby node status needs to be updated.
[0069] In the node master-slave election method disclosed in the present embodiment, the master-slave node election can be performed not only through two-way detection messages, but also through unidirectional detection messages, and the master-slave node election is preferentially performed through two-way detection messages, and the master-slave node election is performed only when the master-slave node election cannot be performed through two-way detection messages. Since in the detection method of the unidirectional detection message, the unidirectional detection message is not directly sent from one node device to another node device, but the unidirectional detection message is sent from one node device to a storage structure, and the other node device then reads the unidirectional detection message from the storage structure, this effectively avoids the problem that the unidirectional detection message cannot be transmitted when the connection between the two node devices is disconnected, and can solve the problem caused by the direct transmission of messages between the two node devices when the master-slave election is performed through the two-way detection message method.
[0070] The unidirectional detection message is a message sent unidirectionally between the first node device and the second node device. Only the first node device sends the unidirectional detection message, or only the second node device sends the unidirectional detection message.
[0071] The one-way detection message contains a second parameter value, and by analyzing the second parameter value, it is possible to determine whether the node device that sends the one-way detection message is abnormal, thereby determining whether the master and standby nodes need to be updated. For example: the first node device sends a one-way detection message so that the second node device can receive the one-way detection message, and the second node device determines whether the first node device is abnormal based on the second parameter value in the received one-way detection message, thereby determining whether the master and standby nodes need to be updated; the second node device sends a one-way detection message so that the first node device can receive the one-way detection message, and the first node device determines whether the second node device is abnormal based on the second parameter value in the received one-way detection message, thereby determining whether the master and standby nodes need to be updated.
[0072] It should be noted that the update of the primary and backup nodes can be achieved by using one-way detection messages, that is, only after the primary and backup nodes have been determined, can one-way detection messages be used for detection to determine whether the primary and backup nodes need to be updated; while two-way detection messages can be applied when the primary and backup nodes have not yet been determined, and the primary and backup nodes can be determined through two-way detection messages. In addition, after the primary and backup nodes have been determined, two-way detection messages can still be used to determine whether the detection status is abnormal, and when it is determined that the detection status is abnormal, the one-way detection message can be used to determine the primary and backup status.
[0073] In addition, when the detection state is determined by using a two-way detection message, the first node device and the second node device included in the system can both determine the detection state and perform the master-slave node election, that is, the first node device can determine the two-way detection message, and determine the detection state based on the first parameter value in the two-way detection message. When the detection state is normal, the first node device can perform the master-slave node election based on the first parameter value; the second node device can also determine the two-way detection message, and determine the detection state based on the first parameter value in the two-way detection message. When the detection state is abnormal, the second node device can perform the master-slave node election based on the first parameter value. Alternatively, the first node device and the second node device can simultaneously perform the master-slave node election. If the first node device determines that the first node device is the master node device when performing the master-slave node election, then the second node device determines that the second node device is the slave node device when performing the master-slave node election. Even if the first node device and the second node device simultaneously perform the master-slave node election, there will be no problem of conflict in the master-slave node election results.
[0074] The node master-slave election method disclosed in this embodiment is that the first node device determines the detection state based on the first parameter value in the bidirectional detection message between the first node device and the second node device; if the detection state is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection state is abnormal, the master node device and the slave node device in the first node device and the second node device are determined based on the second parameter value in the unidirectional detection message between the first node device and the second node device. This scheme transmits a bidirectional detection message between the first node device and the second node device, and can determine the detection state based on the first parameter value in the bidirectional detection message, and when the detection state is normal, it can directly complete the election of the master and standby nodes based on the first parameter value, and when the detection state is abnormal, it completes the election of the master and standby nodes based on the second parameter value in the unidirectional detection message. In the process of the master and standby node election, the election can be completed through the bidirectional detection message or the unidirectional detection message, without the participation of a third-party device, simplifying the election process and improving processing efficiency.
[0075] This embodiment discloses a method for selecting a primary node and a backup node, and its flow chart is as follows: Figure 2 As shown, including:
[0076] Step S21: The first node device determines a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device;
[0077] Step S22: If the detection state is normal, determine the master node device and the slave node device in the first node device and the second node device according to the first parameter value;
[0078] Step S23: if the detection state is abnormal, when the first node device is a slave node device and the second node device is a master node device, determine whether the second node device is abnormal based on a second parameter value in a unidirectional detection message between the first node device and the second node device;
[0079] Step S24: If it is determined that the second node device is abnormal, adjust the first node device to be a master node device.
[0080] If the system includes a first node device and a second node device and is currently in an initial state and it has not yet been determined which node device is the master node device and which node device is the slave node device, then bidirectional detection messages can be used to perform master and backup node elections.
[0081] That is, the first node device sends a first message to the second node device, and receives a first response from the second node device within the target time. The second node device sends a second message to the first node device, and receives a second response from the first node device within the target time. At this time, it can be determined that the detection status is normal. In the current scenario, the first node device determines whether the second node device is the master node device or the slave node device based on the received first response, and the second node device determines whether the first node device is the master node device or the slave node device based on the received second response, thereby realizing the master-slave node election in the initial state.
[0082] When a certain node device in the system is determined to be a master node device and another node device is determined to be a slave node device, the detection of the bidirectional detection message continues, and the detection of the unidirectional detection message is performed at the same time.
[0083] Even if the active and standby node devices are determined, the process of two-way message detection will not be affected. Therefore, the detection of two-way detection messages performed after the active and standby node devices are determined is the same as the detection process of two-way detection messages performed in the above initial state.
[0084] After determining the master and backup node devices in the system, perform a two-way detection message test. If it is determined that the detection status is normal, continue to use the first parameter value to re-execute the master and backup node election to determine whether the current master and backup node devices need to be adjusted. If necessary, update the master and backup node devices. If not, maintain the current master and backup node devices.
[0085] If it is determined that the detection status is abnormal, it is necessary to determine which one is the node device that sends the unidirectional detection message, that is, the master node device, and which one is the node device that receives the unidirectional detection message, that is, the slave node device, and the slave node device performs the detection of the unidirectional detection message.
[0086] For example: the first node device is a slave node device, and the second node device is a master node device. When the detection status is abnormal, a one-way detection message is used to elect the master and standby nodes to determine whether the master and standby node status needs to be updated, that is, a one-way detection message is used to determine whether the second node device can continue to serve as the master node device, that is, whether the second node device is normal. If normal, it can continue to serve as the master node device. If abnormal, the master and standby node devices need to be updated, that is, the second node device no longer serves as the master node device, but the first node device serves as the master node device.
[0087] The one-way detection message may specifically be: DB (Database) one-way asynchronous heartbeat. DB one-way asynchronous heartbeat is a mechanism used in a database to detect and maintain data synchronization status. It confirms the connection status and data consistency between the master and slave databases by periodically sending heartbeat signals.
[0088] In this embodiment, a storage structure (such as a database) is set up, and the master node device periodically sends a unidirectional detection message to the storage structure and stores it in the storage structure. The slave node device periodically reads the unidirectional detection message from the storage structure, and the slave node device determines whether the master node device is abnormal based on the second parameter value in the unidirectional detection message it reads.
[0089] Specifically, the second parameter value in the unidirectional detection message is read from the storage structure at specific intervals. The unidirectional detection message stored in the storage structure is sent to and stored by the second node device at specific intervals. Whether the second node device is abnormal is determined based on the second parameter value.
[0090] like Figure 3 As shown, it is a schematic diagram of sending bidirectional detection messages and unidirectional detection messages between a master node device and a slave node device, including: a master node device, a slave node device, a storage structure, the master node device and the slave node device send bidirectional detection messages to each other, for unidirectional detection messages, the master node device outputs a unidirectional detection message once every specific time interval, the unidirectional detection message output by the master node device is stored in the storage structure, and the slave node device reads the unidirectional detection message from the storage structure once every specific time interval. Among them, the time when the master node device sends the unidirectional detection message can be different from the time when the slave node device reads the unidirectional detection message, such as: the time when the master node device sends the unidirectional detection message is earlier than the time when the slave node device reads the unidirectional detection message, so that the unidirectional detection message read by the slave node device is sent by the master node device at a time close to the current time, avoiding a long delay.
[0091] Specifically, after the one-way detection message is read from the node device, determining whether the second node device is abnormal based on the second parameter value in the one-way detection message may be:
[0092] Taking the first node device as a slave node device as an example, compare the second parameter value in the one-way detection message read from the storage structure at the current moment with the second parameter value in the one-way detection message read from the storage structure a specific time ago to obtain a comparison result; if the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read a specific time ago meet specific rules, determine that the second node device is normal; if the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read a specific time ago do not meet specific rules, determine that the second node device is abnormal.
[0093] If the first node device is a slave node device, and the second node device is a master node device, the master node device outputs a one-way detection message at a specific time interval, and the output one-way detection message is stored in the storage structure. Among them, the one-way detection message output by the master node device at a specific time interval includes a second parameter value, and the second parameter value in the one-way detection message sent by the same master node device has a specific rule, so that the slave node device can determine whether the master node device is abnormal based on the specific rule of the second parameter value. Among them, the second parameter value can be a heartbeat value, or other values, which are not specifically limited here.
[0094] For example, the second parameter value included in the one-way detection message output by the master node device for the first time is 1, the second parameter value included in the one-way detection message output by the master node device for the second time is 2, the second parameter value included in the one-way detection message output by the master node device for the third time is 3, and so on, that is, the second parameter value in the message sent by the master node device each time differs from the second parameter value in the message sent last time by 1, and increases by 1;
[0095] Alternatively, it may also be that: the second parameter value included in the one-way detection message output by the master node device for the first time is 1, the second parameter value included in the one-way detection message output by the master node device for the second time is 3, the second parameter value included in the one-way detection message output by the master node device for the third time is 5, and so on. That is, the second parameter value in the message sent by the master node device each time differs from the second parameter value in the message sent last time by 2, and increases by 2.
[0096] Of course, the specific rules may also be other rules, which are not specifically limited here.
[0097] The slave node device reads a one-way detection message from the storage structure once at a specific time interval, and the second parameter value in the one-way detection message currently read can be obtained. In addition, it is also necessary to obtain the second parameter value in the one-way detection message read at a specific time distance from the current moment and earlier than the current moment, that is, the second parameter value in the one-way detection message read last time, and compare these two second parameter values to determine whether they comply with specific rules. If they comply with the specific rules, it can be determined that the master node device is normal. If they do not comply with the specific rules, it can be determined that the master node device is abnormal.
[0098] For example, the specific rule is: each time it increases by 1, the first node device acts as a slave node device, reads from the storage structure the unidirectional detection message sent by the second node device and stored in the storage structure, if the second parameter value in the currently read unidirectional detection message is 7, the second parameter value in the last read unidirectional detection message is 7, and the second parameter value in the currently read unidirectional detection message and the second parameter value in the last read unidirectional detection message do not meet the specific rule, then it can be determined that the second node device is abnormal;
[0099] For example: the specific rule is: each time the number increases by 1, the first node device acts as a slave node device, reads from the storage structure the unidirectional detection message sent by the second node device and stored in the storage structure; if the second parameter value in the currently read unidirectional detection message is 7, and the second parameter value in the last read unidirectional detection message is 8, and the second parameter value in the currently read unidirectional detection message and the second parameter value in the last read unidirectional detection message meet the specific rule, then it can be determined that the second node device is normal.
[0100] Furthermore, the method may also include: if no unidirectional detection message is read from the storage structure when a specific time period is reached, determining that the second node device is abnormal.
[0101] For example, the specific rule is: each time the value increases by 1, the first node device acts as a slave node device, reads from the storage structure the unidirectional detection message sent by the second node device and stored in the storage structure. If the unidirectional detection message is not read at the current moment, there will be no second parameter value corresponding to the current moment. At this time, there is no need to determine the second parameter value of the unidirectional detection message read last time, and the second node device can be directly determined to be abnormal.
[0102] If the first node device is a slave node device and the second node device is a master node device, when the first node device determines that the second node device is normal based on the second parameter value in the read unidirectional detection message, it can be determined that there is no need to adjust the master and standby node devices, that is, the second node device still serves as the master node device, the first node device still serves as the slave node device, and the first node device controls itself not to become the master;
[0103] When the first node device determines that the second node device is abnormal based on the second parameter value in the read unidirectional detection message, it can be determined that the master-slave node devices need to be adjusted, that is, the second node device is abnormal and can no longer serve as the master node device. At this time, the first node device controls itself and will not be upgraded to the master node device. Since the second node device has an abnormality, it can no longer output signals to the outside. Therefore, there will be no problem of two master nodes, that is, there will be no brain split.
[0104] Correspondingly, if the second node device is a slave node device and the first node device is a master node device, the second node device as a slave node device will read the unidirectional detection message sent by the first node device and stored in the storage structure from the storage structure at specific time intervals, and compare the second parameter value in the currently obtained unidirectional detection message with the second parameter value in the last obtained unidirectional detection message to determine whether specific rules are met, so as to determine whether the first node device can continue to serve as the master node device, that is, to determine whether the second node device needs to be upgraded to the master node device. Its specific implementation is the same as when the first node device is a slave node device, and will not be repeated here.
[0105] In the node master-slave election method disclosed in this embodiment, dual status detection of the master and backup nodes is performed through two-way detection messages and unidirectional detection messages to avoid misjudgment. At the same time, the two-way detection messages and the unidirectional detection messages are processed in parallel and will not affect the efficiency of the master-slave election.
[0106] The node master-slave election method disclosed in this embodiment is that the first node device determines the detection state based on the first parameter value in the bidirectional detection message between the first node device and the second node device; if the detection state is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection state is abnormal, when the first node device is a slave node device and the second node device is a master node device, whether the second node device is abnormal is determined based on the second parameter value in the unidirectional detection message between the first node device and the second node device; if it is determined that the second node device is abnormal, the first node device is adjusted to be the master node device. This scheme first uses the first parameter value in the bidirectional detection message to determine the detection state. If the detection state is normal, the first parameter value is used to elect the master and standby nodes. If the detection state is abnormal, the slave node device determines whether the master node device is abnormal based on the second parameter value in the obtained unidirectional detection message, so as to determine whether the master and standby nodes need to be adjusted. On the basis of the bidirectional detection message, a unidirectional detection message is added to improve the detection accuracy and avoid the occurrence of brain split.
[0107] Furthermore, the node master / slave election method disclosed in this embodiment may also include:
[0108] Detect the interface status of the first node device; if the interface status of the first node device is abnormal, if the first node device is a master node device, adjust the first node device to a slave node device.
[0109] The step of detecting the interface status of the node device will only be performed when the current system including the first node device and the second node device meets the specific scenario. The specific scenario may be: core network scenario, or other scenarios. As long as the service executed by the current system is related to the interface, it can be determined that the specific scenario is met. No specific limitation is made here.
[0110] When a specific scenario is met, both the master node device and the slave node device will detect their own interface status to determine whether the master / slave status needs to be adjusted.
[0111] If the first node device is a master node device, the first node device checks its own interface status to determine whether there is an abnormality in any interface of the first node device. If there is no abnormality in any interface of the first node device, that is, the status of all interfaces is normal, the first node device still serves as the master node device; if the status of an interface in the first node device is abnormal, it is determined that the interface status of the first node device is abnormal. At this time, the service cannot be performed normally, and the first node device is downgraded to a slave node device, and it is no longer a master node device. After the first node device is downgraded to a slave node device, the first node device and the second node device continue to send bidirectional detection messages. If the first message in the bidirectional detection message sent by the first node device to the second node device contains a flag bit indicating that the first node device is a slave node device, the second node device can determine that the first node device is a slave node device, and the second node device is upgraded to a master node device based on this.
[0112] If the first node device is a slave node device, the first node device checks its own interface status to determine whether there is an abnormality in any interface in the first node device; if there is no abnormality in any interface in the first node device, that is, the status of all interfaces are normal, the interface status can continue to be checked, and the unidirectional detection message can also be detected. When it is determined that the unidirectional detection message is also normal, it is determined that the first node device is still not a slave node device, and the interface status and the unidirectional detection message are continued to be checked; if there is an abnormality in the interface status in the first node device, the first node device sets a prohibition flag, which is used to prohibit the first node device from being promoted to a master node device.
[0113] Correspondingly, the detection of the interface status of the second node device itself is the same as the detection of the interface status of the first node device itself, which will not be described in detail here.
[0114] In the node master / slave election method disclosed in this embodiment, detection of the interface status of the node device is added, which ensures the comprehensiveness and accuracy of the detection and improves the accuracy of the master / slave election.
[0115] This embodiment discloses a method for selecting a primary node and a backup node, and its flow chart is as follows: Figure 4 As shown, including:
[0116] Step S41: The first node device determines a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device;
[0117] Step S42: If the detection state is normal, determine that the target state bit determined by the first parameter value in the first message output by the first node device in the two-way detection message represents the master node state, and the target state bit determined by the first parameter value in the second message output by the second node device in the two-way detection message represents the non-master node state, and determine that the first node device is the master node device and the second node device is the slave node device;
[0118] Step S43: if the detection state is normal, determine that the target state bit determined by the first parameter value in the first message represents the master node state, and the target state bit determined by the first parameter value in the second message represents the master node state, and determine the master node device and the slave node device from the first node device and the second node device based on the address information of the first node device and the address information of the second node device;
[0119] Step S44: If the detection status is normal, determine that the target status bit determined by the first parameter value in the first message represents the non-master node status, and the target status bit determined by the first parameter value in the second message represents the non-master node status, and determine the master node device and the slave node device from the first node device and the second node device based on the address information of the first node device and the address information of the second node device.
[0120] A bidirectional detection message is transmitted between the first node device and the second node device. The bidirectional detection message may include: a first message and a second message. The first node device transmits the first message to the second node device, and the second node device transmits the second message to the first node device.
[0121] If the first node device transmits a first message to the second node device and obtains a response from the second node device within a target time period, and the second node device transmits a second message to the first node device and obtains a response from the first node device within the target time period, it can be determined that the detection status is normal. At this time, the master-slave election can be performed based on the first parameter value in the first message and the second parameter value in the second message.
[0122] If the bidirectional detection message is a BFD message, the first parameter value is the TTL field of the IP header of the BFD message, and the composition diagram of the first parameter value can be as follows: Figure 5 As shown, bit0-bit5 represents the TTL value, bit6-bit7 represents the master / slave status role, and bit6-bit7 is the target status bit. The first parameter value in the first message represents the master / slave status of the first node device, and the first parameter value in the second message represents the master / slave status of the second node device.
[0123] Bit 6-bit 7 in the TTL field indicates the master / slave status role, which can be as follows: Figure 6 As shown, it is a schematic diagram of the master-slave status represented by different combinations of values of different bits. As shown in the figure, if the value of bit6 is 0 and the value of bit7 is 0, the node device sending the message is currently in the initial state init; if the value of bit6 is 0 and the value of bit7 is 1, the node device sending the message is currently the slave node device slave; if the value of bit6 is 1 and the value of bit7 is 1, the node device sending the message is currently the master node device master.
[0124] The first node device transmits a first message to the second node device and obtains a response from the second node device within a target time period. The second node device transmits a second message to the first node device and obtains a response from the first node device within a target time period. It can be determined that the detection status is normal. At this time, the first node device obtains the second message sent by the second node device, and the first node device also clearly knows the first message it sent to the second node device. The first node device can determine the target status bit corresponding to the first parameter value of the second node device based on the second message. At the same time, the first node device can determine the target status bit corresponding to the first parameter value of the first node device based on the first message. The first node device can perform master-slave election based on these two target status bits.
[0125] like Figure 7 As shown in FIG. 1 , it is a schematic diagram of determining the primary and backup nodes based on the target status bit of the local end and the target status bit of the opposite end, where L is the local end Local, R is the opposite end Romote, L (b00) indicates that the target status bit of the local end is b00, L (b11) indicates that the target status bit of the local end is b11, L (b10) indicates that the target status bit of the local end is b10, R (b00) indicates that the target status bit of the opposite end is b00, R (b11) indicates that the target status bit of the opposite end is b11, and R (b10) indicates that the target status bit of the opposite end is b10. Figure 6 As shown, L (b11) indicates that the local end is in the master node state, and R (b00) and R (b10) indicate that the other end is in the non-master node state.
[0126] If Figure 7As shown in , it can be determined that if only the target status bit of the local end is b11, it can be determined that the local end is the master node device and the other end is the slave node device, such as Figure 7 When the target status bit of the local end is L (b11) and the target status bit of the other end is R (b00), and when the target status bit of the local end is L (b11) and the target status bit of the other end is R (b10), the local end is the master node device and the other end is the slave node device; if only the target status bit of the other end is b11, it can be determined that the other end is the master node device and the local end is the slave node device, that is, Figure 7 When the target status bit of the local end is L (b00) and the target status bit of the other end is R (b11), and when the target status bit of the local end is L (b10) and the target status bit of the other end is R (b11), the local end is the master node device and the other end is the slave node device;
[0127] For other situations, such as: the target status bit of this end is L (b00) or L (b10), and the target status bit of the other end is R (b00) or R (b10); or, the target status bit of this end is L (b11), and the target status bit of the other end is R (b11), it is necessary to compare (compare IP) based on the address information of the first node device and the address information of the second node device, and then determine the master node device and the slave node device.
[0128] Among them, the master node device and the slave node device are determined based on the address information of the first node device and the address information of the second node device. The address information of the first node device and the address information of the second node device are compared, and the device with smaller address information is determined as the master node device. For example, if the IP of the first node device is smaller than the IP of the second node device, the first node device can be determined as the master node device.
[0129] In the node master-slave election method disclosed in this embodiment, the detection status is determined based on the first parameter value in the two-way detection message, and when the detection status is normal, the master node device and the slave node device are determined based on the target status bit in the first parameter value. If the master node device and the slave node device cannot be determined based on the target status bit in the first parameter value, the address information of the first node device and the address information of the second node device are added, and the address information of the two node devices is used to further determine the master node device and the slave node device, thereby improving the accuracy of the master-slave election.
[0130] This embodiment discloses a node master / slave election system, and its structural diagram is as follows: Figure 8 As shown, including:
[0131] A first node device 81 and a second node device 82.
[0132] Among them, the first node device 81 can determine the detection status based on the first parameter value in the two-way detection message between the first node device and the second node device; if the detection status is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection status is abnormal, the master node device and the slave node device in the first node device and the second node device are determined based on the second parameter value in the unidirectional detection message between the first node device and the second node device.
[0133] The node master and standby election system disclosed in this embodiment is implemented based on the node master and standby election method disclosed in the above embodiments, which will not be described in detail here.
[0134] The node master-slave election system disclosed in this embodiment, the first node device determines the detection state based on the first parameter value in the bidirectional detection message between the first node device and the second node device; if the detection state is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection state is abnormal, the master node device and the slave node device in the first node device and the second node device are determined based on the second parameter value in the unidirectional detection message between the first node device and the second node device. This scheme transmits a bidirectional detection message between the first node device and the second node device, and can determine the detection state based on the first parameter value in the bidirectional detection message, and when the detection state is normal, it can directly complete the election of the master and standby nodes based on the first parameter value, and when the detection state is abnormal, it completes the election of the master and standby nodes based on the second parameter value in the unidirectional detection message. In the process of the master and standby node election, the election can be completed through the bidirectional detection message or the unidirectional detection message, without the participation of a third-party device, simplifying the election process and improving processing efficiency.
[0135] This embodiment discloses a node master / slave election device, which is applied to a first node device. Fig. 9 As shown, including:
[0136] A first determining unit 91 , a second determining unit 92 and a third determining unit 93 .
[0137] A first determining unit 91, configured to determine a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device;
[0138] If the detection state is normal, the second determination unit 92 is used to determine the master node device and the slave node device in the first node device and the second node device according to the first parameter value;
[0139] If the detection state is abnormal, the third determination unit 93 is used to determine the master node device and the slave node device in the first node device and the second node device based on the second parameter value in the unidirectional detection message between the first node device and the second node device.
[0140] Further, the third determining unit is used for:
[0141] If the first node device is a slave node device and the second node device is a master node device, if the detection status is abnormal, determine whether the second node device is abnormal based on the second parameter value in the unidirectional detection message between the first node device and the second node device; if it is determined that the second node device is abnormal, adjust the first node device to be the master node device.
[0142] Further, the third determining unit is used for:
[0143] The second parameter value in the one-way detection message is read from the storage structure at specific intervals. The one-way detection message stored in the storage structure is sent to the storage structure and stored by the second node device at specific intervals. Whether the second node device is abnormal is determined based on the second parameter value.
[0144] Further, the third determining unit is used for:
[0145] Compare the second parameter value in the one-way detection message read from the storage structure at the current moment with the second parameter value in the one-way detection message read from the storage structure a specific time period ago to obtain a comparison result; if the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read a specific time period ago satisfy a specific rule, determine that the second node device is normal; if the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read a specific time period ago do not satisfy the specific rule, determine that the second node device is abnormal.
[0146] Further, the third determining unit is used for:
[0147] If no one-way detection message is read from the storage structure when the specific time period is reached, it is determined that the second node device is abnormal.
[0148] Furthermore, the node master / slave election device disclosed in this embodiment may further include:
[0149] The detection unit is used to detect the interface status of the first node device; if the interface status of the first node device is abnormal, if the first node device is a master node device, the first node device is adjusted to a slave node device.
[0150] Further, the second determining unit is used for:
[0151] In the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message output by the first node device in the bidirectional detection message represents the master node state, and the target state bit determined by the first parameter value in the second message output by the second node device in the bidirectional detection message represents the non-master node state, the first node device is determined to be the master node device, and the second node device is determined to be the slave node device; in the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message represents the master node state, and the target state bit determined by the first parameter value in the second message represents the master node state, based on the address information of the first node device and the address information of the second node device, the master node device and the slave node device are determined from the first node device and the second node device; in the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message represents the non-master node state, and the target state bit determined by the first parameter value in the second message represents the non-master node state, based on the address information of the first node device and the address information of the second node device, the master node device and the slave node device are determined from the first node device and the second node device.
[0152] The node master and standby election device disclosed in this embodiment is implemented based on the node master and standby election method disclosed in the above embodiments, which will not be described in detail here.
[0153] The node master-slave election device disclosed in this embodiment, the first node device determines the detection state based on the first parameter value in the bidirectional detection message between the first node device and the second node device; if the detection state is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection state is abnormal, the master node device and the slave node device in the first node device and the second node device are determined based on the second parameter value in the unidirectional detection message between the first node device and the second node device. This scheme transmits a bidirectional detection message between the first node device and the second node device, and can determine the detection state based on the first parameter value in the bidirectional detection message, and when the detection state is normal, it can directly complete the election of the master and standby nodes based on the first parameter value, and when the detection state is abnormal, it completes the election of the master and standby nodes based on the second parameter value in the unidirectional detection message. In the process of the master and standby node election, the election can be completed through the bidirectional detection message or the unidirectional detection message, without the participation of a third-party device, simplifying the election process and improving processing efficiency.
[0154] This embodiment discloses a first node device, and its structural diagram is as follows: Fig.10 As shown, including:
[0155] Processor 101 and memory 102 .
[0156] The processor 101 is used to determine the detection state based on the first parameter value in the bidirectional detection message between the first node device and the second node device; if the detection state is normal, determine the master node device and the slave node device in the first node device and the second node device according to the first parameter value; if the detection state is abnormal, determine the master node device and the slave node device in the first node device and the second node device based on the second parameter value in the unidirectional detection message between the first node device and the second node device;
[0157] The memory 102 is used to store the program for the processor to execute the above processing flow.
[0158] The first node device disclosed in this embodiment is implemented based on the node master / standby election method disclosed in the above embodiment, which will not be described in detail here.
[0159] The first node device disclosed in this embodiment determines the detection state based on the first parameter value in the bidirectional detection message between the first node device and the second node device; if the detection state is normal, the master node device and the slave node device in the first node device and the second node device are determined by the first parameter value; if the detection state is abnormal, the master node device and the slave node device in the first node device and the second node device are determined based on the second parameter value in the unidirectional detection message between the first node device and the second node device. This scheme transmits a bidirectional detection message between the first node device and the second node device, and can determine the detection state based on the first parameter value in the bidirectional detection message, and when the detection state is normal, it can directly complete the election of the master and standby nodes based on the first parameter value, and when the detection state is abnormal, it completes the election of the master and standby nodes based on the second parameter value in the unidirectional detection message. In the process of the election of the master and standby nodes, the election can be completed through the bidirectional detection message or the unidirectional detection message, without the participation of a third-party device, simplifying the election process and improving processing efficiency.
[0160] An embodiment of the present application also provides a readable storage medium on which a computer program is stored. The computer program is loaded and executed by a processor to implement the steps of the above-mentioned node master-slave election method. The specific implementation process can refer to the description of the corresponding part of the above-mentioned embodiment, and this embodiment will not repeat it.
[0161] The present application also proposes a computer program product or a computer program, which includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. The processor of the electronic device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the electronic device executes the method provided in various optional implementations of the above-mentioned node master and standby election method. The specific implementation process can refer to the description of the above-mentioned corresponding embodiment, and will not be repeated.
[0162] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0163] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0164] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0165] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be 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 present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for selecting a master node and a standby node, comprising: The first node device determines a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device; If the detection status is normal, determining the master node device and the slave node device in the first node device and the second node device according to the first parameter value; If the detection state is abnormal, a master node device and a slave node device in the first node device and the second node device are determined based on a second parameter value in a unidirectional detection message between the first node device and the second node device.
2. The method according to claim 1, wherein if the detection state is abnormal, determining the master node device and the slave node device in the first node device and the second node device based on the second parameter value in the unidirectional detection message between the first node device and the second node device comprises: If the first node device is a slave node device and the second node device is a master node device, if the detection state is abnormal, determining whether the second node device is abnormal based on a second parameter value in a unidirectional detection message between the first node device and the second node device; If it is determined that the second node device is abnormal, the first node device is adjusted to be a master node device.
3. The method according to claim 2, wherein determining whether the second node device is abnormal based on a second parameter value in a unidirectional detection message between the first node device and the second node device comprises: Reading a second parameter value in a one-way detection message from a storage structure at intervals of a specific duration, wherein the one-way detection message stored in the storage structure is sent to and stored by the second node device at intervals of a specific duration; Determine whether the second node device is abnormal based on the second parameter value.
4. The method according to claim 3, wherein determining whether the second node device is abnormal based on the second parameter value comprises: Comparing the second parameter value in the one-way detection message read from the storage structure at the current moment with the second parameter value in the one-way detection message read from the storage structure before the specific time period to obtain a comparison result; If the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read before the specific time period meet a specific rule, it is determined that the second node device is normal; If the comparison result indicates that the second parameter value in the one-way detection message read at the current moment and the second parameter value in the one-way detection message read before the specific time do not meet the specific rule, it is determined that the second node device is abnormal.
5. The method according to claim 3, wherein determining whether the second node device is abnormal based on the second parameter value comprises: If no one-way detection message is read from the storage structure within a specific time period, it is determined that the second node device is abnormal.
6. The method according to claim 1, further comprising: Detecting the interface status of the first node device; If the interface status of the first node device is abnormal, if the first node device is a master node device, the first node device is adjusted to a slave node device.
7. The method according to claim 1, wherein if the detection state is normal, determining a master node device and a slave node device in the first node device and the second node device by using the first parameter value comprises: In the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message output by the first node device in the bidirectional detection message represents the master node state, and the target state bit determined by the first parameter value in the second message output by the second node device in the bidirectional detection message represents the non-master node state, it is determined that the first node device is the master node device and the second node device is the slave node device; In the case where the detection state is normal, if it is determined that the target state bit determined by the first parameter value in the first message represents the master node state, and the target state bit determined by the first parameter value in the second message represents the master node state, based on the address information of the first node device and the address information of the second node device, the master node device and the slave node device are determined from the first node device and the second node device; When the detection status is normal, if it is determined that the target status bit determined by the first parameter value in the first message represents a non-master node status, and the target status bit determined by the first parameter value in the second message represents a non-master node status, based on the address information of the first node device and the address information of the second node device, the master node device and the slave node device are determined from the first node device and the second node device.
8. A node master / slave election system, comprising: Second node device; The first node device is capable of determining a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device; If the detection status is normal, determining the master node device and the slave node device in the first node device and the second node device according to the first parameter value; If the detection state is abnormal, a master node device and a slave node device in the first node device and the second node device are determined based on a second parameter value in a unidirectional detection message between the first node device and the second node device.
9. A first node device, comprising: A processor, configured to determine a detection state based on a first parameter value in a bidirectional detection message between the first node device and the second node device; If the detection status is normal, determining the master node device and the slave node device in the first node device and the second node device according to the first parameter value; If the detection state is abnormal, determining a master node device and a slave node device in the first node device and the second node device based on a second parameter value in a unidirectional detection message between the first node device and the second node device; The memory is used to store the program for the processor to execute the above processing flow.
10. A readable storage medium for storing at least one set of instruction sets; The instruction set is used to be called and at least execute the node master-slave election method according to any one of claims 1 to 7.
