A cluster master node confirmation method, device, electronic device and storage medium

By using the priority score list to determine and switch the master node in the server cluster, the problem of service suspension during the election process is solved and the reliability and high availability of the cluster are improved.

CN115499447BActive Publication Date: 2024-10-29BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211125011.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-15
Publication Date
2024-10-29
Estimated Expiration
2042-09-15

AI Technical Summary

Technical Problem

The server cluster suspended services during the master node election process, resulting in poor reliability.

Method used

Use the maintained priority score list to determine whether the node's own priority score is the highest. If it is the highest, it will immediately switch to the master node and broadcast the master node confirmation information to the cluster network to avoid suspending services while waiting for the election process.

Benefits of technology

The reliability and high availability of the server cluster are improved, and the master node failure time and service unavailability time are shortened.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115499447B_ABST
    Figure CN115499447B_ABST
Patent Text Reader

Abstract

The present application provides a cluster master node confirmation method, device, electronic device and storage medium, the method comprising: after confirming that the master node in the cluster network has a fault, judging whether the node's own priority score is the highest among the slave nodes according to the maintained priority score list, the priority score represents the communication capability and computing capability in the cluster network; if so, sending master node confirmation information to the cluster network, and modifying the node's own role status in the priority score list to the master node. By judging whether the node's own priority score is the highest according to the maintained priority score list, if the node's own priority score is the highest, the node itself is immediately switched to the master node, that is, the master node confirmation information is broadcast to the cluster network, thereby avoiding the situation where the server cluster is suspended while waiting for the election, and effectively improving the reliability of the server cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of server clusters, cluster elections and network communications, and in particular to a cluster master node confirmation method, device, electronic device and storage medium. Background Art

[0002] At present, the process of electing the master node in the server cluster is that when each node in the cluster receives an election request initiated by a candidate node, the node will compare its own identifier with that of the candidate node. When its own identifier is greater than the candidate node identifier, it will send a vote to the candidate node. When the number of votes of the candidate node exceeds half of the number of nodes in the cluster, the candidate node will send master node confirmation information to all cluster nodes, thereby completing the master node election process.

[0003] In the specific practice process, it was found that when the cluster completes the election of the master node, the service of the entire cluster is suspended. It is necessary to wait for the election process to be completed and the master node to be confirmed before the service of the entire cluster can be processed through the master node. Therefore, the current server cluster suspends service while waiting for the election process, resulting in poor reliability of the server cluster. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a cluster master node confirmation method, device, electronic device and storage medium, which are used to improve the problem of poor reliability of the server cluster caused by suspension of service during the election process.

[0005] The embodiment of the present application provides a cluster master node confirmation method, which is applied to nodes in a cluster network, including: after confirming that the master node in the cluster network has a fault, judging whether the node's own priority score is the highest among the slave nodes according to a maintained priority score list, the priority score list is used to store the priority scores of the nodes in the cluster network, and the priority scores represent the communication capabilities and computing capabilities in the cluster network; if so, sending master node confirmation information to the cluster network, and modifying the node's own role status in the priority score list to the master node. In the implementation process of the above scheme, by judging whether the node's own priority score is the highest according to the maintained priority score list, if the node's own priority score is the highest, the node itself is immediately switched to the master node, that is, the master node confirmation information is broadcast to the cluster network, thereby avoiding the situation where the server cluster is suspended while waiting for the election, and effectively improving the reliability of the server cluster.

[0006] Optionally, in an embodiment of the present application, after determining whether the priority score of the node itself is the highest among the slave nodes according to the maintained priority score list, it also includes: if the priority score of the node itself is not the highest, then after receiving the master node confirmation information sent by the first node in the cluster network, the role status of the first node is modified to the master node in the priority score list. In the implementation process of the above scheme, when the priority score of the node itself is not the highest among the slave nodes, if the master node confirmation information sent by the first node in the cluster network is received, the other first nodes are recognized as master nodes, that is, the role status of the first node is modified to the master node in the priority score list, thereby shortening the failure time of the master node in the cluster network, avoiding the situation where the server cluster is suspended while waiting for the election, and effectively improving the reliability of the server cluster.

[0007] Optionally, in an embodiment of the present application, confirming that a master node in a cluster network has failed includes: if a heartbeat message sent by the master node is not received within a preset time length, then confirming that a master node in the cluster network has failed. In the implementation of the above scheme, by confirming that a master node in the cluster network has failed when a heartbeat message sent by the master node is not received within a preset time length, the confirmation time length of a master node failure in the cluster network is shortened.

