A cluster node monitoring method and related equipment
By dividing the main thread, heartbeat monitoring thread and transmission thread in the cluster nodes, heartbeat isolation is achieved, and the load pressure problem caused by excessive processing of the main service process is solved, ensuring the normal operation of the cluster business and improving the robustness of the system.
Patent Information
- Application Number
- CN202210832794.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2042-07-15
AI Technical Summary
In a distributed storage system, the main service process takes too long to process other events, resulting in the inability to process the heartbeat requests of other nodes in time, causing an incorrect election process, affecting the normal operation of cluster services.
By creating the main thread, heartbeat monitoring thread and transmission thread in the cluster node, the heartbeat monitoring thread initiates the heartbeat signal, the transmission thread transmits the signal and receives reply, the main thread updates the node status, realizes heartbeat isolation, and avoids excessive load on the main service process.
It effectively avoids the impact of cluster business due to excessive load pressure on the main service process, ensures the normal operation of cluster business, and improves the robustness and ease of use of cluster system.
Smart Images

Figure CN115102887B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of cluster systems, and in particular to a cluster node monitoring method, and also to a cluster node monitoring device, an electronic device, and a computer-readable storage medium. Background Art
[0002] At present, distributed storage systems have been widely used in IT enterprises, cloud computing, big data, virtualization and other fields. In distributed storage systems, such as CTDB cluster (Cluster Trivial Database, key-value database cluster), the main process mainly includes two processes, the parent process and the recovery process (child process), among which the parent process is responsible for the message interaction between the recovery process and other cluster nodes, the processing of the heartbeat process, and the cluster health status monitoring process; the recovery process is responsible for periodically detecting whether the cluster needs to be recovered and performing the recovery process when necessary. However, if the parent process is unable to process the heartbeat requests of other nodes in time because it takes a long time to process other events, it will be considered unreachable by other nodes, and a new round of elections will be triggered by mistake, thus affecting normal business.
[0003] Therefore, how to effectively avoid the impact on cluster services caused by too much operation content and excessive load pressure of the main service process in the cluster node, and thus ensure the normal operation of the cluster services is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0004] The purpose of the present application is to provide a cluster node monitoring method, which can effectively avoid the impact on cluster services caused by excessive operation content and excessive load pressure of the main service process in the cluster node, thereby ensuring the normal operation of the cluster services; another purpose of the present application is to provide a cluster node monitoring device, electronic device and computer-readable storage medium, all of which have the above-mentioned beneficial effects.
[0005] In a first aspect, the present application provides a cluster node monitoring method, which is applied to each node in a cluster system, including:
[0006] Use the heartbeat monitoring thread to initiate a heartbeat signal;
[0007] Using a transmission thread to send the heartbeat signal to other nodes in the cluster system, and receiving reply signals fed back by other nodes;
[0008] Utilizing the heartbeat monitoring thread to determine the offline nodes in the cluster system according to each of the reply signals, and uploading the corresponding offline node information to the main thread;
[0009] The main thread is used to perform a node status update operation according to the offline node information.
[0010] Optionally, the initiating a heartbeat signal by using a heartbeat monitoring thread includes:
[0011] The heartbeat signal is initiated by the heartbeat monitoring thread at a preset time interval.
[0012] Optionally, the using the heartbeat monitoring thread to determine the offline node in the cluster system according to each of the reply signals includes:
[0013] When the number of times that the reply signal is not received reaches a preset number, the corresponding node is determined to be the offline node.
[0014] Optionally, the using the main thread to perform a node status update operation according to the offline node information includes:
[0015] The offline node information is sent to the recovery process by using the main thread, so that the recovery process performs the node status update operation.
[0016] Optionally, before initiating a heartbeat signal using the heartbeat monitoring thread, the method further includes:
[0017] When receiving a monitoring instruction, reading a preset configuration file according to the monitoring instruction;
[0018] Determine whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file;
[0019] If yes, start the heartbeat monitoring thread and the transmission thread.
[0020] Optionally, the method further comprises:
[0021] When receiving a monitoring exit instruction, reading a preset configuration file according to the monitoring exit instruction;
[0022] Determine whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file;
[0023] If so, the heartbeat monitoring thread and the transmission thread are closed.
[0024] Optionally, after closing the heartbeat monitoring thread and the transmission thread, the method further includes:
[0025] The pre-allocated resources of the heartbeat monitoring thread and the pre-allocated resources of the transmission thread are released.
[0026] In a second aspect, the present application further discloses a cluster node monitoring device, which is applied to each node in the cluster system, including:
[0027] A signal initiation module is used to initiate a heartbeat signal using a heartbeat monitoring thread;
[0028] A signal transmission module, used to send the heartbeat signal to other nodes in the cluster system by using a transmission thread, and receive reply signals fed back by other nodes;
[0029] A status monitoring module, used to determine the offline nodes in the cluster system according to each of the reply signals using the heartbeat monitoring thread, and upload the corresponding offline node information to the main thread;
[0030] The status update module is used to utilize the main thread to perform a node status update operation according to the offline node information.
[0031] In a third aspect, the present application further discloses an electronic device, comprising:
[0032] Memory for storing computer programs;
[0033] A processor is used to implement the steps of any one of the cluster node monitoring methods described above when executing the computer program.
[0034] In a fourth aspect, the present application further discloses a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the cluster node monitoring methods described above are implemented.
[0035] A cluster node monitoring method provided in the present application is applied to each node in the cluster system, including using a heartbeat monitoring thread to initiate a heartbeat signal; using a transmission thread to send the heartbeat signal to other nodes in the cluster system, and receiving reply signals fed back by other nodes; using the heartbeat monitoring thread to determine the offline nodes in the cluster system according to each of the reply signals, and uploading the corresponding offline node information to the main thread; and using the main thread to perform a node status update operation according to the offline node information.
[0036] By applying the technical solution provided in the present application, cluster node monitoring is achieved by creating a main thread, a heartbeat monitoring thread and a transmission thread, heartbeat detection is performed using the heartbeat monitoring thread, signal transmission is performed using the transmission thread, and node status is updated using the main thread. This is equivalent to dividing the original main service process in the cluster node into three independent threads, namely the main thread, the heartbeat monitoring thread and the transmission thread, thereby realizing the heartbeat isolation function of the cluster system, avoiding the problem of excessive load pressure on the main service process caused by concentrating all operation content on the main service process, and thus avoiding the impact on the cluster business, thereby ensuring the normal operation of the cluster business; and it can also effectively improve the robustness and usability of the cluster system and improve product competitiveness.
[0037] The cluster node monitoring device, electronic device and computer-readable storage medium provided in the present application all have the above-mentioned beneficial effects, which will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the prior art and the embodiments of the present application, the drawings required for use in the description of the prior art and the embodiments of the present application are briefly introduced below. Of course, the drawings described below in relation to the embodiments of the present application are only part of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work, and the obtained other drawings also belong to the protection scope of the present application.
[0039] Figure 1 A schematic diagram of a cluster node monitoring method provided in this application;
[0040] Figure 2 A schematic diagram of a configuration parameter analysis process provided by this application;
[0041] Figure 3 A schematic diagram of a process of starting a transmission thread provided by this application;
[0042] Figure 4 A schematic diagram of a process for starting a heartbeat detection thread provided by this application;
[0043] Figure 5 A flowchart of a thread exit provided by this application;
[0044] Figure 6 A logical view of the heartbeat isolation function provided by this application;
[0045] Figure 7 A schematic diagram of the structure of a cluster node monitoring device provided by this application;
[0046] Figure 8A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0047] The core of the present application is to provide a cluster node monitoring method, which can effectively avoid the impact on cluster services caused by excessive operation content and excessive load pressure of the main service process in the cluster node, thereby ensuring the normal operation of the cluster services; another core of the present application is to provide a cluster node monitoring device, electronic device and computer-readable storage medium, which also have the above-mentioned beneficial effects.
[0048] In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below in conjunction with the drawings 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 making creative work are within the scope of protection of this application.
[0049] It should be noted that the cluster node monitoring method provided in this application can be applied to each node in the cluster system. In each node of the cluster system, a main service process is deployed, and the main service process includes a main thread, a transmission thread, and a heartbeat monitoring thread, so that cluster node monitoring is implemented using these three threads. Among them, the specific type of the cluster system does not affect the implementation of this technical solution. For example, it can be a distributed cluster system, such as a CTDB cluster.
[0050] An embodiment of the present application provides a cluster node monitoring method.
[0051] Please refer to Figure 1 , Figure 1 This is a flow chart of a cluster node monitoring method provided in the present application. The cluster node monitoring method includes the following S101 to S104.
[0052] S101: Initiate a heartbeat signal using the heartbeat monitoring thread;
[0053] This step aims to realize the initiation of the heartbeat signal, which is initiated by the heartbeat monitoring thread in the main service process. Among them, the heartbeat signal is used to monitor the status of other nodes in the cluster system. In the implementation process, when the cluster node monitoring service is started, the main service process is started at the same time, and then the main thread, transmission thread and heartbeat monitoring thread are started according to actual needs. Among them, the heartbeat monitoring thread can initiate the heartbeat signal regularly / irregularly / in real time, so as to facilitate the heartbeat monitoring of other nodes in the cluster system.
[0054] It should be noted that when the main service process is started, and the main thread, transmission thread, and heartbeat monitoring thread are started according to actual needs, it specifically means that the user can choose whether to divide the main service process into multiple independent threads for cluster node monitoring according to actual needs. In other words, the main service process can be directly selected to monitor the cluster nodes (similar to traditional technology), or the main service process can be divided into multiple independent threads for cluster node monitoring. Of course, the embodiment of the present application mainly chooses to divide the main service process into multiple independent threads for cluster node monitoring.
[0055] S102: using a transmission thread to send a heartbeat signal to other nodes in the cluster system, and receiving a reply signal fed back by other nodes;
[0056] This step aims to send the heartbeat signal to other nodes in the cluster system so as to realize the heartbeat monitoring of other nodes, and this process is realized by the transmission thread. Among them, the transmission thread is used to send the heartbeat signal initiated by the heartbeat monitoring thread to other nodes in the cluster system, and receive the reply signal about the heartbeat signal fed back by other nodes, that is, the heartbeat response, and then feed back each reply signal to the heartbeat monitoring thread, so that the heartbeat monitoring thread can determine the in-place status of other nodes in the cluster system according to each reply signal.
[0057] During the implementation process, after the heartbeat monitoring thread initiates a heartbeat signal, the heartbeat signal will be sent to the transmission thread, and the transmission thread can forward the heartbeat signal to other nodes in the cluster system. Of course, other nodes in the cluster system can use their own transmission threads to receive the heartbeat signal. If they are in the on-site state, they will feedback a reply signal. If they are in the offline state, there will be no feedback. Therefore, the transmission thread of the node that initiates the heartbeat signal receives all the reply signals and transmits them back to the heartbeat monitoring thread, so that the heartbeat monitoring thread can determine the on-site state of other nodes in the cluster system according to each reply signal.
[0058] It is understandable that the function of the transmission thread is not limited to this, and it can also realize the transmission of any message between the node where it is located and other nodes in the cluster system, such as data communication between the main thread and other nodes in the cluster system.
[0059] S103: using the heartbeat monitoring thread to determine the offline nodes in the cluster system according to each reply signal, and uploading the corresponding offline node information to the main thread;
[0060] This step aims to realize the in-place status monitoring of other nodes in the cluster system, and upload the relevant information of the monitored offline nodes (i.e. the above-mentioned offline node information) to the main thread so that the main thread can update the node status. This process is implemented by the heartbeat monitoring thread.
[0061] In the implementation process, after the heartbeat monitoring thread receives each reply signal fed back by the transmission thread, the node in the cluster system that has not fed back a reply signal can be determined based on the node information in each reply signal. This node is the offline node, and the remaining nodes are in-place nodes. For example, each node in the cluster system maintains the node information of all nodes in the cluster system. Therefore, the node information in each reply signal is compared with the node information maintained by itself to determine the offline node. Further, after determining the offline node, the node information of the offline node can be sent to the main thread so that the main thread can update the node status.
[0062] S104: Utilize the main thread to perform a node status update operation according to the offline node information.
[0063] This step aims to achieve node status update, and the process is implemented by the main thread. It should be noted that the main service process of each node in the cluster system maintains the status information of all nodes in the cluster system, including the in-place state and the offline state, so as to facilitate node monitoring. Therefore, when an offline node is detected in the cluster system, its status information can be updated from the online state to the offline state. Of course, when a node that was originally in the offline state is detected to be restored to the in-place state, its status information can also be changed from the offline state to the online state.
[0064] During the implementation process, after the heartbeat monitoring thread uploads the offline node information to the main thread, the main thread can update the status information of the offline node from the online state to the offline state according to the offline node information, thereby realizing cluster node monitoring.
[0065] It can be seen that the cluster node monitoring method provided in the embodiment of the present application realizes cluster node monitoring by creating a main thread, a heartbeat monitoring thread and a transmission thread, uses the heartbeat monitoring thread to perform heartbeat detection, uses the transmission thread to perform signal transmission, and uses the main thread to update the node status, which is equivalent to dividing the original main service process in the cluster node into three independent threads, namely the main thread, the heartbeat monitoring thread and the transmission thread, thereby realizing the heartbeat isolation function of the cluster system, avoiding the problem of excessive load pressure on the main service process caused by concentrating all operation content on the main service process, and thus avoiding the impact on the cluster business, thereby ensuring the normal operation of the cluster business; and it can also effectively improve the robustness and usability of the cluster system and improve the competitiveness of the product.
[0066] In one embodiment of the present application, the above-mentioned initiating a heartbeat signal by using a heartbeat monitoring thread may include: initiating a heartbeat signal by using a heartbeat monitoring thread at a preset time interval.
[0067] The embodiment of the present application provides a heartbeat signal initiation method, i.e., timed heartbeat monitoring. For the heartbeat monitoring thread, a timer event can be set in advance, and the timer is not set to initiate the heartbeat signal, i.e., the above-mentioned preset time interval, so that the heartbeat monitoring thread can initiate the heartbeat signal according to the preset time interval. Among them, the specific value of the preset time interval does not affect the implementation of the present technical solution, and can be set by the technical personnel according to the actual situation. This application does not limit this, for example, it can be set to 60 seconds.
[0068] In one embodiment of the present application, the above-mentioned determination of offline nodes in the cluster system according to each reply signal using the heartbeat monitoring thread may include: when the number of times that the reply signal is not received reaches a preset number, determining that the corresponding node is an offline node.
[0069] The embodiment of the present application provides a method for determining an offline node. It is understandable that the monitoring result of only one heartbeat monitoring may have errors, so the offline state determination can be achieved through the monitoring results of multiple heartbeat monitoring, thereby effectively ensuring the accuracy of the heartbeat monitoring result.
[0070] In the implementation process, when it is detected that a node does not feedback a reply signal, the node can continue to be monitored until the number of times it does not feedback a reply signal reaches a preset number, and the node can be determined to be an offline node. Of course, the specific value of the preset number does not affect the implementation of this technical solution, and can be set by technical personnel according to actual conditions. This application does not limit this, for example, it can be set to 3 times.
[0071] In one embodiment of the present application, the above-mentioned use of the main thread to perform the node status update operation according to the offline node information may include: using the main thread to send the offline node information to the recovery process, so that the recovery process performs the node status update operation.
[0072] As mentioned above, the main process in the cluster system mainly includes two processes, the parent process (main service process) and the recovery process (child process), wherein the parent process is responsible for message interaction with the recovery process and other cluster nodes, processing of the heartbeat process, and cluster health status monitoring process; the recovery process is responsible for periodically detecting whether the cluster needs to be restored, and performing the recovery process when necessary. On the basis of dividing the parent process into three independent threads, in the process of updating the node status, the main thread can send the offline node information to the recovery process, and the recovery process will perform the node status update operation and continue to execute the subsequent recovery process. That is to say, in an embodiment of the present application, the node status update operation is implemented by the recovery process.
[0073] In one embodiment of the present application, before the above-mentioned use of the heartbeat monitoring thread to initiate a heartbeat signal, it may also include: when a monitoring instruction is received, reading a preset configuration file according to the monitoring instruction; judging whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file; if so, starting the heartbeat monitoring thread and the transmission thread.
[0074] As described above, the user can choose whether to monitor the cluster nodes by dividing the main service process into multiple independent threads according to actual needs, and this process can be implemented based on a preset configuration file. Specifically, the user can set the heartbeat monitoring function on and off in the preset configuration file according to actual needs. When the heartbeat monitoring function is turned off, it means that the user chooses to monitor the cluster nodes directly by the main service process; when the heartbeat monitoring function is turned on, it means that the user chooses to divide the main service process into multiple independent threads for cluster node monitoring.
[0075] During the implementation process, when a monitoring instruction is received, that is, an instruction for starting the cluster node monitoring service, the preset configuration file can be read first to determine whether the heartbeat monitoring function is currently turned on. If the heartbeat monitoring function is not turned on, there is no need to start the heartbeat monitoring thread and the transmission thread, and the cluster node monitoring can be directly performed by the main server process; if the heartbeat monitoring function is turned on, the heartbeat monitoring thread and the transmission thread can be started to facilitate the use of multiple threads to implement cluster node monitoring.
[0076] In one embodiment of the present application, the cluster node monitoring method may further include: when a monitoring exit instruction is received, reading a preset configuration file according to the monitoring exit instruction; determining whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file; if so, closing the heartbeat monitoring thread and the transmission thread.
[0077] For a cluster system, when a user needs to exit cluster node monitoring, he can initiate a monitoring exit command. Of course, during the exit process, he also needs to first execute the corresponding exit process according to the configuration information in the preset configuration file. Specifically, when a monitoring exit command is received, the preset configuration file can be read first to determine whether the heartbeat monitoring function is currently enabled. If the heartbeat monitoring function is not enabled, it means that the cluster node is currently monitored by the main server process. At this time, you can directly exit the cluster node monitoring service; if the heartbeat monitoring function is enabled, it means that the main service process is currently divided into multiple independent threads for cluster node monitoring. At this time, you can first close the heartbeat monitoring thread and the transmission thread, and then continue to exit the cluster node monitoring service.
[0078] In one embodiment of the present application, after the heartbeat monitoring thread and the transmission thread are closed, the method may further include: releasing the pre-allocated resources of the heartbeat monitoring thread and the pre-allocated resources of the transmission thread.
[0079] It is understandable that when monitoring cluster nodes through multiple threads, it is necessary to allocate corresponding resources to each thread, such as computing resources and storage resources. Therefore, when exiting multiple threads, the resources allocated to each thread can be further released to avoid unnecessary resource occupation. Of course, here we mainly release the pre-allocated resources of the heartbeat monitoring thread and the transmission thread.
[0080] Based on the above embodiments, the embodiment of the present application takes the distributed storage system CTDB as an example to provide another cluster node monitoring method.
[0081] First, split the parent process (i.e., the main service process) in CTDB into three threads: the main thread, the transmission thread, and the heartbeat monitoring thread, where:
[0082] 1. Main thread: mainly responsible for event processing, interaction with the recovery process (subprocess), state maintenance and other original functions;
[0083] 2. Transmission thread: Since there will be frequent message exchanges between nodes in the cluster during the recovery phase, the transmission thread is mainly responsible for exchanging messages with other nodes. All messages that need to be transmitted to other nodes are sent through the transmission thread to share the pressure of the main thread, improve the processing efficiency of the main thread, and avoid processing switching caused by frequent message interruptions;
[0084] 3. Heartbeat monitoring thread: Nodes in the CTDB cluster detect the presence status of each node in the cluster by periodically detecting the heartbeat sent by the peer and sending heartbeats to the peer. Once an absent node (i.e., offline node) is detected, the main thread is notified so that the main thread can trigger the recovery process of CTDB. Since heartbeat processing has high requirements for real-time processing, the heartbeat thread is mainly responsible for the heartbeat detection of other nodes in the cluster, and the sending and receiving of heartbeat messages are implemented by the transmission thread.
[0085] Furthermore, the implementation process of the cluster node monitoring method provided in the embodiment of the present application mainly includes: heartbeat isolation function switch parameter analysis, transmission thread startup process, heartbeat monitoring thread startup process, and the exit process of the transmission thread and heartbeat thread when stopping the CTDB service.
[0086] 1. Analysis of heartbeat isolation function switch parameters:
[0087] Please refer to Figure 2 , Figure 2 A schematic diagram of a configuration parameter parsing process provided in this application mainly includes:
[0088] (1) The user configures the heartbeat isolation switch to on or off in the configuration file;
[0089] (2) Set the environment variable according to the configuration value of the parameter configuration in the configuration file;
[0090] (3) Construct the startup parameters of the CTDB main service process according to the environment variable values, including but not limited to switch parameters, number of nodes, response time, timing time interval, etc.;
[0091] (4) Start the CTDB main service process according to the startup parameters.
[0092] Among them, users can control the heartbeat isolation feature switch through the ctdbd.conf configuration file (the default is on):
[0093] (1) An example of enabling the heartbeat isolation feature is as follows:
[0094] CTDB_KEEPALIVE_ISOLATION=1;
[0095] (2) An example of disabling the heartbeat isolation feature is as follows:
[0096] CTDB_KEEPALIVE_ISOLATION=0.
[0097] 2. Transmission thread startup process:
[0098] Please refer to Figure 3 , Figure 3A schematic diagram of a process of starting a transmission thread provided in this application mainly includes:
[0099] (1) When the CTDB main service process starts, it determines whether to start the transmission thread according to the configuration value of the heartbeat isolation switch in the configuration file;
[0100] (2) If the switch is on, the transmission thread is started: in the transmission thread, a tevent event proxy is created and corresponding event monitoring is performed to transfer the message sending and receiving work with other nodes, which was originally the responsibility of the main service process, to the transmission thread of the main service process, so as to share the pressure of the main thread in the main service process;
[0101] (3) If the switch is off or the transfer thread creation is completed, continue with the subsequent startup process.
[0102] 3. Heartbeat monitoring thread startup process:
[0103] Please refer to Figure 4 , Figure 4 A flowchart of starting a heartbeat detection thread provided in this application mainly includes:
[0104] (1) When the CTDB main service process is started, it determines whether to perform heartbeat detection and processing directly in the main service process or to create a heartbeat detection thread in the main service process to perform heartbeat detection and processing according to the configuration value of the heartbeat isolation switch in the configuration file;
[0105] (2) If the switch is on, the heartbeat monitoring thread is started: In the heartbeat monitoring thread, a timer event is registered to periodically detect the heartbeat status of each node in the CTDB cluster. If the heartbeat loss of a node is detected, the main thread is notified to change the state of the node and trigger the main thread to perform corresponding recovery actions;
[0106] (3) If the switch is off, the timer event is directly registered in the main service process to periodically detect the heartbeat status of each node in the CTDB cluster. If the heartbeat loss of a node is detected, the state of the node is changed and the corresponding recovery action is triggered.
[0107] 4. When stopping the CTDB service, the exit process of the transmission thread and the heartbeat thread:
[0108] Please refer to Figure 5 , Figure 5 A flowchart of a thread exit provided by this application mainly includes:
[0109] (1) You can enter the stop CTDB service command through the command line to trigger the service stop process; or if the CTDB service encounters an irreversible error during operation, the service stop process will also be triggered;
[0110] (2) Determine whether the heartbeat isolation function is currently enabled;
[0111] (3) If the heartbeat isolation function is enabled, the heartbeat monitoring thread is stopped and the resources allocated to it are released, and the transmission thread is stopped and the resources allocated to it are released;
[0112] (4) If the heartbeat isolation function is not enabled, the resources allocated for the heartbeat processing process are directly released;
[0113] (5) Continue with the subsequent CTDB service stop process.
[0114] In summary, combined Figures 2 to 5 Can get Figure 6 , Figure 6 A logical view of a heartbeat isolation function provided by the present application. It can be seen that the cluster node monitoring method provided in the embodiment of the present application realizes cluster node monitoring by creating a main thread, a heartbeat monitoring thread and a transmission thread, uses the heartbeat monitoring thread for heartbeat detection, uses the transmission thread for signal transmission, and uses the main thread to update the node status, which is equivalent to dividing the original main service process in the cluster node into three independent threads, namely the main thread, the heartbeat monitoring thread and the transmission thread, realizing the heartbeat isolation function of the cluster system, avoiding the problem of excessive load pressure on the main service process caused by concentrating all operation contents on the main service process, and thus avoiding the impact on the cluster business, thereby ensuring the normal operation of the cluster business; and, it can also effectively improve the robustness and ease of use of the cluster system and improve the competitiveness of the product.
[0115] An embodiment of the present application provides a cluster node monitoring device.
[0116] Please refer to Figure 7 , Figure 7 This is a schematic diagram of the structure of a cluster node monitoring device provided by the present application. The cluster node monitoring device can be applied to each node in the cluster system, including:
[0117] The signal initiation module 1 is used to initiate a heartbeat signal using a heartbeat monitoring thread;
[0118] Signal transmission module 2, used to send heartbeat signals to other nodes in the cluster system using a transmission thread, and receive reply signals fed back by other nodes;
[0119] Status monitoring module 3, used to determine the offline nodes in the cluster system according to each reply signal using the heartbeat monitoring thread, and upload the corresponding offline node information to the main thread;
[0120] The status update module 4 is used to use the main thread to perform node status update operations according to offline node information.
[0121] It can be seen that the cluster node monitoring device provided in the embodiment of the present application realizes cluster node monitoring by creating a main thread, a heartbeat monitoring thread and a transmission thread, uses the heartbeat monitoring thread to perform heartbeat detection, uses the transmission thread to perform signal transmission, and uses the main thread to update the node status, which is equivalent to dividing the original main service process in the cluster node into three independent threads, namely the main thread, the heartbeat monitoring thread and the transmission thread, thereby realizing the heartbeat isolation function of the cluster system, avoiding the problem of excessive load pressure on the main service process caused by concentrating all operation content on the main service process, and thus avoiding the impact on the cluster business, thereby ensuring the normal operation of the cluster business; and it can also effectively improve the robustness and usability of the cluster system and improve the competitiveness of the product.
[0122] In one embodiment of the present application, the signal initiating module 1 may be specifically used to initiate a heartbeat signal at a preset time interval using a heartbeat monitoring thread.
[0123] In one embodiment of the present application, the above-mentioned status monitoring module 3 can be specifically used to determine that the corresponding node is an offline node when the number of times that the reply signal is not received reaches a preset number.
[0124] In one embodiment of the present application, the above-mentioned status update module 4 can be specifically used to send offline node information to the recovery process by using the main thread, so that the recovery process performs a node status update operation.
[0125] In one embodiment of the present application, the cluster node monitoring device may also include a thread startup module, which is used to read a preset configuration file according to the monitoring instruction when a monitoring instruction is received before the heartbeat signal is initiated by the heartbeat monitoring thread mentioned above; determine whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file; if so, start the heartbeat monitoring thread and the transmission thread.
[0126] In one embodiment of the present application, the cluster node monitoring device may also include a thread exit module, which is used to read a preset configuration file according to the monitoring exit instruction when a monitoring exit instruction is received; determine whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file; if so, close the heartbeat monitoring thread and the transmission thread.
[0127] In one embodiment of the present application, the cluster node monitoring device may further include a resource release module, which is used to release the pre-allocated resources of the heartbeat monitoring thread and the pre-allocated resources of the transmission thread after the heartbeat monitoring thread and the transmission thread are closed.
[0128] For an introduction to the device provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0129] An embodiment of the present application provides an electronic device.
[0130] Please refer to Figure 8 , Figure 8 This is a schematic diagram of the structure of an electronic device provided in this application, and the electronic device may include:
[0131] Memory for storing computer programs;
[0132] The processor is used to implement the steps of any one of the above-mentioned cluster node monitoring methods when executing a computer program.
[0133] like Figure 8 , which is a schematic diagram of the composition structure of an electronic device, the electronic device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through the communication bus 13.
[0134] In the embodiment of the present application, the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic devices, etc.
[0135] The processor 10 may call a program stored in the memory 11. Specifically, the processor 10 may execute operations in an embodiment of the cluster node monitoring method.
[0136] The memory 11 is used to store one or more programs, which may include program codes, and the program codes include computer operation instructions. In the embodiment of the present application, the memory 11 at least stores programs for implementing the following functions:
[0137] Use the heartbeat monitoring thread to initiate a heartbeat signal;
[0138] Use the transmission thread to send heartbeat signals to other nodes in the cluster system and receive reply signals from other nodes;
[0139] Use the heartbeat monitoring thread to determine the offline nodes in the cluster system according to each reply signal, and upload the corresponding offline node information to the main thread;
[0140] Use the main thread to perform node status update operations based on offline node information.
[0141] In a possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.
[0142] In addition, the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.
[0143] The communication interface 12 may be an interface of a communication module, and is used to connect to other devices or systems.
[0144] Of course, it should be noted that Figure 8 The structure shown does not constitute a limitation on the electronic device in the embodiment of the present application. In actual applications, the electronic device may include Figure 8 More or fewer components than shown, or combinations of certain components.
[0145] An embodiment of the present application provides a computer-readable storage medium.
[0146] The computer-readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned cluster node monitoring methods can be implemented.
[0147] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0148] For an introduction to the computer-readable storage medium provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.
[0149] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various 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 description.
[0150] 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.
[0151] 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.
[0152] The technical solution provided by the present application is described in detail above. The principle and implementation method of the present application are described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A cluster node monitoring method, characterized in that: Applied to each node in the cluster system, the method includes: Use the heartbeat monitoring thread to initiate a heartbeat signal; Using a transmission thread to send the heartbeat signal to other nodes in the cluster system, and receiving reply signals fed back by other nodes; Utilizing the heartbeat monitoring thread to determine the offline nodes in the cluster system according to each of the reply signals, and uploading the corresponding offline node information to the main thread; Utilizing the main thread to perform a node status update operation according to the offline node information; wherein the node status update operation includes updating the status information of the offline node to an offline status, and updating the status information of the online node to an online status; The initiating the heartbeat signal by using the heartbeat monitoring thread comprises: initiating the heartbeat signal by using the heartbeat monitoring thread at a preset time interval; The using the heartbeat monitoring thread to determine the offline nodes in the cluster system according to each of the reply signals includes: comparing the node information in each of the reply signals with the self-maintained node information, so as to regard the node that has not received the reply signal for a preset number of times as the offline node; The using the main thread to perform the node status update operation according to the offline node information includes: using the main thread to send the offline node information to the recovery process, so that the recovery process performs the node status update operation; Before the heartbeat monitoring thread is used to initiate a heartbeat signal, it also includes: when a monitoring instruction is received, a preset configuration file is read according to the monitoring instruction; whether the heartbeat monitoring function is turned on is determined according to the configuration information in the preset configuration file; if so, the heartbeat monitoring thread and the transmission thread are started; wherein the preset configuration file is used to set the cluster node monitoring mode, when the heartbeat monitoring function is turned on, the cluster node monitoring mode is a cluster node monitoring based on multi-threading; when the heartbeat monitoring function is turned off, the cluster node monitoring mode is a cluster node monitoring based on the main service process; the cluster node monitoring based on multi-threading is used to divide the main service process into the heartbeat monitoring thread, the transmission thread, and the main thread to realize cluster node monitoring, and the heartbeat monitoring thread, the transmission thread, and the main thread are independent of each other; The method further comprises: when receiving a monitoring exit instruction, reading a preset configuration file according to the monitoring exit instruction; judging whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file; and if so, closing the heartbeat monitoring thread and the transmission thread; After closing the heartbeat monitoring thread and the transmission thread, the method further includes: releasing pre-allocated resources of each thread obtained by dividing the main service process.
2. A cluster node monitoring device, characterized in that: Applied to each node in a cluster system, the device comprises: A signal initiation module is used to initiate a heartbeat signal using a heartbeat monitoring thread; A signal transmission module, used to send the heartbeat signal to other nodes in the cluster system by using a transmission thread, and receive reply signals fed back by other nodes; A status monitoring module, used to determine the offline nodes in the cluster system according to each of the reply signals using the heartbeat monitoring thread, and upload the corresponding offline node information to the main thread; A status update module, used to use the main thread to perform a node status update operation according to the offline node information; wherein the node status update operation includes updating the status information of the offline node to an offline state and updating the status information of the online node to an online state; A thread startup module is used to read a preset configuration file according to the monitoring instruction when receiving a monitoring instruction before the heartbeat monitoring thread initiates a heartbeat signal; determine whether the heartbeat monitoring function is turned on according to the configuration information in the preset configuration file; if so, start the heartbeat monitoring thread and the transmission thread; A thread exit module, which is used to read a preset configuration file according to the monitoring exit instruction when a monitoring exit instruction is received; determine whether the heartbeat monitoring function is enabled according to the configuration information in the preset configuration file; if so, close the heartbeat monitoring thread and the transmission thread; wherein the preset configuration file is used to set the cluster node monitoring mode, when the heartbeat monitoring function is enabled, the cluster node monitoring mode is a cluster node monitoring based on multi-threading; when the heartbeat monitoring function is disabled, the cluster node monitoring mode is a cluster node monitoring based on a main service process; the multi-threaded cluster node monitoring is used to divide the main service process into the heartbeat monitoring thread, the transmission thread, and the main thread to implement cluster node monitoring, and the heartbeat monitoring thread, the transmission thread, and the main thread are independent of each other; A resource release module, used for releasing the pre-allocated resources of each thread obtained by dividing the main service process after closing the heartbeat monitoring thread and the transmission thread; The signal initiation module is specifically used to utilize the heartbeat monitoring thread to initiate the heartbeat signal at a preset time interval; The state monitoring module is specifically used to compare the node information in each reply signal with the self-maintained node information, so as to regard the node that has not received the reply signal for a preset number of times as the offline node; The status update module is specifically used to send the offline node information to the recovery process by using the main thread, so that the recovery process performs the node status update operation.
3. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to implement the steps of the cluster node monitoring method as claimed in claim 1 when executing the computer program.
4. 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 steps of the cluster node monitoring method according to claim 1 are implemented.
Citation Information
Patent Citations
ICFS cluster network card monitoring method, device, equipment and medium
CN110933142A
Method for optimizing screen projection process response
CN113965496A