Cluster service restarting method and device, electronic equipment and storage medium
By obtaining and detecting the node information and restarting conditions of the cluster service, restarting the supervisor node and detecting the managed node, the problems of cluster service restart failure and instability are solved, and the success rate and efficiency are improved.
Patent Information
- Application Number
- CN202411064940.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-11-26
AI Technical Summary
The existing technology cannot effectively guarantee the success rate and stability of cluster services after restarting, resulting in restart failure and unstable operation.
By obtaining the node information associated with the cluster service to be restarted and the pre-restart conditions, restart the supervisor node, and perform pre-restart detection and operation status detection on the managed node based on these conditions to ensure that the managed node passes and then restart the cluster service before restarting the cluster service based on these conditions. .
It improves the success rate and stability of cluster service restarts, ensuring normal operation and efficiency after restart.
Smart Images

Figure CN119025335A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer automation cluster technology, and in particular to a cluster service restart method, device, electronic device and storage medium. Background Art
[0002] In the prior art, during the operation of cluster services, automatic restart or scheduled restart tools can usually be used to ensure the normal operation of cluster services. However, the prior art cannot effectively ensure the normal operation of cluster services after restart, and the success rate and stability of cluster service startup are low. Summary of the invention
[0003] The present disclosure provides a cluster service restart method, device, electronic device and storage medium to solve the problem of how to improve the success rate of cluster service restart and the stability after restart.
[0004] According to one aspect of the present disclosure, a cluster service restart method is provided, comprising:
[0005] Obtaining node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service;
[0006] Restarting the supervisor node;
[0007] Based on the pre-restart condition, performing a pre-restart detection on the managed node, and detecting the running state of the managed node after startup;
[0008] When the managed node passes the detection, the cluster service to be restarted is restarted.
[0009] According to another aspect of the present disclosure, a cluster service restarting device is provided, comprising:
[0010] An acquisition module, used to acquire node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service;
[0011] A first restart module, used to restart the supervisor node;
[0012] A detection module, configured to perform a pre-restart detection on the managed node based on the pre-restart condition, and detect the running state of the managed node after startup;
[0013] The second restart module is used to restart the cluster service to be restarted if the managed node passes the detection.
[0014] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0015] at least one processor;
[0016] and, a memory communicatively coupled to the at least one processor;
[0017] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute the method of the above embodiment.
[0018] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method according to the above embodiment.
[0019] The present disclosure provides a cluster service restart method, device, electronic device and storage medium. First, the node information and pre-restart conditions associated with the cluster service to be restarted are obtained, and the supervisor node is restarted. Then, based on the pre-restart conditions, a pre-restart detection is performed on the managed nodes, and the running status of the managed nodes after startup is detected. Finally, if the managed nodes pass the detection, the cluster service to be restarted is restarted. Thus, by performing a pre-restart detection on the managed nodes based on the pre-restart conditions of the cluster service to be restarted, and detecting the running status of the managed nodes after startup, and restarting the cluster service if the managed nodes pass the detection, the success rate of cluster service restart is improved, and the normal operation and stability of the restarted cluster service are effectively guaranteed, thereby improving the efficiency of cluster service restart. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0021] Figure 1 A schematic diagram of a process for restarting a cluster service provided by an embodiment of the present disclosure;
[0022] Figure 2 A schematic diagram of a process for restarting a cluster service provided by an embodiment of the present disclosure;
[0023] Figure 3 A schematic diagram of a process for restarting a cluster service provided by an embodiment of the present disclosure;
[0024] Figure 4 A schematic diagram of a process for restarting a cluster service provided by an embodiment of the present disclosure;
[0025] Figure 5A schematic diagram of a process for restarting a cluster service provided by an embodiment of the present disclosure;
[0026] Figure 6 A schematic diagram of the structure of a cluster service restart device provided by an embodiment of the present disclosure;
[0027] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure.
[0028] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0030] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0031] It should be noted that the acquisition, transmission, storage, use, and processing of data in the technical solution disclosed in this disclosure are in compliance with the relevant provisions of national laws and regulations.
[0032] The method for restarting a cluster service according to an embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0033] Figure 1 A schematic diagram of a process for restarting a cluster service provided in an embodiment of the present disclosure.
[0034] like Figure 1 As shown, the method includes:
[0035] Step 101: Obtain node information and pre-restart conditions associated with a cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service.
[0036] Among them, the pre-restart condition can be any external condition that the cluster service to be restarted depends on. For example, when the cluster service to be restarted needs to use services such as database, full platform, message queue (MQ), etc., then the pre-restart condition of the cluster service to be restarted can be whether the database, full platform, message queue and other services can be connected, etc., and this disclosure does not limit this.
[0037] It should be noted that, for different cluster services to be restarted, the corresponding pre-restart conditions may be different, or may be the same, and this disclosure does not limit this.
[0038] The managed node may be a processing unit used to restart the cluster service.
[0039] It should be noted that, for different cluster services to be restarted, their associated managed nodes may be different or may be the same, and this disclosure does not limit this.
[0040] It should be noted that the supervisor node associated with the cluster service can be used to manage the managed nodes associated with the cluster service. For example, the supervisor node can determine the restart time and restart sequence of the managed nodes, and the present disclosure does not limit this.
[0041] In the present disclosure, after obtaining the cluster service to be restarted, the number of servers required for the cluster service can be determined first according to the production conditions such as the business volume of the cluster service, and the server can be configured for the cluster service. Then, according to the server assigned to the cluster service, the identification of the cluster service can be obtained, wherein the identification of the cluster service can be the address of the assigned server, for example, in the Linux operating system, the Internet Protocol (IP) address of the server can be obtained through the ifconfig command, and the IP address of the server can be used as the identification of the cluster service, etc., which is not limited in the present disclosure. Then, based on the identification of the cluster service, the configuration file of the server corresponding to the identification is queried, and the node information corresponding to the identification is obtained as the node information associated with the cluster service.
[0042] It should be noted that the node information may also include a node identifier of each node, an address of a server to which the node belongs, a port address of the node, etc., which is not limited in the present disclosure.
[0043] The node identifier can be used to characterize the node type, and can be in any pre-set form. For example, the node identifier can be a node name, etc., which is not limited in the present disclosure.
[0044] It should be noted that different node types may have different corresponding node identifiers. For example, the node identifier of a supervisor node may be an identifier beginning with "Admin", and the node identifier of a managed node may be an identifier beginning with "Managed", etc. This disclosure does not limit this.
[0045] It should be noted that, for different cluster services to be restarted, the number of servers allocated thereto may be different or may be the same, and this disclosure does not limit this.
[0046] It should be noted that, since the node information pre-configured in each server may be different, the node information associated with the cluster service may be determined by the node information in the assigned server. For example, if a cluster service is assigned to a server, and a managed node is pre-configured on the server, then the node information associated with the cluster service may include the information of the managed node, etc., and the present disclosure does not limit this.
[0047] It should be noted that when a cluster service is allocated to multiple servers, since the number of supervisor nodes associated with the cluster service is only one, the supervisor node can be on any server among the multiple servers, and the present disclosure does not limit this.
[0048] Step 102, restart the supervisor node.
[0049] In the present disclosure, after obtaining the node information associated with the cluster service to be restarted and the pre-restart condition, a preset script for restarting the cluster service can be automatically executed based on the preset restart time of the cluster service to restart the supervisor node of the cluster service.
[0050] The restart time of the cluster service may be a specific time for restarting the cluster service, or a periodic restart time, which may be pre-set, or may be configured according to the production situation of the cluster service. For example, the restart time of the cluster service may be any specific time on a certain day of a certain month of a certain year, or may be based on a week as a cycle, with any specific time on the xth day of each week as the restart time, etc., and the present disclosure does not limit this.
[0051] In the present disclosure, after obtaining the node information associated with the cluster service to be restarted, the supervisor node of the cluster service can be first determined based on the node identifier included in the node information. For example, the node corresponding to the node identifier starting with "Admin" is the supervisor node. Then, the supervisor node process is started by calling the preset startup script corresponding to the supervisor node, such as the startAdmin.sh script, to restart the supervisor node. The present disclosure does not limit this.
[0052] In the present disclosure, after restarting the supervisor node, the running status of the supervisor node can also be detected. When the running status of the supervisor node reports an error, the supervisor node needs to be restarted. When the number of restarts of the supervisor node is less than or equal to the preset supervisor node restart number threshold, the supervisor node can be restarted until the running status detection of the supervisor node passes, or when the number of restarts of the supervisor node is greater than the preset supervisor node restart number threshold, based on the identifier of the supervisor node, the process number corresponding to the supervisor node is determined, and the restart of the supervisor node is stopped by stopping the operation of the supervisor node process, and the restart operation of the cluster service to be restarted is terminated until the next restart time of the cluster service to be restarted is reached, and the supervisor node is restarted again. The present disclosure does not limit this.
[0053] The supervisor node restart times threshold may be any preset times, for example, the supervisor node restart times threshold may be 3, etc., which is not limited in the present disclosure.
[0054] Step 103: Based on the pre-restart condition, a pre-restart detection is performed on the managed node, and the running state of the managed node after startup is detected.
[0055] The pre-restart condition may be any external service condition that the cluster service depends on. For example, the pre-restart condition may be an external system, tool, component, or disk space capacity that the cluster service depends on, and the present disclosure does not limit this.
[0056] In the present disclosure, after restarting the supervisor node, in order to ensure the normal startup of the cluster service, a pre-restart detection can be performed on the managed node based on the restart time of the managed node determined by the supervisor node and the pre-start condition of the cluster service by detecting the connection status or disk space capacity of the external service that the cluster service depends on. After the managed node passes the pre-restart detection, the managed node is restarted. In order to effectively ensure the availability of the cluster service after startup, the running status of the managed node after startup can also be detected.
[0057] It should be noted that when the managed node passes the pre-restart detection, the process of the managed node can be started by calling the preset startup script corresponding to the managed node, for example, calling the ManagedServer+port number.sh script corresponding to the managed node, where the port number is the port number corresponding to the managed node, and this disclosure does not limit this.
[0058] It should be noted that after the managed node passes the pre-restart detection, the thread snapshot of the managed node can also be collected, thereby providing a data basis for understanding the running status of the system, which is not limited in the present disclosure.
[0059] Step 104: When the managed node passes the detection, the cluster service to be restarted is restarted.
[0060] In the present disclosure, when the managed node passes the pre-restart detection and the running status detection after startup, it can be considered that the prerequisites for the successful startup of the cluster service to be restarted are met, and the normal operation of the cluster service after the restart can be effectively guaranteed. At this time, the cluster service can be restarted on the managed node.
[0061] In the disclosed embodiment, the node information and pre-restart conditions associated with the cluster service to be restarted are first obtained, and the supervisor node is restarted. Then, based on the pre-restart conditions, a pre-restart detection is performed on the managed nodes, and the running status of the managed nodes after startup is detected. Finally, if the managed nodes pass the detection, the cluster service to be restarted is restarted. Thus, by performing a pre-restart detection on the managed nodes based on the pre-restart conditions of the cluster service to be restarted, and detecting the running status of the managed nodes after startup, and restarting the cluster service if the managed nodes pass the detection, the success rate of cluster service restart is improved, and the normal operation and stability of the restarted cluster service is effectively guaranteed, thereby improving the efficiency of cluster service restart.
[0062] Figure 2 A schematic diagram of a process for restarting a cluster service provided in an embodiment of the present disclosure.
[0063] like Figure 2 As shown, the method includes:
[0064] Step 201: Obtain node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service.
[0065] Step 202, restart the supervisor node.
[0066] The specific implementation forms of step 201 to step 202 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0067] Step 203: Obtain the service port associated with the cluster service to be restarted.
[0068] The service port associated with the cluster service may be a port of an external service that the cluster service depends on. For example, when the cluster service to be restarted needs to use a database, its associated service port may include a port of the database, etc., which is not limited in the present disclosure.
[0069] In the present disclosure, in order to improve the success rate of cluster service restart, the pre-restart condition associated with the cluster service may be first obtained, and based on the pre-restart condition, the service port associated with the cluster service may be determined.
[0070] It should be noted that the pre-restart conditions associated with cluster services are different, and the service ports associated with them may be different, which is not limited in this disclosure.
[0071] It should be noted that the number of service ports associated with a cluster service may be one or more. The number of service ports associated with a cluster service may be determined by the number of external services that the cluster service depends on, and this disclosure does not limit this.
[0072] Step 204: Detect the connection status of the service port.
[0073] In the present disclosure, after determining the service port associated with the cluster service, the connection status of the service port associated with the cluster service can be detected. For example, Telnet dialing can be used to simulate the connection to detect whether the service port associated with the cluster service is connected, etc. Telnet is the abbreviation of the Teletype network (Telnet) protocol, and the present disclosure does not limit this.
[0074] Step 205: When the service port is in a connected state, determine that the managed node passes the pre-restart detection, and restart the managed node.
[0075] In the present disclosure, after detecting the connection status of the service port associated with the cluster service, if the service port is in a connected state, it can be considered that the external service that the cluster service depends on can be connected, satisfying the restart preconditions of the cluster service. At this time, it can be determined that the managed node has passed the pre-restart detection and the managed node can be restarted.
[0076] It should be noted that after detecting the connection status of the service port associated with the cluster service, any basic environment such as the disk space capacity may also be detected, thereby improving the success rate of cluster service restart.
[0077] Optionally, when the service port is in a disconnected state, or when any basic environment does not meet the conditions for the successful restart of the cluster service, such as when the disk space is full, it can be determined that the managed node has not passed the pre-restart detection. At this time, in order to improve the success rate and efficiency of the cluster service restart, the restart operation of the cluster service can be terminated until the next restart time of the cluster service is reached, and the operation of restarting the supervisor node is returned. The present disclosure does not limit this.
[0078] Step 206: Detect the running status of the managed node after startup.
[0079] Step 207: When the managed node passes the detection, the cluster service to be restarted is restarted.
[0080] The specific implementation forms of step 206 to step 207 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0081] In the disclosed embodiment, the node information and pre-restart conditions associated with the cluster service to be restarted are first obtained, and the supervisor node is restarted. Then, the service port associated with the cluster service to be restarted is obtained, and the connection status of the service port is detected. When the service port is in a connected state, it is determined that the managed node passes the pre-restart detection, and the managed node is restarted. Then, the running status of the managed node after startup is detected, and finally, when the managed node passes the detection, the cluster service to be restarted is restarted. Thus, by performing a pre-restart detection on the managed node based on the connection status of the service port associated with the cluster service, and then detecting the running status of the managed node after startup, the success rate of cluster service restart is improved on the basis of effectively ensuring the stability of the operation of the cluster service after restart.
[0082] Figure 3 A schematic diagram of a process for restarting a cluster service provided in an embodiment of the present disclosure.
[0083] like Figure 3 As shown, the method includes:
[0084] Step 301: Obtain node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes the supervisor node and the managed node associated with the cluster service.
[0085] Step 302, restart the supervisor node.
[0086] Step 303: Perform a pre-restart detection on the managed node based on the pre-restart condition.
[0087] Step 304: When it is determined that the managed node passes the pre-restart detection, restart the managed node.
[0088] The specific implementation forms of steps 301 to 304 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0089] Step 305: Obtain logs associated with the managed node.
[0090] In the present disclosure, when it is determined that the managed node passes the pre-restart detection, after restarting the managed node, the managed node can output its associated log when restarting. In order to detect the running status of the managed node after startup, the log associated with the managed node can be obtained first.
[0091] It should be noted that different managed nodes may have different associated logs, and this disclosure does not limit this.
[0092] Step 306: Check the restart completion time in the log and / or the error field associated with the preset abnormal keyword.
[0093] The restart completion time may be the time when the managed node completes the restart.
[0094] The abnormal keyword may be a field used to characterize the running status of the managed node during startup, and may be a pre-set field in any form, which is not limited in the present disclosure.
[0095] In some possible implementation forms, the preset abnormal keywords may include the following: Error, Emergency, Critical, etc., which is not limited in the present disclosure.
[0096] In the present disclosure, in order to effectively ensure the availability and stability of the cluster service after restart, the restart completion time in the log associated with the managed node and / or the error field associated with the preset abnormal keyword can be detected.
[0097] It should be noted that when detecting the restart completion time in the log, the restart completion time of the managed node can be determined by calling a preset function and obtaining the status of the managed node multiple times at regular intervals. The preset function can be any function for obtaining the status of the managed node, for example, it can be the getServerRuntimes() function of the application server scripting tool (WebLogic Scripting Tool, WLST) of the application server (WebLogic), wherein the status of the managed node can be obtained regularly based on a preset time period, and the present disclosure does not limit this.
[0098] Step 307: if the restart completion time in the log is less than or equal to the restart time threshold, and the log associated with the managed node does not contain an error field associated with the abnormal keyword, it is determined that the managed node passes the post-startup running status detection.
[0099] The restart time threshold may be a restart time critical value when the managed node completes the restart, and may be any pre-set time threshold, which is not limited in the present disclosure.
[0100] In the present disclosure, after detecting the restart completion time in the log associated with the cluster service, and / or the error field associated with the abnormal keyword in the log, when the restart completion time in the log is less than or equal to the restart time threshold, and the log does not contain the error field associated with the abnormal keyword, it can be considered that the managed node has completed the restart within the specified time, and the managed node runs normally during the startup process. At this time, it can be determined that the managed node has passed the post-startup running status detection.
[0101] Step 308: When the managed node passes the detection, the cluster service to be restarted is restarted.
[0102] The specific implementation form of step 308 can refer to the detailed description in other embodiments of the present disclosure, and will not be described in detail here.
[0103] In the disclosed embodiment, firstly, the node information and pre-restart conditions associated with the cluster service to be restarted are obtained, and the supervisor node is restarted. Then, based on the pre-restart conditions, the pre-restart detection is performed on the managed node. When it is determined that the managed node passes the pre-restart detection, the managed node is restarted. The log associated with the managed node is obtained, and the restart completion time in the log and / or the error field associated with the preset abnormal keyword are detected. When the restart completion time in the log is less than or equal to the restart time threshold, and the log associated with the managed node does not contain the error field associated with the abnormal keyword, it is determined that the managed node passes the post-startup running status detection. Finally, when the managed node passes the detection, the cluster service to be restarted is restarted. Thus, by performing the pre-restart detection on the managed node, and detecting the restart completion time in the log associated with the restarted managed node and / or the error field associated with the abnormal keyword, when the managed node passes the detection, the cluster service is restarted, thereby effectively ensuring the normal operation and stability of the restarted cluster service on the basis of improving the success rate and efficiency of the cluster service restart.
[0104] Figure 4 A schematic diagram of a process for restarting a cluster service provided in an embodiment of the present disclosure.
[0105] like Figure 4 As shown, the method includes:
[0106] Step 401: Obtain node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service.
[0107] Step 402, restart the supervisor node.
[0108] Step 403: Perform a pre-restart detection on the managed node based on the pre-restart condition.
[0109] Step 404: if it is determined that the managed node passes the pre-restart detection, restart the managed node.
[0110] Step 405: Obtain logs associated with the managed node.
[0111] Step 406: Check the restart completion time in the log and / or the error field associated with the preset abnormal keyword.
[0112] The specific implementation forms of steps 401 to 406 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0113] Step 407: if the restart completion time in the log is greater than the restart time threshold, and / or the log associated with the managed node contains an error field associated with the abnormal keyword, it is determined that the managed node fails the post-startup running status detection.
[0114] In the present disclosure, when the restart completion time in the log is greater than the restart time threshold, it can be considered that the managed node has not completed the restart within the specified time and the restart of the managed node is abnormal. At this time, it can be determined that the managed node has not passed the post-startup running status detection.
[0115] In the present disclosure, when the log associated with the managed node contains an error field associated with the abnormal keyword, it can be considered that an error occurs in the operation of the managed node during the restart process. At this time, it can be determined that the managed node has failed the post-startup operation status monitoring.
[0116] It should be noted that when the restart completion time in the log is greater than the restart time threshold, or the log contains an error field associated with the abnormal keyword, when either of these two situations appears in the log, it can be determined that the managed node has failed the post-startup operating status monitoring. The present disclosure does not limit this.
[0117] Step 408: If it is determined that the managed node fails the post-startup running status detection, determine whether to restart the managed node based on the relationship between the number of restarts associated with the managed node and the restart number threshold.
[0118] The restart count threshold may be a restart count critical value used to determine whether the managed node can be restarted, and may be any preset restart count threshold. For example, the restart count threshold may be 3, etc., which is not limited in the present disclosure.
[0119] It should be noted that the restart count threshold of the managed node may be the same as the restart count threshold of the supervisor node, or may be different from the restart count threshold of the supervisor node, and the present disclosure does not limit this.
[0120] In the present disclosure, when it is determined that the managed node fails the operation status detection after startup, the number of times the managed node has been restarted can be obtained first, and based on the relationship between the number of times the managed node has been restarted and the restart number threshold, it is determined whether to restart the managed node.
[0121] Step 409: When the number of restarts is less than or equal to the restart number threshold, the managed node is restarted again, and the operation of detecting the running status of the managed node after startup is returned to be executed.
[0122] In the present disclosure, when the number of restarts is less than or equal to the restart number threshold, the managed node may be restarted, and the running status of the restarted managed node may be re-detected.
[0123] Optionally, when the number of restarts is greater than the restart threshold, in order to improve the efficiency of cluster service restart, the corresponding process number can be determined based on the identification of the managed node, and then the restart operation of the managed node can be stopped by stopping the process of the managed node, and the restart operation of the cluster service is terminated until the next restart time of the cluster service is reached, and then the operation of restarting the supervisor node is returned to execute.
[0124] It should be noted that before stopping the restart operation on the managed node, you can also collect a thread snapshot corresponding to the managed node so that relevant personnel can quickly locate the cause of the managed node restart failure, which provides conditions for improving the efficiency of cluster service restart.
[0125] In the disclosed embodiment, firstly, the node information and pre-restart conditions associated with the cluster service to be restarted are obtained, and the supervisor node is restarted. Then, based on the pre-restart conditions, a pre-restart detection is performed on the managed node. When it is determined that the managed node passes the pre-restart detection, the managed node is restarted. The log associated with the managed node is obtained, and the restart completion time in the log and / or the error field associated with the preset abnormal keyword are detected. When the restart completion time in the log is greater than the restart time threshold, and / or the log associated with the managed node contains the error field associated with the abnormal keyword, it is determined that the managed node has not passed the post-startup running status detection. When it is determined that the managed node has not passed the post-startup running status detection, based on the relationship between the number of restarts associated with the managed node and the restart number threshold, it is determined whether to restart the managed node again. Finally, when the number of restarts is less than or equal to the restart number threshold, the managed node is restarted again, and the operation of detecting the running status of the managed node after startup is returned. Therefore, by performing a pre-restart detection on the managed node and detecting the operating status of the managed node after the restart, if it is determined that the managed node has not passed the operating status detection after startup, based on the relationship between the number of restarts associated with the managed node and the restart number threshold, it is determined whether to restart the managed node again, thereby improving the success rate and efficiency of cluster service restart.
[0126] Figure 5 A schematic diagram of a process for restarting a cluster service provided in an embodiment of the present disclosure.
[0127] like Figure 5 As shown, the method includes:
[0128] Step 501: Obtain node information and pre-restart conditions associated with a cluster service to be restarted, wherein the node information includes a supervisor node and a plurality of managed nodes associated with the cluster service.
[0129] In the present disclosure, when the cluster service to be restarted is assigned to multiple servers, the number of managed nodes associated therewith may be multiple and may be distributed on each server. Alternatively, when the cluster service to be restarted is assigned to one server, multiple managed nodes are pre-configured in the server, and the number of managed nodes associated with the cluster service may be the number of managed nodes of the server, which is not limited in the present disclosure.
[0130] It should be noted that when a cluster service is assigned multiple servers, the cluster service can have multiple identifiers, which can be the IP addresses of each server respectively. Then, based on the pre-configured node information in the server associated with each identifier, the node information associated with each identifier is determined. This disclosure does not limit this.
[0131] It should be noted that the node information pre-configured in each server may be different, and the node information associated with the identifier corresponding to the cluster service may be different, which is not limited in the present disclosure.
[0132] Step 502, restart the supervisor node.
[0133] The specific implementation form of step 502 can refer to the detailed description in other embodiments of the present disclosure, and will not be described in detail here.
[0134] Step 503: According to the restart sequence of each managed node contained in the node information, a pre-restart detection and a post-startup running status detection are sequentially performed on each managed node.
[0135] In the present disclosure, when there are multiple managed nodes associated with the cluster service, a pre-restart detection and a post-startup running status detection may be performed on each managed node in turn based on the restart order of each managed node determined by the supervisor node.
[0136] It should be noted that when there are multiple managed nodes associated with a cluster service, since the restart time of each managed node is uncertain, the connection status of the external services that the cluster service depends on may change. In order to ensure that the cluster service can be successfully started, it is necessary to perform a pre-restart check on each managed node. Among them, the pre-restart conditions based on which each managed node performs the pre-restart check are the same, and the present disclosure does not limit this.
[0137] It should be noted that when there are multiple managed nodes associated with a cluster service and these multiple managed nodes are distributed on different servers, when performing pre-restart detection and post-startup running status detection on each managed node, for the managed nodes located on the same server, each managed node can be detected in turn based on the restart order of each managed node, and for the managed nodes located on different servers, the managed nodes on different servers can be detected in parallel. The present disclosure does not limit this.
[0138] Step 504: When each managed node included in the node information passes the detection in sequence, restart the cluster service on the corresponding managed node until the cluster service is restarted on each managed node.
[0139] In the present disclosure, when each managed node included in the node information associated with the cluster service passes the detection in turn, the cluster service can be restarted on the corresponding managed node until the cluster service is restarted on each managed node. At this time, it can be considered that the cluster service restart is completed.
[0140] In the disclosed embodiment, the node information and pre-restart conditions associated with the cluster service to be restarted are first obtained, and the supervisor node is restarted. Then, according to the restart order of each managed node contained in the node information, a pre-restart detection and a post-startup running status detection are performed on each managed node in turn. Finally, when each managed node contained in the node information passes the detection in turn, the cluster service is restarted on the corresponding managed node until the cluster service is restarted on each managed node. Thus, by performing a pre-restart detection and a post-startup running status detection on each managed node associated with the cluster service, when each managed node passes the detection in turn, the cluster service is restarted on the corresponding managed node until the cluster service is restarted on each managed node, thereby improving the success rate and efficiency of cluster service restart and improving the stability of cluster service operation after restart.
[0141] In order to implement the above embodiment, the embodiment of the present disclosure further proposes a cluster service restart device.
[0142] Figure 6 A schematic diagram of the structure of a cluster service restart device provided in an embodiment of the present disclosure.
[0143] like Figure 6 As shown, the cluster service restart device 600 may include:
[0144] The acquisition module 601 is used to acquire node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes the supervisor node and the managed node associated with the cluster service;
[0145] A first restart module 602, used to restart the supervisor node;
[0146] The detection module 603 is used to perform a pre-restart detection on the managed node based on the pre-restart condition, and detect the running state of the managed node after startup;
[0147] The second restart module 604 is configured to restart the cluster service to be restarted if the managed node passes the detection.
[0148] Optionally, the node information includes a plurality of managed nodes, and the detection module 603 is specifically used to:
[0149] According to the restart sequence of each managed node contained in the node information, a pre-restart detection is performed on each managed node in turn.
[0150] Optionally, the detection module 603 is specifically used to:
[0151] Get the service port associated with the cluster service to be restarted;
[0152] Check the connection status of the service port.
[0153] Optionally, after detecting the connection status of the service port, the method further includes:
[0154] A first determination module (not shown in the figure) is used to determine that the managed node passes the pre-restart detection and restart the managed node when the service port is in a connected state; or
[0155] The second determination module (not shown in the figure) is used to determine that the managed node has not passed the pre-restart detection when the service port is in a disconnected state, terminate the restart operation of the cluster service until the next restart time of the cluster service is reached, and return to execute the operation of restarting the supervisor node.
[0156] Optionally, the detection module 603 is specifically used to:
[0157] Get the logs associated with the managed node;
[0158] The restart completion time in the log and / or the error field associated with the preset abnormal keyword are checked.
[0159] Optionally, after detecting the restart completion time in the log and / or the error field associated with the preset abnormal keyword, the method further includes:
[0160] A third determination module (not shown in the figure) is used to determine that the managed node passes the post-startup running status detection when the restart completion time in the log is less than or equal to the restart time threshold and the log associated with the managed node does not contain an error field associated with the abnormal keyword; or,
[0161] The fourth determination module (not shown in the figure) is used to determine that the managed node has failed the post-startup operation status detection when the restart completion time in the log is greater than the restart time threshold and / or the log associated with the managed node contains an error field associated with the abnormal keyword.
[0162] Optionally, after determining that the managed node fails the post-startup running status detection, the fourth determining module (not shown in the figure) is further configured to:
[0163] Determine whether to restart the managed node based on the relationship between the number of restarts associated with the managed node and the restart number threshold;
[0164] When the number of restarts is less than or equal to the restart number threshold, the managed node is restarted again, and the operation of detecting the running status of the managed node after startup is returned to be executed.
[0165] Optionally, after determining whether to restart the managed node based on the relationship between the number of restarts associated with the managed node and the restart number threshold, the fourth determination module (not shown in the figure) is further used to:
[0166] When the number of restarts is greater than the restart threshold, the restart operation on the managed node is stopped, and the restart operation on the cluster service is terminated until the next restart time of the cluster service is reached, and the operation of restarting the supervisor node is returned to be executed.
[0167] Optionally, the node information includes a plurality of managed nodes, and the second restart module 604 is specifically configured to:
[0168] When each managed node included in the node information passes the detection in sequence, the cluster service is restarted on the corresponding managed node until the cluster service is restarted on each managed node.
[0169] The functions and specific implementation principles of the above modules in the embodiments of the present disclosure can be referred to the above method embodiments, and will not be repeated here.
[0170] In the present disclosure, firstly, the node information and pre-restart conditions associated with the cluster service to be restarted are obtained, and the supervisor node is restarted. Then, based on the pre-restart conditions, a pre-restart detection is performed on the managed nodes, and the running status of the managed nodes after startup is detected. Finally, if the managed nodes pass the detection, the cluster service to be restarted is restarted. Thus, by performing a pre-restart detection on the managed nodes based on the pre-restart conditions of the cluster service to be restarted, and detecting the running status of the managed nodes after startup, and restarting the cluster service if the managed nodes pass the detection, the success rate of cluster service restart is improved, and the normal operation and stability of the restarted cluster service is effectively guaranteed, and the efficiency of cluster service restart is improved.
[0171] Figure 7 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown.
[0172] Figure 7 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0173] like Figure 7As shown, the electronic device 12 is in the form of a general computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, memory 28, and a bus 18 connecting different system components (including memory 28 and processing unit 16). The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any bus structure in a variety of bus structures. For example, these architectures include, but are not limited to, an Industry Standard Architecture (hereinafter referred to as: ISA) bus, a Micro Channel Architecture (hereinafter referred to as: MCA) bus, an Enhanced ISA bus, a Video Electronics Standards Association (hereinafter referred to as: VESA) local bus, and a Peripheral Component Interconnection (hereinafter referred to as: PCI) bus.
[0174] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0175] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 Not shown, often called a "hard drive").
[0176] although Figure 7Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present disclosure.
[0177] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described in the present disclosure.
[0178] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), may also communicate with one or more devices that enable the human body to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. In addition, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0179] The processing unit 16 executes various functional applications and parameter information determination by running the program stored in the memory 28, for example, implementing the cluster service restart method mentioned in the above embodiment.
[0180] In order to implement the above embodiments, the present disclosure further proposes a non-transitory computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the cluster service restart method proposed in the above embodiments of the present disclosure is implemented.
[0181] In order to implement the above embodiments, the present disclosure further proposes a computer program product. When an instruction processor in the computer program product is executed, the cluster service restart method proposed in the above embodiments of the present disclosure is executed.
[0182] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0183] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
[0184] It should be noted that, in the description of the present disclosure, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present disclosure, unless otherwise specified, the meaning of "plurality" is two or more.
[0185] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.
[0186] It should be understood that the various parts of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0187] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0188] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0189] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0190] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" 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 present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0191] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present disclosure.
Claims
1. A cluster service restart method, characterized in that: include: Obtaining node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service; Restarting the supervisor node; Based on the pre-restart condition, performing a pre-restart detection on the managed node, and detecting the running state of the managed node after startup; When the managed node passes the detection, the cluster service to be restarted is restarted.
2. The method according to claim 1, characterized in that The node information includes a plurality of managed nodes, and the pre-restart detection on the managed nodes includes: According to the restart sequence of each managed node contained in the node information, a pre-restart detection is performed on each managed node in turn.
3. The method according to claim 1, characterized in that The performing a pre-restart detection on the managed node based on the pre-restart condition includes: Obtain the service port associated with the cluster service to be restarted; The connection status of the service port is detected.
4. The method according to claim 3, characterized in that After detecting the connection status of the service port, the method further includes: When the service port is in a connected state, determining that the managed node passes the pre-restart detection, and restarting the managed node; or, When the service port is in a disconnected state, it is determined that the managed node has not passed the pre-restart detection, and the restart operation of the cluster service is terminated until the next restart time of the cluster service is reached, and the operation of restarting the supervisor node is returned to be executed.
5. The method according to claim 1, characterized in that The detecting the running status of the managed node after startup includes: Obtaining logs associated with the managed node; The restart completion time in the log and / or the error field associated with the preset abnormal keyword are detected.
6. The method according to claim 5, characterized in that After detecting the restart completion time in the log and / or the error field associated with the preset abnormal keyword, the method further includes: When the restart completion time in the log is less than or equal to the restart time threshold, and the log associated with the managed node does not contain an error field associated with the abnormal keyword, determining that the managed node passes the post-startup running status detection; or, When the restart completion time in the log is greater than the restart time threshold, and / or the log associated with the managed node contains an error field associated with the abnormal keyword, it is determined that the managed node fails the post-startup running status detection.
7. The method according to claim 6, characterized in that After determining that the managed node fails the post-startup running status detection, the method further includes: Determining whether to restart the managed node based on a relationship between a restart count associated with the managed node and a restart count threshold; In a case where the number of restarts is less than or equal to the restart number threshold, the managed node is restarted again, and the operation of detecting the running status of the managed node after startup is returned to be executed.
8. The method according to claim 7, characterized in that After determining whether to restart the managed node based on the relationship between the number of restarts associated with the managed node and the restart number threshold, the method further includes: When the number of restarts is greater than the restart number threshold, the restart operation on the managed node is stopped, and the restart operation on the cluster service is terminated until the next restart time of the cluster service is reached, and the operation of restarting the supervisor node is returned to be executed.
9. The method according to any one of claims 1-2, characterized in that: The node information includes a plurality of managed nodes, and when the managed nodes pass the detection, restarting the cluster service to be restarted includes: When each managed node included in the node information passes the detection in sequence, the cluster service is restarted on the corresponding managed node until the cluster service is restarted on each managed node.
10. A cluster service restart device, characterized in that: include: An acquisition module, used to acquire node information and pre-restart conditions associated with the cluster service to be restarted, wherein the node information includes a supervisor node and a managed node associated with the cluster service; A first restart module, used to restart the supervisor node; A detection module, configured to perform a pre-restart detection on the managed node based on the pre-restart condition, and detect the running state of the managed node after startup; The second restart module is used to restart the cluster service to be restarted if the managed node passes the detection.
11. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions that may be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9.
13. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 9.