[0008] Optionally, in an embodiment of the present application, before determining whether the node's own priority score is the highest among the slave nodes based on the maintained priority score list, it also includes: determining whether a heartbeat message sent from the slave node is received within a preset time period; if so, updating the priority score in the priority score list based on the heartbeat message.

[0009] Optionally, in an embodiment of the present application, updating the priority score in the priority score list according to the heartbeat information includes: determining whether the priority score is parsed from the heartbeat information; if so, using the parsed priority score to update the priority score of the slave node in the priority score list. In the implementation process of the above scheme, after receiving the heartbeat information sent by the slave node within a preset time, the priority score is parsed from the heartbeat information, and the priority score is updated to the priority score list, thereby providing a data basis for the determination of the master node, thereby improving the transfer speed of the cluster network when a fault occurs.

[0010] Optionally, in an embodiment of the present application, after determining whether the priority score is parsed from the heartbeat information, it also includes: if the priority score is not parsed from the heartbeat information, using the timestamp corresponding to the current moment to update the timestamp of the slave node in the priority score list.

[0011] Optionally, in an embodiment of the present application, after determining whether the heartbeat information sent by the slave node is received within a preset time length, it also includes: if the heartbeat information sent by the slave node is not received within the preset time length, the priority score of the slave node is deleted from the priority score list. In the implementation process of the above scheme, by deleting the priority score of the slave node from the priority score list when the heartbeat information sent by the slave node is not received within the preset time length, the impact of the priority score of the faulty node on the confirmation of the new master node is reduced. Since the priority score of the slave node is deleted from the priority score list, the amount of data that needs to be compared in the priority score list is reduced, shortening the time length for querying the priority score list, and therefore, the transfer speed of a fault in the cluster network can be improved.

[0012] Optionally, in an embodiment of the present application, before judging whether the priority score of the node itself is the highest among the slave nodes according to the maintained priority score list, it also includes: obtaining the load data of the node itself; performing weighted calculation on the load data of the node itself to obtain the priority score of the node itself. In the implementation process of the above scheme, the priority score is obtained by performing weighted calculation on the load data of the node itself, thereby avoiding the situation where the cluster network cannot operate again due to the excessive load of the master node, and effectively ensuring the high availability of the server cluster.

[0013] Optionally, in the embodiment of the present application, it also includes: if the hardware device of the node itself changes from the running state to the fault state, the priority score of the node itself is reduced by the priority score corresponding to the hardware device; if the hardware device of the node itself recovers from the fault state to the running state, the priority score of the node itself is increased by the priority score corresponding to the hardware device. In the implementation process of the above scheme, when the state of the hardware device of the node itself changes, the priority score of the node itself is increased or decreased in real time, thereby ensuring the real-time nature of the priority score, avoiding the problem of being unable to determine the master node due to the inability to update the priority score in real time, and effectively ensuring the high availability of the server cluster.

[0014] The embodiment of the present application also provides a cluster master node confirmation device, which is applied to nodes in a cluster network, including: a priority score judgment module, which is used to judge whether the node's own priority score is the highest among the slave nodes based on a maintained priority score list after confirming that the master node in the cluster network has a fault, the priority score list being used to store the priority scores of the nodes in the cluster network, and the priority scores representing the communication capability and computing capability in the cluster network; a main node confirmation module, which is used to send main node confirmation information to the cluster network if the node's own priority score is the highest among the slave nodes, and modify the node's own role status in the priority score list to a main node.

[0015] Optionally, in an embodiment of the present application, the cluster master node confirmation device also includes: a main node recognition module, which is used to modify the role status of the first node to the main node in the priority score list after receiving the main node confirmation information sent by the first node in the cluster network if the node’s own priority score is not the highest.

[0016] Optionally, in an embodiment of the present application, the priority score determination module includes: a master node fault confirmation submodule, which is used to confirm that a master node in the cluster network has a fault if no heartbeat information sent by the master node is received within a preset time.

[0017] Optionally, in an embodiment of the present application, the cluster master node confirmation device also includes: a heartbeat reception judgment module, used to determine whether the heartbeat information sent by the slave node is received within a preset time length; a priority score updating module, used to update the priority score in the priority score list according to the heartbeat information if the heartbeat information sent by the slave node is received within the preset time length.

