Service Process Daemon Method in Dual-Machine Mode and Dual-Machine Service System
By comparing service information in a dual-machine environment and sending automatic restart instructions, the problem of slow service abnormal response speed in a dual-machine environment is solved, and disaster recovery performance and service recovery efficiency are improved.
Patent Information
- Application Number
- CN202211623365.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-16
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2042-12-16
AI Technical Summary
In dual-machine environment mode, the response speed is slow when the service abnormality occurs, resulting in a longer service recovery time and affecting the user experience.
By reading service information in the local cache module and comparing it with the service information of the other party’s server, the service operation status of both servers is determined. When the service downtime occurs on the other party's server, a service restart instruction is generated and sent to the other party's server to achieve automatic restart and state recovery of the service.
Improve the disaster recovery performance of the server in dual-machine mode, shorten the service recovery time, and make users less susceptible to service abnormalities.
Smart Images

Figure CN115987760B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and in particular, to a method for guarding service processes in a dual-machine mode and a dual-machine service system. Background Art
[0002] In the early years, during project development, various business functions and system functions were mostly integrated and packaged into a single service module. With the development of computer technologies, the previous approach has gradually been abandoned, and instead, the system is split into individual independent units. The functions of each unit are relatively concentrated, and the division of labor between units is clear, thus achieving the miniaturization and micro-miniaturization of service units in the project. This development concept of splitting system functions and reducing service granularity is called "microservices". The development concept of microservices can split system functions, enabling them to be developed by small teams. Services are loosely coupled, and each service is independent during development, testing, and deployment phases. Moreover, different microservices can use different programming languages.
[0003] However, using the microservices development model also increases the difficulty of operations and maintenance, etc. Due to the use of distributed development, the complexity of the system is also increased because each service may be deployed in a different environment, which makes the system more difficult to maintain. For example, when a service fails, it is necessary to determine the server where the service is located and restore the service through manual intervention. To avoid business interruption of the entire service system due to an exception in a single server node, key nodes are usually configured in a dual-machine hot standby working mode, with the same service deployed on two servers. The services on different servers are isolated from each other and do not affect each other. Existing process monitoring reads the running status through computer instructions locally on each server and compares it with the service configuration information in the local database to determine the running services and the crashed services. If the monitoring process cannot run properly, the service cannot be restarted in a timely manner, resulting in a slow response speed when the service encounters an exception. Summary of the Invention
[0004] Embodiments of this application provide a method for guarding service processes in a dual-machine mode and a dual-machine service system to solve the problem of slow response speed when a service encounters an exception in an existing dual-machine environment mode.
[0005] In a first aspect, embodiments of this application provide a method for guarding service processes in a dual-machine mode, including:
[0006] Reading first service information from a local cache module according to a set guarding period;
[0007] Sending the first service information to the other server and receiving second service information sent by the other server according to the set guarding period;
[0008] Read service configuration information from the local database;
[0009] Compare the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers; wherein, the service information includes the server address, the service name of the services running on the server, the primary / backup status of the service, and the service status code; the service configuration information includes the service name and the primary / backup status of the services deployed on the server;
[0010] When it is determined that the other server has a service outage, generate a service restart instruction according to the name of the outage service, and send the service restart instruction to the other server.
[0011] In a possible implementation, when it is determined that the other server has a service outage, it further includes:
[0012] Determine whether the local corresponding primary / backup status of the service is the backup service according to the name of the outage service;
[0013] If it is the backup service, adjust the local corresponding primary / backup status to the primary service and provide the corresponding service externally.
[0014] In a possible implementation, the sending the service restart instruction to the other server includes:
[0015] Notify the other server through an http request; wherein, the http request includes: the service name and the primary / backup status of the service.
[0016] In a possible implementation, the method further includes:
[0017] When receiving a service restart instruction, parse the service restart instruction to determine the target service name;
[0018] Restart the corresponding target service according to the target service name, and update the primary / backup status of the target service name in the service configuration information to the backup service.
[0019] In a possible implementation, comparing the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers includes:
[0020] When the service name in the first service information is inconsistent with the service name in the service configuration information, and / or, the service status code is the specified status code, it is determined that a service outage occurs locally, and it is determined that the service corresponding to the missing service name in the first service information is the outage service, and / or, it is determined that the service corresponding to the specified status code is the outage service;
[0021] When the service name in the second service information is inconsistent with the service name in the service configuration information, and / or when the service status code is a specified status code, it is determined that the other server has a service outage, and it is determined that the service corresponding to the missing service name in the second service information is the down service, and / or it is determined that the service corresponding to the specified status code is the down service.
[0022] In a possible implementation, the method further includes:
[0023] Read the service configuration information from the local database according to the set monitoring period, and obtain the real-time service running process of the server;
[0024] Compare the service configuration information and the service running process to determine service exception information; wherein, the service exception information includes the service name and the primary / backup status of the abnormal service.
[0025] Restart the abnormal service according to the service exception information; wherein, the set daemon period is a multiple of the set monitoring period and the start times are different.
[0026] In a possible implementation, the method further includes:
[0027] Update the first service information in the local cache module according to the real-time service running information according to the set detection period; wherein, the set detection period is less than or equal to the set daemon period; the set daemon period is a multiple of the set detection period.
[0028] In a second aspect, an embodiment of the present application provides a service process daemon device in a dual-machine mode, including:
[0029] A reading module, configured to read the first service information from the local cache module according to the set daemon period;
[0030] A communication module, configured to send the first service information to the other server and receive the second service information sent by the other server according to the set daemon period;
[0031] The reading module is further configured to read the service configuration information from the local database;
[0032] A comparison module, configured to compare the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers; wherein, the service information includes the server address, the service name of the service running on the server, the primary / backup status of the service, and the service status code; the service configuration information includes the service name and the primary / backup status of the service deployed in the server.
[0033] The communication module is further configured to generate a service restart instruction according to the name of the downed service when it is determined that the other server has a service outage, and send the service restart instruction to the other server.
[0034] In a possible implementation manner, it further includes:
[0035] A control module, configured to determine whether the local corresponding service primary / backup status is the backup service according to the name of the downed service when it is determined that the other server has a service outage; if it is the backup service, adjust the local corresponding service primary / backup status to the primary service and provide the corresponding service externally.
[0036] In a possible implementation manner, the communication module is specifically configured to notify the other server through an HTTP request; wherein, the HTTP request includes: the service name and the service primary / backup status.
[0037] In a possible implementation manner, the control module is further configured to parse the service restart instruction to determine the target service name when receiving the service restart instruction;
[0038] Restart the corresponding target service according to the target service name, and update the service primary / backup status corresponding to the target service name in the service configuration information to the backup service.
[0039] In a possible implementation manner, the comparison module is specifically configured to determine that a local service outage occurs when the service name in the first service information is inconsistent with the service name in the service configuration information, and / or the service status code is the specified status code, and determine that the service corresponding to the missing service name in the first service information is the downed service, and / or determine that the service corresponding to the specified status code is the downed service;
[0040] When the service name in the second service information is inconsistent with the service name in the service configuration information, and / or the service status code is the specified status code, determine that the other server has a service outage, and determine that the service corresponding to the missing service name in the second service information is the downed service, and / or determine that the service corresponding to the specified status code is the downed service.
[0041] In a possible implementation manner, the reading module is further configured to read the service configuration information from the local database according to a set monitoring period and obtain the real-time service running process of the server;
[0042] The comparison module is further configured to compare the service configuration information and the service running process to determine service exception information; wherein, the service exception information includes the service name and the service primary / backup status of the exception service.
[0043] The control module is further configured to restart the abnormal service according to the service exception information; wherein, the set daemon period is a multiple of the set guardianship period, and the start times are different.
[0044] In a possible implementation manner, the control module is further configured to update the first service information in the local cache module according to the real-time service operation information at a set detection period; wherein, the set detection period is less than or equal to the set daemon period; the set daemon period is a multiple of the set detection period.
[0045] In a third aspect, an embodiment of the present application provides a dual-machine service system, which is characterized in that it includes two servers deploying the same service, and there is a primary-backup relationship when providing services externally for the same service; the servers are respectively configured to execute the steps of implementing the method described in the first aspect or any possible implementation manner of the first aspect above.
[0046] In a fourth aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, it implements the steps of the method described in the first aspect or any possible implementation manner of the first aspect above.
[0047] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, it implements the steps of the method described in the first aspect or any possible implementation manner of the first aspect above.
[0048] An embodiment of the present application provides a method for daemonizing a service process in a dual-machine mode and a dual-machine service system. In this embodiment, the service information in the cache modules of the local server and another server in the dual-machine mode is obtained through a daemon thread. Based on the fact that the same tasks are deployed on the two servers, when the daemon thread of the other server fails, it can be determined whether there is a service outage on the other server in the local server based on the comparison between the service configuration information in the local database and the service information in the cache module of the other server. When the daemon thread of the other server fails and there is a service outage, a backup of the daemon thread is implemented, and the other server can obtain the service restart instruction sent by the local server and execute the instruction to start the downed service, improving the disaster tolerance performance of the server in the dual-machine mode, shortening the service recovery time, and making it difficult for users to perceive service exceptions. Description of the Drawings
[0049] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0050] Figure 1 is the implementation flowchart of the service process daemon method in the dual-machine mode provided by an embodiment of the present application;
[0051] Figure 2 is the implementation flowchart of the service process daemon method in the dual-machine mode provided by another embodiment of the present application;
[0052] Figure 3 is the structural schematic diagram of the service process daemon device in the dual-machine mode provided by an embodiment of the present application;
[0053] Figure 4 is the structural schematic diagram of the electronic device provided by an embodiment of the present application. Detailed implementation manners
[0054] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system structures and technologies are proposed to thoroughly understand the embodiments of the present application. However, those skilled in the art should understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.
[0055] In the embodiments of the present application, terms such as "first" and "second" in the specification, claims, and the above drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so as to implement the embodiments of the present application described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion.
[0056] Unless otherwise stated, the term "plurality" means two or more.
[0057] In the embodiments of the present application, the character " / " indicates that the objects before and after are in an "or" relationship. For example, A / B means: A or B.
[0058] The term "and / or" is a description of the associated relationship of objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B these three relationships.
[0059] In the existing hot standby working mode for dual machines, a management center is built between two servers, and the service status of the two servers is confirmed through heartbeat signals. This requires an additional investment in equipment costs. In addition, the form of the heartbeat signal is simple and can detect the downtime of the server system. However, when multiple tasks are deployed on the server, it is difficult to effectively confirm the specific service status. The embodiment of this application aims to provide a low-cost solution that can accurately detect the service status and guard the service process.
[0060] In the dual-machine environment mentioned in the embodiment of the present invention, the microservice development mode is adopted. The same service is deployed on two servers respectively, and the same services on the two servers have a primary and standby relationship, that is, one primary and one standby. When the system is running normally, the service in the primary state provides services externally. When the primary service fails, the service in the standby state in the other server is upgraded to the primary service. After being upgraded to the primary service, it provides services externally and starts a timed service to start the failed service. When the standby service fails, no primary-standby adjustment is made, but the timed service is used to start the failed service.
[0061] Since it is a dual-machine environment, in the timed task, the information of all services in the dual machines will be obtained by reading the service configuration in the database, including the IP addresses of the servers to which they belong, etc. Then, all the surviving services in this server are read. By comparing the two, the running situation of the services and whether they belong to this server are judged. If a service fails and belongs to the services of this server, the instruction to start the service is executed; otherwise, no processing is done.
[0062] To make the purpose, technical solution and advantages of this application clearer, the following will be described through specific embodiments with reference to the accompanying drawings.
[0063] Figure 1 It is a flowchart of the implementation of the service process guarding method in the dual-machine mode provided by an embodiment of this application. As Figure 1 shown, the method includes the following steps:
[0064] S101, read the first service information from the local cache module according to the set guarding period.
[0065] Among them, the execution subject of this method is two servers in the dual-machine mode, and the two servers execute this method synchronously at regular intervals.
[0066] Specifically, in the dual-server mode, the same tasks are deployed on the two servers, maintaining a parallel state and the services have a primary-backup status. The primary service provides services, while the backup service acts as a "spare tire". Additionally, the two servers regularly synchronize and execute the service process daemonization solution provided in this embodiment to achieve two-way process daemonization and mutual monitoring, ensuring that when a daemon thread of one server fails, the service status can be monitored through the daemon thread of the other party. This can play a significant role in some systems with high performance and data requirements.
[0067] When deploying services to the server, the deployed service information and the primary-backup status of the two servers for executing the service will be stored in the server's database. After the service deployment is completed, the services running in the database and the real-time status data generated during the service operation will be stored in the cache module, and the corresponding data format is status.
[0068] Among them, the first service information includes the service information of one or more services. Reading the first service information from the local cache module according to the set daemonization period can obtain the service operation status in the local server in real time.
[0069] S102, Send the first service information to the other server and receive the second service information sent by the other server according to the set daemonization period.
[0070] Among them, the local server and the other server send each other real-time service operation data to achieve mutual monitoring and backup of the daemon threads, avoiding the situation where a daemon thread fails and the downed service cannot be restarted in time, which affects the user service experience.
[0071] S103, Read the service configuration information from the local database.
[0072] When deploying services to the server, the service configuration information will be updated. Since the same tasks are deployed on the two servers in the dual-server mode, the service names included in the service configuration information stored in any server are the same. Based on the comparison of the service configuration information in different servers and the service information obtained from the regular daemon threads, the same results can be obtained. Therefore, the service operation status can be judged without mutual transmission of the service configuration information in the regular daemon threads, improving the efficiency of comparative analysis.
[0073] S104, Compare the first service information and the second service information with the service configuration information respectively to determine the service operation status of the two servers; among them, the service information includes the server address, the service name / primary-backup status of the service running on the server, and the service status code; the service configuration information includes the service name and the primary-backup status of the service deployed in the server.
[0074] In a possible implementation, comparing the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers includes:
[0075] When the service name in the first service information is inconsistent with the service name in the service configuration information, and / or the service status code is a specified status code, it is determined that a service outage has occurred locally, and it is determined that the service corresponding to the missing service name in the first service information is an outage service, and / or it is determined that the service corresponding to the specified status code is an outage service;
[0076] When the service name in the second service information is inconsistent with the service name in the service configuration information, and / or the service status code is a specified status code, it is determined that a service outage has occurred on the other server, and it is determined that the service corresponding to the missing service name in the second service information is an outage service, and / or it is determined that the service corresponding to the specified status code is an outage service.
[0077] In the specific implementation process, among them, the outage services include services that are not pulled up after being deployed on the server and services that are pulled up after deployment and experience an outage during operation.
[0078] When a certain service is not pulled up after deployment, the service information obtained by the timing daemon thread does not include the service name and related running information of this service. Therefore, when including one or more tasks, after comparing the service information with the service configuration information, the services that are not pulled up after deployment can be confirmed according to the missing service names.
[0079] When a certain service is pulled up after deployment and experiences an outage during service operation, the service status code is set to an abnormal status code and stored in the server cache module. Among them, the abnormal status code is preset in the server system or configured according to specific service monitoring conditions.
[0080] In a specific embodiment, when the service is running normally, the service status code is 1, and when the service is down, the service status code is 0.
[0081] S105, when it is determined that a service outage has occurred on the other server, generate a service restart instruction according to the name of the outage service and send the service restart instruction to the other server.
[0082] Among them, when it is determined that a service outage has occurred on the other server and a service restart instruction is sent to the other server, the other server comprehensively determines the service running status based on the service restart instruction and the judgment result of its own timing daemon process, and timely pulls up the outage service based on the service restart instruction when its own daemon thread fails, shortening the service recovery time.
[0083] In this embodiment, the service information in the cache modules of the local server and another server in the dual-machine mode is obtained through a daemon thread. Based on the deployment of the same tasks on the two servers, when the daemon thread of the other server fails, it can be determined on the local server whether there is a service outage on the other server by comparing the service configuration information in the local database with the service information in the cache module of the other server. When the daemon thread of the other server fails and there is a service outage, a daemon thread backup is implemented. The other server can obtain the service restart instruction sent by the local server and execute the instruction to start the downed service, improving the disaster tolerance performance of the servers in the dual-machine mode, shortening the service recovery time, and making it difficult for users to perceive service anomalies.
[0084] In a possible implementation, when it is determined in step S105 that there is a service outage on the other server, it further includes:
[0085] Determine whether the local corresponding service master-backup status is the backup service according to the name of the downed service;
[0086] If it is the backup service, adjust the local corresponding service master-backup status to the master service and provide the corresponding service externally.
[0087] Among them, if the service master-backup status of the local server corresponding to the downed service is the backup service, it is timely adjusted to the master service to provide services externally; if the local server is the master service, the state of providing services externally is maintained unchanged, and the other server is instructed to start the downed service to improve the disaster tolerance performance of the system. When a service outage occurs in the local server, the other server can provide services externally in a timely manner.
[0088] In this embodiment, when it is determined that there is a service outage on the other server, the master-backup status of the downed service corresponding to the local server and the other server is further determined to ensure the normal external provision of services.
[0089] In a possible implementation, sending a service restart instruction to the other server includes:
[0090] Notify the other server through an HTTP request; where the HTTP request includes: the service name and the service master-backup status.
[0091] In this embodiment, the other server is notified to restart the service in the form of an HTTP request. The information format is relatively simple and the transmission speed is fast, improving the service recovery efficiency.
[0092] In a possible implementation, the method further includes:
[0093] When receiving the service restart instruction, parse the service restart instruction to determine the target service name;
[0094] Restart the corresponding target service according to the target service name, and update the primary / backup status of the target service corresponding to the target service name in the service configuration information to the backup service.
[0095] In this embodiment, when the local timed daemon thread fails, the target service name that has crashed is determined in a timely manner according to the service restart instruction sent by the other server, and the crashed service is restarted in a timely manner to provide relevant services externally in a timely manner when the target service in the other server crashes.
[0096] The foregoing embodiment mainly introduced how to implement the control of restarting a crashed service based on a timed two-way process daemon thread. In the specific implementation process, each server itself also has a timed monitoring thread.
[0097] In a possible implementation manner, the method further includes:
[0098] Read the service configuration information from the local database according to the set monitoring period, and obtain the real-time service running process of the server;
[0099] Compare the service configuration information and the service running process to determine service exception information; wherein, the service exception information includes the service name and the primary / backup status of the abnormal service.
[0100] Restart the abnormal service according to the service exception information.
[0101] In this embodiment, each server itself executes a timed monitoring thread in the dual-machine mode, and obtains the real-time service running process of the server based on computer instructions at regular intervals, and can detect the abnormal state of the service not being started or crashed. When the local timed monitoring thread of the server itself or the local timed monitoring thread of the other server has an exception, the service is restarted through the two-way process daemon solution provided in the foregoing embodiment to achieve dual protection.
[0102] Optionally, the set monitoring period is a multiple of the set detection period, and the start times are different, that is, the local timed monitoring thread of the server itself and the two-way process daemon thread are executed asynchronously. When both threads are running normally, the service crash recovery time can be further shortened.
[0103] In a possible implementation manner, the method further includes:
[0104] Update the first service information in the local cache module according to the real-time service running information according to the set detection period; wherein, the set detection period is less than or equal to the set monitoring period; the set monitoring period is a multiple of the set detection period.
[0105] In this embodiment, the first service information in the local cache module is updated according to the real-time service operation information at a set detection period, reducing the data storage amount in the local cache module and improving the data reading efficiency and data validity in the two-way process daemon thread.
[0106] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not imply the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this application.
[0107] The embodiment of this application also provides a dual-server service system, including two servers deploying the same service, which have a primary and standby relationship when providing services externally for the same service; the servers are respectively used to execute the method provided in any of the above embodiments.
[0108] Figure 2 is a schematic structural diagram of service process daemon in the dual-server mode provided by an embodiment of this application. The implementation flowchart of the method is as Figure 2 shown, and includes the following steps:
[0109] The two servers synchronously execute the timed daemon task. When the set daemon period start time is reached, the service information is read from the local cache module and interacted with each other, and at the same time, the service configuration information is read from the local database;
[0110] The service configuration information is compared with the service data in the cache modules of both parties to determine whether there is a service outage;
[0111] When there is no outage service, the current state is maintained unchanged. Otherwise, when there is a service outage, it is judged whether it belongs to this server;
[0112] If it belongs to this server, the service is restarted. Otherwise, it is judged whether the state of the corresponding outage service in this server is the primary service;
[0113] If the state of the local corresponding outage service is the primary service, the service is provided externally. Otherwise, it is adjusted to the primary service and the service is provided externally.
[0114] The following is the device embodiment of this application. For the details not described in detail, reference can be made to the corresponding method embodiment above.
[0115] Figure 3 is a schematic structural diagram of the service process daemon device in the dual-server mode provided by an embodiment of this application. As Figure 3 shown, for the convenience of description, only the parts related to the embodiment of this application are shown. As Figure 3 shown, the device includes:
[0116] A reading module 301, configured to read first service information from a local cache module according to a set daemon period;
[0117] A communication module 302, configured to send the first service information to a peer server and receive second service information sent by the peer server according to a set daemon period;
[0118] The reading module 301 is further configured to read service configuration information from a local database;
[0119] A comparison module 303, configured to compare the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers; wherein, the service information includes a server address, a service name of a service running on the server, a service primary / standby status, and a service status code; the service configuration information includes a service name and a service primary / standby status of a service deployed on the server;
[0120] The communication module 302 is further configured to, when determining that a service outage occurs on the peer server, generate a service restart instruction according to the name of the downed service and send the service restart instruction to the peer server.
[0121] In a possible implementation manner, it further includes:
[0122] A control module, configured to, when determining that a service outage occurs on the peer server, determine whether the corresponding service primary / standby status locally is the standby service according to the name of the downed service; if it is the standby service, adjust the corresponding service primary / standby status locally to the primary service and provide the corresponding service externally.
[0123] In a possible implementation manner, the communication module 302 is specifically configured to notify the peer server through an http request; wherein, the http request includes: a service name and a service primary / standby status.
[0124] In a possible implementation manner, the control module is further configured to, when receiving a service restart instruction, parse the service restart instruction to determine a target service name;
[0125] Restart the corresponding target service according to the target service name and update the service primary / standby status corresponding to the target service name in the service configuration information to the standby service.
[0126] In a possible implementation manner, the comparison module 303 is specifically configured to, when the service name in the first service information is inconsistent with the service name in the service configuration information, and / or the service status code is a specified status code, determine that a service outage occurs locally, and determine that the service corresponding to the missing service name in the first service information is the downed service, and / or determine that the service corresponding to the specified status code is the downed service;
[0127] When the service name in the second service information is inconsistent with the service name in the service configuration information, and / or when the service status code is the specified status code, it is determined that the other server has a service outage, and it is determined that the service corresponding to the missing service name in the second service information is the outage service, and / or it is determined that the service corresponding to the specified status code is the outage service.
[0128] In a possible implementation manner, the reading module 301 is further configured to read service configuration information from the local database according to a set monitoring period, and obtain the real-time service running process of the server;
[0129] The comparison module 303 is further configured to compare the service configuration information and the service running process to determine service exception information; wherein, the service exception information includes the service name and the primary / backup status of the abnormal service.
[0130] The control module is further configured to restart the abnormal service according to the service exception information; wherein, the set daemon period is a multiple of the set monitoring period, and the start times are different.
[0131] In a possible implementation manner, the control module is further configured to update the first service information in the local cache module according to the real-time service running information according to a set detection period; wherein, the set detection period is less than or equal to the set daemon period; the set daemon period is a multiple of the set detection period.
[0132] In this embodiment, the service information in the cache modules of the local server and another server in the dual-machine mode is obtained through the daemon thread. Based on the same tasks deployed on the two servers, when the daemon thread of the other server fails, it can be determined whether there is a service outage on the other server based on the comparison between the service configuration information in the local database and the service information in the cache module of the other server. When the daemon thread of the other server fails and there is a service outage, the daemon thread backup is realized. The other server can obtain the service restart instruction sent by the local server and execute the instruction to start the downed service, improving the disaster tolerance performance of the server in the dual-machine mode, shortening the service recovery time, and making it difficult for users to perceive service exceptions.
[0133] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 4 shown, the electronic device 4 in this embodiment includes: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer program 42, the steps in the above-mentioned embodiments of the service process daemon method in the dual-machine mode are implemented, for example Figure 1The steps S101 to S105 shown. Alternatively, when the processor 40 executes the computer program 42, it implements the functions of each module / unit in the above-described device embodiments, such as Figure 3 the functions of the modules 301 to 303 shown.
[0134] Exemplarily, the computer program 42 may be divided into one or more modules / units, and the one or more modules / units are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program 42 in the electronic device 4. For example, the computer program 42 may be divided into Figure 3 the modules 301 to 303 shown.
[0135] The electronic device 4 may be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The electronic device 4 may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art can understand that Figure 4 merely examples of the electronic device 4, and do not constitute a limitation on the electronic device 4. It may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, the electronic device may further include input / output devices, network access devices, a bus, etc.
[0136] The so-called processor 40 may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc.
[0137] The memory 41 may be an internal storage unit of the electronic device 4, such as a hard disk or memory of the electronic device 4. The memory 41 may also be an external storage device of the electronic device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the electronic device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 41 is used to store the computer program and other programs and data required by the electronic device. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0138] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be assigned to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above system can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.
[0139] In the above embodiments, the descriptions of the various embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0140] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this application can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0141] In the embodiments provided in the present application, it should be understood that the disclosed device / electronic device and method can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0142] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0143] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0144] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above method embodiments, it can also be completed by a computer program instructing relevant hardware. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above method embodiments of the service process daemon method in each dual-machine mode can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0145] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included within the protection scope of the present application.
Claims
1. A method for daemonizing a service process in a dual - machine mode, characterized in that, Including: Read the first service information from the local cache module according to the set guardian period; Send the first service information to the other server and receive the second service information sent by the other server according to the set guardian period; Read the service configuration information from the local database; Compare the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers; wherein, the service information includes the server address, the service name of the services running on the server, the service primary / backup status, and the service status code; the service configuration information includes the service name and the service primary / backup status of the services deployed on the server; When it is determined that the other server has a service outage, generate a service restart instruction according to the name of the outage service and send the service restart instruction to the other server; Among them, comparing the first service information and the second service information with the service configuration information respectively to determine the service running status of both servers includes: When the service name in the first service information is inconsistent with the service name in the service configuration information, and / or the service status code is the specified status code, it is determined that a service outage has occurred locally, and it is determined that the service corresponding to the missing service name in the first service information is the outage service, and / or it is determined that the service corresponding to the specified status code is the outage service; When the service name in the second service information is inconsistent with the service name in the service configuration information, and / or the service status code is the specified status code, it is determined that the other server has a service outage, and it is determined that the service corresponding to the missing service name in the second service information is the outage service, and / or it is determined that the service corresponding to the specified status code is the outage service.
2. The method for daemonizing a service process in a dual - machine mode according to claim 1, characterized in that, When it is determined that the other server has a service outage, it also includes: Determine whether the local corresponding service primary / backup status is the backup service according to the name of the outage service; If it is the backup service, adjust the local corresponding service primary / backup status to the primary service and provide the corresponding service externally.
3. The method for daemonizing a service process in a dual - machine mode according to claim 2, characterized in that, Sending the service restart instruction to the other server includes: Notify the other server through an http request; wherein, the http request includes: the service name and the service primary / backup status.
4. The method for daemonizing a service process in a dual - machine mode according to any one of claims 1 to 3, characterized in that, It also includes: When receiving the service restart instruction, parse the service restart instruction to determine the target service name; Restart the corresponding target service according to the target service name and update the service primary / backup status corresponding to the target service name in the service configuration information to the backup service.
5. The method for daemonizing a service process in a dual - machine mode according to claim 1, characterized in that, It also includes: Read the service configuration information from the local database according to the set monitoring period and obtain the real-time service running process of the server; Compare the service configuration information and the service running process to determine the service exception information; wherein, the service exception information includes the service name and the service primary / backup status of the exception service; Restart the exception service according to the service exception information; wherein, the set guardian period is a multiple of the set monitoring period and the start times are different.
6. The method for daemonizing a service process in a dual - machine mode according to claim 1, characterized in that, It also includes: Update the first service information in the local cache module according to the real-time service operation information according to the set detection period; wherein, the set detection period is less than or equal to the set daemon period; the set daemon period is a multiple of the set detection period.
7. A dual - machine service system, characterized in that, It includes two servers that deploy the same service, and have a primary-standby relationship when providing services externally for the same service; the servers are respectively used to execute the steps of the method described in any one of claims 1 to 6 above.
8. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 6 above.
9. A computer - readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method described in any one of claims 1 to 6 above.
Citation Information
Patent Citations
Switching of main and standby servers on the basis of monitoring
CN103795553A
Double host server system
CN105306605A