[0018] Optionally, in an embodiment of the present application, the priority score update module includes: a priority score judgment submodule, used to determine whether the priority score is parsed from the heartbeat information; and a priority score update submodule, used to update the priority score list with the parsed priority score if the priority score is parsed from the heartbeat information.

[0019] Optionally, in an embodiment of the present application, the priority score update module further includes: a timestamp update submodule, which is used to update the timestamp of the slave node in the priority score list using the timestamp corresponding to the current moment if the priority score is not parsed from the heartbeat information.

[0020] Optionally, in an embodiment of the present application, the cluster master node confirmation device also includes: a priority score deletion module, which is used to delete the priority score of the slave node from the priority score list if the heartbeat information sent by the slave node is not received within a preset time period.

[0021] Optionally, in an embodiment of the present application, the cluster master node confirmation device also includes: a load data acquisition module, used to obtain the node's own load data; a priority score acquisition module, used to perform weighted calculation on the node's own load data to obtain the node's own priority score.

[0022] Optionally, in an embodiment of the present application, the cluster master node confirmation device also includes: a priority score subtraction module, which is used to subtract the priority score of the node itself from the priority score corresponding to the hardware device if the node's own hardware device changes from a running state to a faulty state; and a priority score increase module, which is used to increase the priority score of the node itself by the priority score corresponding to the hardware device if the node's own hardware device recovers from a faulty state to a running state.

[0023] An embodiment of the present application further provides an electronic device, including: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, the method described above is performed.

[0024] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described above is executed.

[0025] Other features and advantages of the embodiments of the present application will be described in the subsequent description, and in part will become apparent from the description, or will be understood by implementing the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0027] Figure 1 A schematic diagram of a process flow of a cluster master node confirmation method provided by an embodiment of the present application is shown;

[0028] Figure 2 A schematic diagram of an electronic device in a cluster network provided by an embodiment of the present application is shown;

[0029] Figure 3 A schematic diagram of a priority score list provided in an embodiment of the present application is shown;

[0030] Figure 4 A schematic diagram of the structure of a cluster master node confirmation device provided in an embodiment of the present application is shown;

[0031] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments in the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the embodiments of the present application claimed for protection, but merely represents the selected embodiments in the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the embodiments of the present application.

[0033] It is understandable that the "first" and "second" in the embodiments of the present application are used to distinguish similar objects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not necessarily limit the difference.

[0034] Before introducing the cluster master node confirmation method provided in the embodiment of the present application, some concepts involved in the embodiment of the present application are first introduced:

[0035] A cluster network refers to the network devices and connected networks that communicate with each other between the internal devices of a computer cluster. The cluster network here can be a network in a wide area network (such as the Internet) or a local area network; at least one electronic device runs in the cluster network here, and the electronic devices here include: terminal devices, servers and network devices.

[0036] It should be noted that the cluster master node confirmation method provided in the embodiment of the present application can be executed by an electronic device, where the electronic device refers to a device terminal or server with the function of executing a computer program, such as a smart phone, a personal computer, a tablet computer, a personal digital assistant, or a mobile Internet device. A server refers to a device that provides computing services through a network, such as an x86 server and a non-x86 server, and non-x86 servers include mainframes, minicomputers, and UNIX servers.

[0037] The following introduces application scenarios where the cluster master node confirmation method is applicable. The application scenarios here are not limited to: using the cluster master node confirmation method to replace the traditional cluster master node election process, if the master node fails, and the node's own priority score is the highest among the slave nodes, the node itself is immediately switched to the master node, thereby avoiding the situation where the server cluster waits for the election process and causes the cluster to suspend service. The server cluster does not need to perform the election process and can directly use the pre-maintained priority score list to determine the cluster master node, which greatly shortens the unavailability period of the cluster service and effectively ensures the high reliability and high availability of the server cluster.

[0038] See also Figure 1 The flowchart of the cluster master node confirmation method provided by the embodiment of the present application is shown; the cluster master node confirmation method can be applied to nodes in a cluster network. The main idea of ​​the method is that after confirming that the master node in the cluster network has a fault, the cluster is no longer triggered to elect a new master node, but the slave node with the highest priority score is directly selected from the maintained priority score list as the new master node, thereby avoiding the situation where the server cluster is suspended while waiting for the election process, and effectively improving the reliability of the server cluster. The implementation method of the above-mentioned cluster master node confirmation method may include:

[0039] Step S110: After confirming that the master node in the cluster network fails, determine whether the node's own priority score is the highest among the slave nodes based on the maintained priority score list. The priority score list is used to store the priority scores of the nodes in the cluster network. The priority scores represent the communication capability and computing capability in the cluster network.

[0040] The master node refers to the node used to coordinate and allocate various electronic devices in the cluster network to perform cluster system tasks. When the master node fails (for example, all network adapters fail and the network is disconnected, or the master node is overloaded and cannot be used, etc.), the entire cluster network cannot provide services normally. Therefore, a new master node needs to be determined from the cluster network so that the entire cluster network can continue to provide services normally.

[0041] The priority score list refers to a list used to store the priority scores of nodes in the cluster network. The priority score list can use a data table in a database. The database here includes but is not limited to: in-memory database, relational database and non-relational database, etc. The in-memory database that can be used is for example: Memcached and Redis, etc. The fields in the data table may include but are not limited to: node identification, priority score, role status, node status, node load information, hardware status information and / or timestamp of the most recent update time, etc.

[0042] Step S120: If the priority score of the node itself is the highest among the slave nodes, a master node confirmation message is sent to the cluster network, and the role status of the node itself in the priority score list is changed to a master node.

[0043] See also Figure 2 A schematic diagram of electronic device communication in a cluster network provided by an embodiment of the present application is shown; it can be understood that the cluster network may include: electronic device A, electronic device B, electronic device C and electronic device D. Assuming that electronic device A is a master node, and electronic device B, electronic device C and electronic device D are all slave nodes, then after electronic device A fails as the master node, there is no need to perform an election process. Each slave node directly determines in the priority score list that its priority score is the highest among the slave nodes, and then sends a master node confirmation message to the cluster network, and changes the node's own role status in the priority score list to the master node.

[0044] An implementation example of the above-mentioned step S120 is: electronic device A (priority score is 90) is the master node, and electronic device B (priority score is 80), electronic device C (priority score is 70) and electronic device D (priority score is 60) are all slave nodes, then electronic device B, as a slave node, can determine whether the node's own priority score is the highest among the slave nodes based on the maintained priority score list; if the node's own priority score is the highest among the slave nodes, then electronic device B, as a slave node, can send master node confirmation information to the cluster network via the Transmission Control Protocol (TCP) or the User Datagram Protocol (UDP), and modify the node's own role status in the priority score list to the master node, that is, change the role status of electronic device B to the master node.

[0045] It is understandable that the priority scores in the priority score list can be maintained in advance, for example, each node broadcasts heartbeat information (the heartbeat information may include: node identification, priority score, role status, node status, node load information and / or hardware status information, etc.) at regular intervals, and the priority scores of each slave node and master node are parsed from the heartbeat information, and the priority scores are stored in the priority score list. Since the priority scores in the priority score list can be maintained in advance, when the master node fails, other nodes in the cluster network can query the priority score list to determine the new master node in the cluster network without communication.

[0046] There are many ways to encapsulate the above-mentioned heartbeat information, including but not limited to: the first encapsulation method, when the electronic device node in the cluster network detects that the network bandwidth utilization is less than the preset utilization (indicating that the current network bandwidth is idle), the above-mentioned node identification, priority score, role status, node status, node load information and / or hardware status information, etc. can all be encapsulated as heartbeat information. The second encapsulation method, when the electronic device node in the cluster network detects that the network bandwidth utilization is greater than the preset utilization (indicating that the current network bandwidth is crowded), in order to save network resources, the node identification and role status can be encapsulated in the heartbeat information, and the reason why the priority score is not encapsulated in the heartbeat information is that the priority score has not changed. If the priority score has changed, the node identification and the changed priority score are encapsulated in the heartbeat information. The third encapsulation method, in order to further save network resources, the priority score can be encapsulated in the heartbeat information only when the priority score changes greatly, specifically for example: determine whether the ratio of the change value of the priority score to the priority score is greater than the preset ratio, if the ratio of the change value of the priority score to the priority score is greater than the preset ratio (i.e., the priority score changes greatly), then the node identification and the changed priority score are encapsulated in the heartbeat information. If the ratio of the change value of the priority score to the priority score is less than a preset ratio (ie, the change of the priority score is small), the node identifier and the role status are encapsulated in the heartbeat information.

[0047] There are many ways to send the above heartbeat information, including but not limited to: sending the heartbeat information in broadcast, multicast and unicast modes. The specific sending mode is similar to the following, so refer to the following broadcast, multicast and unicast modes.

[0048] There are many ways to send the master node confirmation information to the cluster network, including but not limited to: sending the master node confirmation information by broadcast, multicast, unicast, etc. Assuming that the cluster network is a local area network, the electronic device (i.e., the node) can send the master node confirmation information to the cluster network by broadcasting after determining whether its own priority score is the highest among the slave nodes. The sending object is the slave nodes in the cluster network except the node itself, and the role status of the node itself in the priority score list is modified to the master node. Assuming that the cluster network is a wide area network, the electronic device (i.e., the node) can send the master node confirmation information to the cluster network by multicast or unicast after determining whether its own priority score is the highest among the slave nodes, and the role status of the node itself in the priority score list is modified to the master node.

[0049] In the process of implementing the above scheme, by judging whether the node's own priority score is the highest according to the maintained priority score list, if the node's own priority score is the highest, the node itself is immediately switched to the master node, that is, the master node confirmation information is broadcast to the cluster network, thereby improving the transfer speed of faults in the cluster network, shortening the failure time of the master node in the cluster network, avoiding the situation where the server cluster suspends service while waiting for the election, and effectively improving the reliability of the server cluster.

[0050] As an optional implementation of the above cluster master node confirmation method, after determining whether the priority score of the node itself is the highest among the slave nodes, it is also possible to recognize other nodes as master nodes after confirming that it is not the highest among the slave nodes. This implementation may include:

[0051] Step S130: if the priority score of the node itself is not the highest, after receiving the master node confirmation information sent by the first node in the cluster network, the role status of the first node is modified to the master node in the priority score list.

[0052] See also Figure 3 A schematic diagram of a priority score list provided in an embodiment of the present application is shown; an implementation example of the above-mentioned step S130 is: electronic device A (priority score is 90) is a master node, and electronic device B (priority score is 80), electronic device C (priority score is 70) and electronic device D (priority score is 60) are all slave nodes, then electronic device C as a slave node can determine whether the node's own priority score is the highest among the slave nodes based on the maintained priority score list, if the priority score of electronic device C is not the highest among the slave nodes, it can wait to receive master node confirmation information sent by other slave nodes (such as electronic device B) in the cluster network, and after receiving master node confirmation information sent by other first nodes (such as electronic device B) in the cluster network through the TCP protocol or the UDP protocol, the role status of the first node (such as electronic device B) in the priority score list is modified to the master node.

[0053] As an optional implementation of confirming that a master node in the cluster network fails in the above step S110, the implementation may include:

[0054] Step S111: If the heartbeat information sent by the master node is not received within a preset time period, it is determined that the master node in the cluster network fails.

[0055] The implementation method of the above step S111 is, for example: if the heartbeat information sent by the master node (e.g., electronic device A) is not received within a preset time (e.g., 1 minute), it is confirmed that the master node in the cluster network has a fault (e.g., all network adapters of electronic device A fail and fall into a disconnected state, or the load of electronic device A is too heavy and causes the downtime and unusable state, etc.). It can be understood that the above preset time can be set according to the specific situation, for example, the preset time is set to 30 seconds, 60 seconds or 90 seconds, etc.

[0056] As an optional implementation of the above step S110, before using the maintained priority score list for judgment, the priority score parsed from the received heartbeat information may be updated into the priority score list. This implementation may include:

[0057] Step S112: Determine whether the heartbeat information sent by the slave node is received within a preset time period.

[0058] An implementation method of the above-mentioned step S112 is, for example: using an executable program compiled or interpreted by a preset programming language to determine whether the heartbeat information sent from the node is received within a preset time period, wherein the programming languages ​​that can be used are, for example: C, C++, Java, BASIC, JavaScript, LISP, Shell, Perl, Ruby, Python and PHP, etc.

[0059] Step S113: if the heartbeat information sent by the slave node is received within the preset time period, the priority score in the priority score list is updated according to the heartbeat information.

[0060] As an optional implementation of the above step S113, when there is a change in the priority score, the priority score can be directly updated. The implementation may include:

[0061] Step S113a: Determine whether a priority score is parsed from the heartbeat information.

[0062] Step S113b: If the priority score is parsed from the heartbeat information, the parsed priority score is updated into the priority score list.

[0063] Step S113c: If the priority score is not parsed from the heartbeat information, the timestamp corresponding to the current moment is used to update the timestamp of the slave node in the priority score list.

[0064] The implementation method of the above steps S113a to S113c is, for example: each node broadcasts heartbeat information regularly (the heartbeat information may include: node identification, priority score, node role, node load information and / or hardware status information, etc.), if the heartbeat information sent by the slave node (e.g., electronic device B) is received within the preset time length, then after parsing the priority score from the heartbeat information, the priority score is updated to the priority score list, that is, the priority score parsed from the heartbeat information (e.g., 80 points) is updated (i.e., replaced) with the priority score (e.g., 50 points) of the slave node (e.g., electronic device B) in the priority score list. Similarly, if the priority score is not parsed from the heartbeat information, the timestamp corresponding to the current moment is used to update (i.e., replace) the timestamp of the slave node in the priority score list, and the timestamp represents the most recent update time of the priority score. Of course, in the specific practice process, the role status and node status can also be parsed from the heartbeat information, and the role status and node status are updated to the priority score list.

[0065] As an optional implementation of the above step S110, before using the maintained priority score list for judgment, if no heartbeat information of the slave node is received within a preset period of time, the priority score of the slave node may be directly deleted. This implementation may include:

[0066] Step S114: If the heartbeat information sent by the slave node is not received within the preset time period, the priority score of the slave node is deleted from the priority score list.

[0067] The implementation method of the above step S114 is, for example: assuming that electronic device B is a slave node, and does not receive the heartbeat information sent by the slave node (e.g., electronic device D) within a preset time (e.g., 1 minute), the priority score of the slave node (e.g., electronic device D) is deleted from the priority score list, and the node state of the node (e.g., electronic device D) is modified to a fault state. Of course, in the specific practice, if the heartbeat information sent by the slave node (e.g., electronic device D) is not received within the preset time, the entire data record of the slave node (e.g., electronic device D) can be directly deleted.

[0068] Similarly, assuming that electronic device B acts as a slave node and does not receive the heartbeat information sent by the master node (e.g., electronic device A) within a preset time (e.g., 1 minute), the priority score of the master node (e.g., electronic device A) is deleted from the priority score list, and the node state of the node (e.g., electronic device A) is modified to a fault state. It is understandable that the above-mentioned preset time can be set according to the specific situation, for example, the preset time is set to 30 seconds, 60 seconds, or 90 seconds, etc. Of course, in the specific practice process, if the heartbeat information sent by the master node (e.g., electronic device A) is not received within the preset time (e.g., 1 minute), the entire data record of the master node (e.g., electronic device A) can be directly deleted.

[0069] As an optional implementation of the above step S110, before determining whether the priority score of the node itself is the highest among the slave nodes, the priority score may also be calculated according to the load data of the node itself. This implementation may include:

[0070] Step S115: Obtain the load data of the node itself.

[0071] Load data refers to the load-related data that an electronic device bears when it acts as a node (master node or slave node), such as CPU utilization, network bandwidth occupancy, memory utilization, and swap area utilization.

[0072] The implementation method of the above step S115 is, for example: if the operating system of the node is a Linux system, the load data of the node itself can be obtained by using commands such as top. If the operating system of the node is a Windows system, the system application programming interface (Application Programming Interface, API) in the system can be called to obtain the load data of the node itself.

[0073] Step S116: Perform weighted calculation on the node's own load data to obtain the node's own priority score.

[0074] It is understandable that, when the cluster network starts to run in an initial state, the user can configure the priority score of the node itself, or the node can perform weighted calculation according to its own load data to obtain the priority score of the node itself.

[0075] For example, the implementation of the above step S116 is as follows: Assuming that the load data includes: CPU utilization (weight is 0.5) and memory utilization (weight is 0.5), and the CPU utilization is 20% and the memory utilization is 40%, then the priority score of electronic device C can be calculated using the formula S = [(1-R1) × 0.5 + (1-R2) × 0.5] × 100, that is, the load data of electronic device C is weighted and the priority score obtained is S = [(1-0.2) × 0.5 + (1-0.4) × 0.5] × 100 = 70. Among them, S represents the priority score of the node itself, R1 represents the CPU utilization, and R2 represents the memory utilization.

[0076] As an optional implementation of the above cluster master node confirmation method, the priority score of the node itself may also be modified when the status of the node's own hardware device changes. This implementation may include:

[0077] Step S117: If the hardware device of the node itself changes from a running state to a faulty state, the priority score of the node itself is subtracted from the priority score corresponding to the hardware device.

[0078] An example of an implementation of the above step S117 is: assuming that electronic device D detects that one of its network adapters has changed from a running state to a faulty state, and the priority score corresponding to the network adapter is 10 points, then the priority score of electronic device D itself, 70, can be subtracted from the priority score of the hardware device, 10, to obtain a final priority score of 60 for electronic device D itself.

[0079] Step S118: If the hardware device of the node recovers from the fault state to the running state, the priority score of the node is increased by the priority score corresponding to the hardware device.

[0080] An example of an implementation of the above step S118 is: assuming that electronic device B detects that one of its network adapters has recovered from a faulty state to a running state, and the priority score corresponding to the network adapter is 10 points, then the priority score of electronic device C itself, 70, can be increased by the priority score corresponding to the hardware device, 10, and the final priority score of electronic device C itself is 80.

[0081] See also Figure 4 The schematic diagram of the structure of the cluster master node confirmation device provided in the embodiment of the present application is shown; the embodiment of the present application provides a cluster master node confirmation device 200, which is applied to a node in a cluster network, including:

[0082] The priority score judgment module 210 is used to determine whether the node's own priority score is the highest among the slave nodes based on the maintained priority score list after confirming that the main node in the cluster network has a fault. The priority score list is used to store the priority scores of the nodes in the cluster network. The priority scores represent the communication capability and computing capability in the cluster network.

[0083] The main node confirmation module 220 is used to send a main node confirmation message to the cluster network if the node's own priority score is the highest among the slave nodes, and modify the node's own role status in the priority score list to a main node.

[0084] Optionally, in the embodiment of the present application, the cluster master node confirmation device further includes:

[0085] The main node recognition module is used to modify the role status of the first node to the main node in the priority score list after receiving the main node confirmation information sent by the first node in the cluster network if the node's own priority score is not the highest.

[0086] Optionally, in the embodiment of the present application, the priority score determination module includes:

[0087] The master node fault confirmation submodule is used to confirm that the master node in the cluster network has a fault if the heartbeat information sent by the master node is not received within a preset time.

[0088] Optionally, in the embodiment of the present application, the cluster master node confirmation device further includes:

[0089] The heartbeat receiving judgment module is used to judge whether the heartbeat information sent by the slave node is received within a preset time.

[0090] The priority score updating module is used to update the priority scores in the priority score list according to the heartbeat information if the heartbeat information sent by the slave node is received within a preset time period.

[0091] Optionally, in the embodiment of the present application, the priority score updating module includes:

[0092] The priority score judgment submodule is used to judge whether the priority score is parsed from the heartbeat information;

[0093] The priority score update submodule is used to update the priority score list with the parsed priority score if the priority score is parsed from the heartbeat information.

[0094] Optionally, in the embodiment of the present application, the priority score updating module further includes:

[0095] The timestamp update submodule is used to update the timestamp of the slave node in the priority score list with the timestamp corresponding to the current moment if the priority score is not parsed from the heartbeat information.

[0096] Optionally, in the embodiment of the present application, the cluster master node confirmation device further includes:

[0097] The priority score deletion module is used to delete the priority score of the slave node from the priority score list if the heartbeat information sent by the slave node is not received within a preset time period.

[0098] Optionally, in the embodiment of the present application, the cluster master node confirmation device further includes:

[0099] The load data acquisition module is used to obtain the load data of the node itself.

[0100] The priority score obtaining module is used to perform weighted calculation on the node's own load data to obtain the node's own priority score.

[0101] Optionally, in the embodiment of the present application, the cluster master node confirmation device further includes:

[0102] The priority score subtraction module is used to subtract the priority score corresponding to the hardware device from the priority score of the node itself if the hardware device of the node itself changes from the running state to the fault state.

[0103] The priority score increasing module is used to increase the priority score of the node itself by the priority score corresponding to the hardware device if the hardware device of the node itself recovers from a fault state to a running state.

[0104] It should be understood that the device corresponds to the above-mentioned cluster master node confirmation method embodiment and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.

[0105] See also Figure 5 The electronic device 300 provided in the embodiment of the present application includes: a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and when the machine-readable instructions are executed by the processor 310, the above method is executed.

[0106] The embodiment of the present application further provides a computer-readable storage medium 330 , on which a computer program is stored. When the computer program is executed by the processor 310 , the above method is executed.

[0107] Among them, the computer-readable storage medium 330 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, disk or optical disk.

[0108] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0109] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed device and method can also be implemented in other ways. The device embodiments described above are only schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible implementation architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a part of a module, a program segment or a code, and a part of a module, a program segment or a code includes one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also be different from the order of occurrence marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which is mainly determined by the functions involved.

[0110] In addition, each functional module of each embodiment in the embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. In addition, in the description of this specification, the description of reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present application. In this specification, the schematic representation of the above terms does not necessarily have to be directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples without contradicting each other.

[0111] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0112] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.

Claims

1. A cluster master node confirmation method, characterized in that: Applicable to nodes in the cluster network, including: After confirming that a master node in the cluster network fails, determining whether the node's own priority score is the highest among the slave nodes according to a maintained priority score list, the priority score list being used to store priority scores of nodes in the cluster network, the priority scores representing communication capability and computing capability in the cluster network; If yes, send a master node confirmation message to the cluster network, and modify the role status of the node itself in the priority score list to be a master node; Among them, before judging whether the priority score of the node itself is the highest among the nodes based on the maintained priority score list, it also includes: obtaining the load data of the node itself, the load data including: CPU utilization and memory utilization; performing weighted calculation on the CPU utilization and the memory utilization to obtain the priority score of the node itself; if the hardware device of the node itself changes from a running state to a faulty state, subtracting the priority score corresponding to the hardware device from the priority score of the node itself; if the hardware device of the node itself recovers from a faulty state to a running state, increasing the priority score of the node itself by the priority score corresponding to the hardware device.

2. The method according to claim 1, characterized in that After determining whether the priority score of the node itself is the highest among the nodes according to the maintained priority score list, the method further includes: If the priority score of the node itself is not the highest, after receiving the master node confirmation information sent by the first node in the cluster network, the role status of the first node is modified to the master node in the priority score list.

3. The method according to claim 1, characterized in that: The confirming that a master node in the cluster network fails includes: If the heartbeat information sent by the master node is not received within the preset time period, it is confirmed that the master node in the cluster network has a fault.

4. The method according to claim 1, characterized in that: Before judging whether the priority score of the node itself is the highest among the nodes according to the maintained priority score list, the method further includes: Determine whether the heartbeat information sent by the slave node is received within a preset time; If so, the priority scores in the priority score list are updated according to the heartbeat information.

5. The method according to claim 4, characterized in that The updating of the priority scores in the priority score list according to the heartbeat information comprises: Determining whether the priority score is parsed from the heartbeat information; If so, the parsed priority score is updated to the priority score list.

6. The method according to claim 5, characterized in that After determining whether to parse the priority score from the heartbeat information, the method further includes: If the priority score is not parsed from the heartbeat information, the timestamp corresponding to the current moment is used to update the timestamp of the slave node in the priority score list.

7. The method according to claim 4, characterized in that After determining whether the heartbeat information sent by the slave node is received within a preset time period, the method further includes: If the heartbeat information sent by the slave node is not received within a preset time period, the priority score of the slave node is deleted from the priority score list.

8. A cluster master node confirmation device, characterized in that: Applicable to nodes in the cluster network, including: a priority score judgment module, configured to, after confirming that a master node in the cluster network has failed, judge whether the priority score of the node itself is the highest among the slave nodes according to a maintained priority score list, wherein the priority score list is used to store the priority scores of the nodes in the cluster network, and the priority scores represent the communication capability and computing capability in the cluster network; A primary node confirmation module, configured to send a primary node confirmation message to the cluster network if the priority score of the node itself is the highest among the secondary nodes, and change the role status of the node itself in the priority score list to a primary node; Among them, before judging whether the priority score of the node itself is the highest among the nodes based on the maintained priority score list, it also includes: obtaining the load data of the node itself, the load data including: CPU utilization and memory utilization; performing weighted calculation on the CPU utilization and the memory utilization to obtain the priority score of the node itself; if the hardware device of the node itself changes from a running state to a faulty state, subtracting the priority score corresponding to the hardware device from the priority score of the node itself; if the hardware device of the node itself recovers from a faulty state to a running state, increasing the priority score of the node itself by the priority score corresponding to the hardware device.

9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the machine-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is performed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.

Citation Information

Patent Citations

  • A method to enhance the reliability of the cluster and a high reliability communication node

    CN101217402A

  • System fault processing method and device, computer equipment and storage medium

    CN112328421A

  • Master server and slave server switching method and device and server

    CN112422320A