Server abnormality processing method, device and electronic device
By automatically judging the number of active services of the main server, automatic detection and switching of the master server exception is achieved, and the problem of cumbersome switching of the main and standby servers is solved, and the response speed and switching efficiency are improved.
Patent Information
- Application Number
- CN202211728332.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In the prior art, the method of manually sensing the switching of the main and standby servers is relatively cumbersome, resulting in slow response speed, which may lead to inability to perceive and handle server abnormalities in time.
By obtaining the number of active services in the main server, we automatically determine whether the main server is abnormal, and control the main server to suspend work in abnormal situations, control the backup server to start working, and realize automatic switching control.
Automatic server abnormality detection and switching is realized, the response speed is improved, the cumbersomeness of manual intervention is reduced, and the timeliness and efficiency of server switching is ensured.
Smart Images

Figure CN116155697B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of server technology, and in particular to a method, device, computer-readable storage medium and electronic device for processing server exceptions. Background Art
[0002] Current disaster recovery switching technologies mostly rely on manual inspections to determine if an anomaly has occurred in the current service, as well as manual deactivation and activation of all single-center services to achieve the switching of primary and backup servers. However, the manual perception and switching of primary and backup servers is relatively cumbersome. Summary of the invention
[0003] The main purpose of the present application is to provide a method, device, computer-readable storage medium and electronic device for processing server exceptions, so as to solve the problem that the manual perception switching between primary and backup servers in the prior art is relatively cumbersome.
[0004] According to one aspect of an embodiment of the present invention, a method for handling server abnormalities is provided, comprising: obtaining the number of active services in a main server, wherein the services are used to execute system functions; determining whether the main server is abnormal based on the number of active services in the main server, wherein the main server abnormality indicates that the main server is unable to continue to provide relevant data of services due to a failure of the main server; and in the case of determining that the main server is abnormal, controlling the main server to suspend operation and controlling the backup server to start operation, wherein the main server and the backup server are respectively in the same target area.
[0005] Optionally, determining whether the main server is abnormal is based on the number of active services in the main server, including: acquiring the number of abnormal services in the main server to obtain the number of abnormal services; determining that the main server is abnormal when the proportion of the number of abnormal services in the number of services is greater than or equal to a proportion threshold; determining that the main server is not abnormal when the proportion of the number of abnormal services in the number of services is less than the proportion threshold.
[0006] Optionally, obtaining the number of abnormal services in the main server to obtain the abnormal number includes: obtaining target identification information of the service in the main server, the target identification information indicating whether the service has been updated; when the target identification information indicates that the service has been updated, determining that the service is a non-abnormal service, wherein a service update refers to an upgrade of the deployed service; when the target identification information indicates that the service has not been updated, determining that the service is an abnormal service, and counting the number of abnormal services to obtain the abnormal number.
[0007] Optionally, when it is determined that the main server is abnormal, the main server is controlled to suspend operation, and the backup server is controlled to start operation, including: when it is determined that the main server is abnormal, the first process on the main server is controlled to enter a dormant state, wherein the main server is suspended when the first process enters the dormant state; the second process on the backup server is controlled to enter a running state, wherein the backup service starts working when the second process enters the running state.
[0008] Optionally, the method further includes: obtaining switching related information, the switching related information indicating whether to switch the server; obtaining the type of the current server; and determining a switching method between servers based on the switching related information and the type of the current server.
[0009] Optionally, the switching method between servers is determined based on the switching-related information and the type of the current server, including: when the switching-related information indicates that a switch is to be made from the main server to the backup server and the current server is the backup server, determining not to switch the server and controlling the backup server to continue working; when the switching-related information indicates that a switch is to be made from the main server to the backup server and the current server is the main server, determining to switch the server, controlling the main server to suspend working, and controlling the backup server to start working.
[0010] Optionally, the method further includes: when both the primary server and the backup server are abnormal, controlling the primary server and the backup server to stop working, and controlling the disaster recovery server to start working, wherein the disaster recovery server is located in a non-target area.
[0011] According to another aspect of an embodiment of the present invention, a server exception processing device is also provided, including: a first acquisition unit, used to obtain the number of active services in the main server, wherein the services are used to execute system functions; a first determination unit, used to determine whether the main server is abnormal based on the number of active services in the main server, wherein the main server abnormality represents relevant data that the main server cannot continue to provide services due to the failure of the main server; a first control unit, used to control the main server to suspend operation and control the backup server to start operation when it is determined that the main server is abnormal, wherein the main server and the backup server are respectively in the same target area.
[0012] According to yet another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein the program executes any one of the methods described.
[0013] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising: one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of the methods described.
[0014] In the embodiment of the present invention, the number of active services in the main server is first obtained, and then whether the main server is abnormal is determined according to the number of active services in the main server. Finally, if the main server is determined to be abnormal, the main server is controlled to stop working and the backup server is controlled to start working. In this solution, whether the main server is abnormal can be automatically determined by the number of active services in the main server, and the main server and the backup server can be automatically switched when the main server is abnormal, realizing automatic switching control, thereby solving the problem that the manual perception switching method of the main and backup servers is relatively cumbersome. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0016] Figure 1 A schematic flow chart of a method for handling server exceptions according to an embodiment of the present application is shown;
[0017] Figure 2 A schematic diagram of the structure of a server abnormality processing device according to an embodiment of the present application is shown;
[0018] Figure 3 A flowchart of another solution for handling server exceptions is shown;
[0019] Figure 4 A logical schematic diagram of a unified monitoring server is shown. DETAILED DESCRIPTION
[0020] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] It should be understood that when an element (such as a layer, film, region, or substrate) is described as being "on" another element, the element may be directly on the other element, or there may be intermediate elements. Moreover, in the specification and claims, when an element is described as being "connected" to another element, the element may be "directly connected" to the other element, or "connected" to the other element through a third element.
[0024] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0025] Configuration Center: The Configuration Center is a configuration management platform that implements multi-service configuration management. Some configuration files are associated with certain specific services through configuration file subscription.
[0026] Registry Center: The registry center is the infrastructure for managing services in a distributed system. It records the mapping relationship between services and service addresses and is used for service registration and service discovery.
[0027] Active-active: The primary and standby database centers simultaneously handle customer traffic, which is a resource-saving computer disaster recovery solution.
[0028] Hot standby: The backup data center backs up the main database center without shutting down. In a broad sense, it is another term for server high-availability application. In a narrow sense, dual-machine hot standby specifically refers to the hot standby of two servers based on a high-availability system.
[0029] Service: A service in a computer is a program, routine, or process that performs a specified system function to support other programs, especially low-level programs close to the hardware. When services are provided over a network, services can be published in Active Directory, which promotes service-centric management and use. A service is a type of application that runs in the background. Service applications typically provide some functionality to users locally and over a network, such as client / server applications, Web servers, database servers, and other server-based applications.
[0030] In a distributed architecture, clusters (servers) are deployed in regional centers. This deployment method is to avoid the situation where the services provided by the cluster are completely unavailable for a long time when a computer room in a certain region loses power or suffers from natural disasters or other unpredictable situations. In order to shorten the external perception time during the disaster recovery switching process and reduce the idle resources of the disaster recovery server, local disaster recovery servers usually use active-active mode (switching between the primary and backup servers in the same target area), and remote backup servers use hot standby mode (switching between servers in the target area and servers in non-target areas).
[0031] The database of the off-site backup server (server in a non-target area) is often read-only before the switch occurs. This is to avoid data inconsistency between the two locations. Among the primary and backup databases (databases corresponding to the primary server in the target area), only the primary database is read-only. When the original primary server is unavailable and the backup server is switched, the database of the backup server becomes the primary database and can be read and written.
[0032] Therefore, how to make the disaster recovery server and backup server aware of the unavailability of the primary server in time, and how to synchronize the changes of the primary server after the primary server is switched, have become the focus of the disaster recovery switching process. At the code level, how to use a unified management mechanism to control the current server service's write operations to the database is also an issue that needs to be solved urgently.
[0033] Most existing technologies for solving disaster recovery switching rely on manual inspections to determine the abnormality rate of the current service, as well as the deactivation and activation of a single server to achieve the switch of the primary server. When a problem occurs on the current primary server, all services on the primary server are stopped, and then the services on the backup server are started. The disadvantages of this method are:
[0034] 1) It takes a certain amount of time to deactivate the service of the main server and to activate the service of the backup server. The operation process is complicated. Under abnormal circumstances, the unavailability of external services will be prolonged, affecting the user experience;
[0035] 2) Manual inspections have a slow response speed. When an abnormality occurs in the cluster of the main server, most of the nodes in the server may be abnormal, but a small number of nodes can still conduct transactions. When there are fewer external requests, the processing capacity reduction caused by the unavailability of most services of the main server cannot be perceived. The abnormality of the main server can only be perceived when a large number of abnormal events occur or the service has been unavailable for a period of time. If it is not handled until then, irreversible consequences and greater impacts may have occurred;
[0036] 3) The deactivation of the primary server service and the activation of the backup server service will prolong the time for troubleshooting. For some important business scenarios, long-term unavailability is not acceptable, that is, the primary server and the backup primary server may be unavailable at the same time in the same period of time.
[0037] As mentioned in the background technology, the manual perception and switching of primary and backup servers in the prior art is rather cumbersome. In order to solve the above problem, a typical implementation of the present application provides a method, device, computer-readable storage medium and electronic device for handling server exceptions.
[0038] According to an embodiment of the present application, a method for handling server exceptions is provided.
[0039] Figure 1 FIG. 1 is a flow chart of a method for handling server exceptions according to an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0040] Step S101, obtaining the number of active services in the main server, wherein the above services are used to execute system functions;
[0041] Specifically, in the initial state, the primary server is in the startup state, but not in the running state, and both the primary server and the backup server will request services from the registration center.
[0042] In the above step S101, the number of active services in the main server can be obtained, so that whether the main server is abnormal can be judged based on the number of active services in the main server, which is more efficient and accurate than manual judgment.
[0043] Step S102, determining whether the main server is abnormal according to the number of the services active in the main server, wherein the abnormality of the main server indicates that the main server fails and thus the main server cannot continue to provide relevant data of the service;
[0044] In the above step S102, whether the main server is abnormal can be automatically determined by the number of active services in the main server. Compared with the manual monitoring and manual judgment methods in some solutions, this solution can detect whether the main server is abnormal in time, and then timely handle it later.
[0045] Step S103, when it is determined that the main server is abnormal, the main server is controlled to stop working and the backup server is controlled to start working, wherein the main server and the backup server are respectively in the same target area.
[0046] Specifically, the target area refers to an area where a city is located, and the primary server and the backup server are in the same city, or a specific region, and the primary server and the backup server are in the same region.
[0047] In the above step S103, when it is determined that the main server is abnormal, the main server and the backup server can be switched to work on the backup server, so that the main server and the backup server can be automatically switched, realizing automatic switching control.
[0048] In the above method, the number of active services in the main server is first obtained, and then whether the main server is abnormal is determined based on the number of active services in the main server. Finally, if the main server is determined to be abnormal, the main server is controlled to stop working and the backup server is controlled to start working. In this solution, it is possible to automatically determine whether the main server is abnormal through the number of active services in the main server, and when the main server is abnormal, the main server and the backup server can be automatically switched, realizing automatic switching control, thereby solving the problem of the cumbersome method of manually sensing the switching of the main and backup servers.
[0049] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0050] In some solutions, whether the server is abnormal is sensed manually. The accuracy of the manual sensing method is low and it takes a long time to detect, which may result in failure to sense the server abnormality in time. In one embodiment of the present application, whether the main server is abnormal is determined according to the number of the above services active in the above main server, specifically including the following steps:
[0051] Step S201, obtaining the number of abnormal services in the main server to obtain the abnormal number;
[0052] The main server can work with the active service, and the main server can also automatically update the service. If the service on the main server has not been updated, it means that the service of the main server is in an abnormal state. In a specific embodiment of the present application, the number of abnormal services in the main server is obtained to obtain the abnormal number, which specifically includes the following steps:
[0053] Step S2011, obtaining target identification information of the service in the main server, wherein the target identification information indicates whether the service has been updated;
[0054] Step S2012, when the target identification information indicates that the service has been updated, determining that the service is a non-abnormal service, wherein the service update refers to upgrading the deployed service;
[0055] Step S2013: when the target identification information indicates that the service is not updated, determining that the service is an abnormal service, and counting the number of abnormal services to obtain the abnormal number.
[0056] In the above steps S2011 to S2013, by judging whether the services in the main server have been updated, it can be determined whether the services on the main server are abnormal. In this way, the number of abnormal services can be counted to obtain the number of abnormalities, and subsequently the number of abnormalities can be used to further accurately determine whether the main server is abnormal.
[0057] Step S202, when the ratio of the number of abnormalities to the number of services is greater than or equal to a ratio threshold, determining that the main server is abnormal;
[0058] Specifically, the ratio threshold may be 50%, 60%, or 75%. Of course, it is not limited to these cases, and those skilled in the art may also select a suitable ratio threshold according to actual conditions.
[0059] Step S203: When the ratio of the number of abnormalities to the number of services is less than the ratio threshold, it is determined that the main server is not abnormal.
[0060] In the above-mentioned steps S201 to S203, the abnormal proportion threshold can be set in advance to automatically determine whether the proportion of the number of abnormal services in the number of active services in the main server has reached the proportion threshold. When the proportion threshold is reached, the main server abnormality is determined through the logic set in advance. In this way, whether the main server is abnormal can be judged in an automated manner, and it does not take a long time to determine whether the main server is abnormal, thereby ensuring that the present solution can perceive the abnormality of the main server in a timely manner.
[0061] When both the primary server and the backup server are started, the first process on the primary server and the second process on the backup server are both in the started state, but only one process on one server is in the running state at the same time. If the server is to be switched, the corresponding process on the server can be awakened. In another embodiment of the present application, when it is determined that the primary server is abnormal, the primary server is controlled to suspend work and the backup server is controlled to start working, which specifically includes the following steps:
[0062] Step S301, when it is determined that the main server is abnormal, controlling the first process on the main server to enter a dormant state, wherein the main server suspends operation when the first process enters the dormant state;
[0063] Step S302, controlling the second process on the backup server to enter a running state, wherein the backup service starts to work when the second process enters the running state.
[0064] Specifically, this solution can realize automatic switching between servers, thereby further avoiding the problem of external services being unavailable for a long time under abnormal conditions caused by slow detection speed and insensitive perception in some solutions.
[0065] In the above steps S301 to S302, when the main server is abnormal, the first process on the main server can be controlled to enter a dormant state, and the second process on the backup server can be controlled to enter a running state. When the main server is working, the second process on the backup server is not actually closed, but only enters a dormant state. In this way, when the main server is abnormal, the second process on the backup server can be awakened in time, so that the switching between the main and backup servers can be responded to in time, thereby avoiding the situation where there is no server running for a long time due to the failure of the backup server to start for a long time.
[0066] For each server, the processing logic of the server change is similar. If the server needs to be switched, the switching mode between the servers can be determined according to the type of the currently running server and the corresponding switching related information, and then the server can be switched according to the switching mode. In another embodiment of the present application, the above method further includes the following steps:
[0067] Step S401, obtaining switching related information, the switching related information indicating whether to switch the server;
[0068] Step S402, obtaining the type of the current server;
[0069] Step S403: Determine the switching mode between servers according to the switching related information and the type of the current server.
[0070] In the above steps S401 to S403, the switching mode between servers can be further accurately determined according to the switching related information and the type of the current server currently running.
[0071] In order to further determine the switching mode between servers more efficiently and accurately, improve the scalability of the present solution, and implement control to prevent repeated push of switching related information, in a specific embodiment of the present application, the switching mode between servers is determined according to the above-mentioned switching related information and the type of the above-mentioned current server, specifically including the following steps:
[0072] Step S4031, when the switching related information indicates that the primary server is to be switched to the backup server, and the current server is the backup server, determining not to switch the server, and controlling the backup server to continue working;
[0073] Specifically, if the switching related information indicates that the primary server needs to be switched to the backup server, the switching related information may be triggered by mistake due to misjudgment or other reasons, and the current server is originally the backup server. In this case, there is no need to switch servers, and no switching process between servers is required.
[0074] Step S4032: when the switching related information indicates that the main server is to be switched to the backup server and the current server is the main server, determine the switching server, control the main server to suspend operation, and control the backup server to start operation.
[0075] In an optional embodiment, when the switching related information indicates that a switch is to be made from a backup server to a main server, the type of the current server is determined. If the current server is the main server, the server is not switched and the main server is controlled to continue working. If the current server is the backup server, the server is switched and the main server is controlled to start working and the backup server is controlled to suspend working.
[0076] In the above-mentioned steps S4031 to S4032, the server is switched only when the switching related information indicates that the switch is to be made from the main server to the backup server and the current server is the main server. If the switching related information indicates that the switch is to be made from the main server to the backup server and the current server is the backup server, there is no need to switch the server. This is because the originally running server is already a backup server, so there is no need to switch the server. In this way, the switching method between servers can be further efficiently and accurately determined based on the switching related information and the type of the current server currently running.
[0077] This solution can switch between the main server and the backup server. If both the main server and the backup server are abnormal, the disaster recovery server can also be controlled to work to avoid the situation where no server is working. In another embodiment of the present application, the above method also includes: when both the main server and the backup server are abnormal, the main server and the backup server are controlled to suspend work, and the disaster recovery server is controlled to start working, wherein the disaster recovery server is located in a non-target area. In this embodiment, when both the main server and the backup server are abnormal, the main server and the backup server can be controlled to suspend work, and at this time, the disaster recovery server in the non-target area can be controlled to start working, which further ensures that there can be a server to provide services to the terminals in the target area, avoiding the situation where no server is working.
[0078] Specifically, in the initial state, the disaster recovery server will also be in the startup state, but not the running state. The disaster recovery server will start running only when both the primary server and the backup server in the target area are abnormal.
[0079] For the target area and non-target area, if there are two areas, namely area A and area B, the primary server and the backup server will be in area A, area A is the target area, and the disaster recovery server will be in area B. The disaster recovery server is not in the same area as the primary and backup servers.
[0080] The embodiment of the present application also provides a server exception processing device. It should be noted that the server exception processing device of the embodiment of the present application can be used to execute the server exception processing method provided in the embodiment of the present application. The server exception processing device provided in the embodiment of the present application is introduced below.
[0081] Figure 2 Schematic diagram of a server exception processing device according to an embodiment of the present application. Figure 2 As shown, the device comprises:
[0082] A first acquisition unit 10 is used to acquire the number of active services in the main server, wherein the services are used to execute the functions of the system;
[0083] Specifically, in the initial state, the primary server is in the startup state, but not in the running state, and both the primary server and the backup server will request services from the registration center.
[0084] The first acquisition unit can acquire the number of active services in the main server, so that it can be judged whether the main server is abnormal based on the number of active services in the main server, which is more efficient and accurate than manual judgment.
[0085] The first determining unit 20 is used to determine whether the main server is abnormal according to the number of the services active in the main server, wherein the abnormality of the main server indicates that the main server is unable to continue to provide relevant data of the service due to the failure of the main server;
[0086] The above-mentioned first determination unit can automatically determine whether the main server is abnormal based on the number of active services in the main server. Compared with the manual monitoring and manual judgment methods in some solutions, this solution can detect whether the main server is abnormal in time, and then timely handle it later.
[0087] The first control unit 30 is used to control the main server to stop working and control the backup server to start working when it is determined that the main server is abnormal, wherein the main server and the backup server are respectively in the same target area.
[0088] Specifically, the target area refers to an area where a city is located, and the primary server and the backup server are in the same city, or a specific region, and the primary server and the backup server are in the same region.
[0089] The above-mentioned first control unit can switch between the main server and the backup server when determining that the main server is abnormal, and can switch to the backup server to work, so that the main server and the backup server can be automatically switched, realizing automatic switching control.
[0090] In the above-mentioned device, the first acquisition unit acquires the number of active services in the main server, the first determination unit determines whether the main server is abnormal according to the number of active services in the main server, and the first control unit controls the main server to suspend operation and controls the backup server to start operation when determining that the main server is abnormal. In this solution, it is possible to automatically determine whether the main server is abnormal by the number of active services in the main server, and when the main server is abnormal, the main server and the backup server can be automatically switched, thereby realizing automatic switching control, thereby solving the problem that the manual perception switching method of the main and backup servers is relatively cumbersome.
[0091] In some solutions, it is manually sensed whether the server is abnormal. The manual perception method has a low accuracy rate and takes a long time to detect, which may result in failure to timely perceive the server abnormality. In one embodiment of the present application, the first determination unit includes an acquisition module, a first determination module, and a second determination module. The functions of each module are as follows:
[0092] An acquisition module is used to acquire the number of abnormal services in the main server to obtain the abnormal number;
[0093] The main server can work with the active service, and the main server can also automatically update the service. If the service on the main server has not been updated, it indicates that the service of the main server is in an abnormal state. In a specific embodiment of the present application, the acquisition module includes an acquisition submodule, a first determination submodule and a second determination submodule, and the functions of each submodule are as follows:
[0094] The acquisition submodule is used to acquire the target identification information of the service in the main server, where the target identification information indicates whether the service has been updated;
[0095] A first determination submodule is used to determine that the service is a non-abnormal service when the target identification information indicates that the service has been updated, wherein the service update refers to an upgrade of the deployed service;
[0096] The second determination submodule is used to determine that the service is an abnormal service when the target identification information indicates that the service has not been updated, and to count the number of abnormal services to obtain the abnormal number.
[0097] The above-mentioned acquisition submodule, first determination submodule and second determination submodule can determine whether the service on the main server is abnormal by judging whether the service in the main server has been updated. In this way, the number of abnormalities can be obtained by counting the number of abnormal services, and subsequently, whether the main server is abnormal can be further accurately determined by the number of abnormalities.
[0098] A first determination module is used to determine that the main server is abnormal when the proportion of the number of abnormalities in the number of services is greater than or equal to a proportion threshold;
[0099] Specifically, the ratio threshold may be 50%, 60%, or 75%. Of course, it is not limited to these cases, and those skilled in the art may also select a suitable ratio threshold according to actual conditions.
[0100] The second determination module is used to determine that the main server is not abnormal when the proportion of the above-mentioned abnormal number in the number of the above-mentioned services is less than the above-mentioned proportion threshold.
[0101] The above-mentioned acquisition module, first determination module and second determination module can set the abnormal proportion threshold in advance, and automatically determine whether the proportion of the number of abnormal services in the number of active services in the main server has reached the proportion threshold. When the proportion threshold is reached, the main server abnormality is determined through the logic set in advance. In this way, whether the main server is abnormal can be judged in an automated manner, and it does not take a long time to determine whether the main server is abnormal, thereby ensuring that the present solution can perceive the abnormality of the main server in a timely manner.
[0102] When both the main server and the backup server are started, the first process on the main server and the second process on the backup server are both in the started state, but only one process on one server is in the running state at the same time. If the server is to be switched, the process on the corresponding server can be awakened. In another embodiment of the present application, the first control unit includes a first control module and a second control module, and the functions of each module are as follows:
[0103] A first control module is used to control the first process on the main server to enter a dormant state when it is determined that the main server is abnormal, wherein the main server suspends operation when the first process enters the dormant state;
[0104] The second control module is used to control the second process on the backup server to enter the running state, wherein the backup service starts to work when the second process enters the running state.
[0105] Specifically, this solution can realize automatic switching between servers, thereby further avoiding the problem of external services being unavailable for a long time under abnormal conditions caused by slow detection speed and insensitive perception in some solutions.
[0106] The above-mentioned first control module and second control module can first control the first process on the main server to enter a dormant state, and control the second process on the backup server to enter a running state when the main server is abnormal. When the main server is working, the second process on the backup server is actually not closed, but just enters a dormant state. In this way, when the main server is abnormal, the second process on the backup server can be awakened in time, so that the switching between the main and backup servers can be responded to in time, thereby avoiding the situation where there is no server running for a long time due to the failure of the backup server to start for a long time.
[0107] For each server, the processing logic of the server change is similar. If the server needs to be switched, the switching mode between the servers can be determined according to the type of the currently running server and the corresponding switching related information, and then the server can be switched according to the switching mode. In another embodiment of the present application, the above-mentioned device also includes a second acquisition unit, a third acquisition unit and a second determination unit, and the functions of each unit are as follows:
[0108] A second acquisition unit is used to acquire switching related information, where the switching related information indicates whether to switch the server;
[0109] A third obtaining unit is used to obtain the type of the current server;
[0110] The second determining unit is used to determine the switching mode between servers according to the switching related information and the type of the current server.
[0111] The second acquisition unit, the third acquisition unit and the second determination unit can further accurately determine the switching mode between servers according to the switching related information and the type of the current server currently running.
[0112] In order to further determine the switching mode between servers more efficiently and accurately, improve the scalability of the present solution, and implement control to prevent repeated push of switching related information, in a specific embodiment of the present application, the second determination unit includes a third control module and a fourth control module, and the functions of each module are as follows:
[0113] A third control module is used for determining not to switch the server and controlling the backup server to continue working when the switching related information indicates that the primary server is to be switched to the backup server and the current server is the backup server;
[0114] Specifically, if the switching related information indicates that the primary server needs to be switched to the backup server, the switching related information may be triggered by mistake due to misjudgment or other reasons, and the current server is originally the backup server. In this case, there is no need to switch servers, and no switching process between servers is required.
[0115] The fourth control module is used to determine the switching server when the switching related information indicates that the main server is to be switched to the backup server and the current server is the main server, and control the main server to suspend operation and control the backup server to start operation.
[0116] In an optional embodiment, when the switching related information indicates that a switch is to be made from a backup server to a main server, the type of the current server is determined. If the current server is the main server, the server is not switched and the main server is controlled to continue working. If the current server is the backup server, the server is switched and the main server is controlled to start working and the backup server is controlled to suspend working.
[0117] The above-mentioned third control module and fourth control module will switch servers only when the switching related information indicates that switching from the main server to the backup server is required and the current server is the main server. If the switching related information indicates that switching from the main server to the backup server is required and the current server is the backup server, there is no need to switch servers. This is because the originally running server is already a backup server, so there is no need to switch servers. In this way, the switching method between servers can be further efficiently and accurately determined based on the switching related information and the type of the current server currently running.
[0118] This solution can switch between the main server and the backup server. If both the main server and the backup server are abnormal, the disaster recovery server can also be controlled to work to avoid the situation where no server is working. In another embodiment of the present application, the above-mentioned device also includes a second control unit, and the second control unit is used to control the above-mentioned main server and the above-mentioned backup server to suspend work and control the disaster recovery server to start working when both the above-mentioned main server and the above-mentioned backup server are abnormal, wherein the above-mentioned disaster recovery server is located in a non-target area. In this embodiment, when both the main server and the backup server are abnormal, the main server and the backup server can be controlled to suspend work, and at this time, the disaster recovery server in the non-target area can be controlled to start working, which further ensures that there can be a server to provide services to the terminals in the target area, avoiding the situation where no server is working.
[0119] Specifically, in the initial state, the disaster recovery server will also be in the startup state, but not the running state. The disaster recovery server will start running only when both the primary server and the backup server in the target area are abnormal.
[0120] For the target area and non-target area, if there are two areas, namely area A and area B, the primary server and the backup server will be in area A, area A is the target area, and the disaster recovery server will be in area B. The disaster recovery server is not in the same area as the primary and backup servers.
[0121] The above-mentioned server exception processing device includes a processor and a memory. The above-mentioned first acquisition unit, first determination unit and first control unit are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0122] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the kernel parameters can be adjusted to automatically sense and switch between the primary and standby servers.
[0123] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0124] An embodiment of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the method for processing the server exception is implemented.
[0125] An embodiment of the present invention provides a processor, and the processor is used to run a program, wherein the method for handling server exceptions is executed when the program is running.
[0126] An embodiment of the present application also provides an electronic device, comprising one or more processors, a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a method for executing any one of the above methods.
[0127] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0128] Step S101, obtaining the number of active services in the main server, wherein the above services are used to execute system functions;
[0129] Step S102, determining whether the main server is abnormal according to the number of the services active in the main server, wherein the abnormality of the main server indicates that the main server fails and thus the main server cannot continue to provide relevant data of the service;
[0130] Step S103, when it is determined that the main server is abnormal, the main server is controlled to stop working and the backup server is controlled to start working, wherein the main server and the backup server are respectively in the same target area.
[0131] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0132] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:
[0133] Step S101, obtaining the number of active services in the main server, wherein the above services are used to execute system functions;
[0134] Step S102, determining whether the main server is abnormal according to the number of the services active in the main server, wherein the abnormality of the main server indicates that the main server fails and thus the main server cannot continue to provide relevant data of the service;
[0135] Step S103, when it is determined that the main server is abnormal, the main server is controlled to stop working and the backup server is controlled to start working, wherein the main server and the backup server are respectively in the same target area.
[0136] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the technical solution and technical effects of the present application will be explained below in conjunction with specific embodiments.
[0137] Example
[0138] This embodiment relates to a solution for handling server exceptions, such as Figure 3 As shown, the program includes:
[0139] 1. In the initial state, the main server, disaster recovery server, and backup server services are all in the startup state, and the services are registered with the public registration center;
[0140] 2. When the current main server is abnormal, the registration center senses that a large number of services of the server are disconnected (i.e., service abnormality), and sends the number and proportion of disconnected services to the operation and maintenance platform (sends a notification to the operation and maintenance platform);
[0141] 3. The operation and maintenance platform determines whether the proportion of disconnected services reaches the proportion threshold according to the pre-set proportion threshold. If the proportion threshold is not reached, the operation and maintenance platform waits for the next alarm. If the proportion threshold is reached, the operation and maintenance platform executes the server switching strategy and pushes the configuration change (i.e., server switching notification) to the configuration center.
[0142] 4. The configuration center pushes configuration change messages to the three servers (the applications of the three servers will monitor the configuration changes. The three servers include the primary server, backup server, and disaster recovery server). The server that becomes the primary server starts running, and the other servers remain suspended. The server that was originally the primary server also suspends operation.
[0143] 5. For each server service, the processing logic for server changes is the same. Now take a single service to illustrate the processing logic of the master server change within the application service. When the master server configuration change notification pushed by the configuration center reaches the server, the service memory will start to verify the master server information in the memory and the pushed configuration information (that is, switch related information). There are the following situations:
[0144] 1) Confirm that the primary server in the pushed primary server configuration is the current server (i.e., whether to switch the backup server to the primary server)
[0145] a) If the primary server flag of the current server is true, it is considered as repeated push information, and the primary server has not changed, so no processing is done;
[0146] b) If the primary server flag of the current server is false, it is considered that the primary server has changed, the current server becomes the primary server, and the online logic is executed;
[0147] 2) Make sure that the primary server in the pushed primary server configuration is not the current server (i.e., whether to switch the primary server to the backup server)
[0148] a) If the primary server flag of the current server is false, it is considered as repeated push information, and the primary server has not changed, so no processing is done;
[0149] b) If the primary server flag of the current server is true, it is considered that the primary server has changed and the current server is no longer the primary server, and the offline logic is executed;
[0150] That is, only when the comparison result between the primary server in the configuration and the server receiving the message service is inconsistent with the primary server identifier inside the service, the corresponding online and offline logic will be executed;
[0151] 6. Then, based on the judgment result in the previous step, notify the process or thread in the service and execute the corresponding online and offline logic:
[0152] Online logic: When the primary server starts or the non-primary server switches to the primary server, the dormant process or thread is awakened. The code needs to perform unified startup management, and the primary server starts processing tasks.
[0153] Offline logic: When a non-primary server is started or the primary server is switched to a non-primary server, the running process or thread is put into hibernation. The code needs to be managed uniformly, and the non-primary server will no longer process tasks.
[0154] The unified management method in the code uses event publishing and subscription to uniformly monitor the server, such as Figure 4 As shown, a stop / enable event is published. A stop event refers to an event that controls the server to suspend operation, and an enable event refers to an event that controls the server to start operation. Specifically, each listener monitors the operating status of a server.
[0155] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0156] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the above-mentioned units can be a logical function division. There may be other division methods in actual implementation. 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0157] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0158] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0159] If the above-mentioned integrated 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, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0160] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0161] 1) The server abnormality processing method of the present application first obtains the number of active services in the main server, then determines whether the main server is abnormal based on the number of active services in the main server, and finally controls the main server to suspend work and controls the backup server to start working when it is determined that the main server is abnormal. In this solution, it is possible to automatically determine whether the main server is abnormal based on the number of active services in the main server, and when the main server is abnormal, the main server and the backup server can be automatically switched, realizing automatic switching control, thereby solving the problem that the manual perception switching method of the main and backup servers is relatively cumbersome.
[0162] 2) In the server abnormality processing device of the present application, the first acquisition unit acquires the number of active services in the main server, the first determination unit determines whether the main server is abnormal according to the number of active services in the main server, and the first control unit controls the main server to suspend operation and controls the backup server to start operation when determining that the main server is abnormal. In this solution, whether the main server is abnormal can be automatically determined by the number of active services in the main server, and when the main server is abnormal, the main server and the backup server can be automatically switched, realizing automatic switching control, thereby solving the problem that the manual perception switching method of the main and backup servers is relatively cumbersome.
[0163] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for handling server exceptions, characterized in that: include: Obtaining the number of active services in the primary server, wherein the services are used to perform functions of the system; Determine whether the main server is abnormal according to the number of the services active in the main server, wherein the abnormality of the main server indicates that the failure of the main server causes the main server to be unable to continue to provide relevant data of the service; When it is determined that the main server is abnormal, controlling the main server to stop working and controlling the backup server to start working, wherein the main server and the backup server are respectively in the same target area; Determining whether the main server is abnormal according to the number of active services in the main server includes: obtaining the number of abnormal services in the main server to obtain the number of abnormal services; determining that the main server is abnormal when the proportion of the number of abnormal services in the number of services is greater than or equal to a proportion threshold; determining that the main server is normal when the proportion of the number of abnormal services in the number of services is less than the proportion threshold; Obtaining the number of abnormal services in the main server to obtain the abnormal number includes: obtaining target identification information of the service in the main server, the target identification information indicating whether the service has been updated; in the case where the target identification information indicates that the service has been updated, determining that the service is a non-abnormal service, wherein service update refers to upgrading the deployed service; in the case where the target identification information indicates that the service has not been updated, determining that the service is an abnormal service, and counting the number of abnormal services to obtain the abnormal number; In the case that both the primary server and the backup server are abnormal, the primary server and the backup server are controlled to stop working, and the disaster recovery server is controlled to start working, wherein the disaster recovery server is located in a non-target area.
2. The method according to claim 1, characterized in that When it is determined that the main server is abnormal, controlling the main server to stop working and controlling the backup server to start working includes: When it is determined that the main server is abnormal, controlling a first process on the main server to enter a dormant state, wherein the main server suspends operation when the first process enters the dormant state; The second process on the backup server is controlled to enter a running state, wherein the backup server starts to work when the second process enters the running state.
3. The method according to claim 1, characterized in that The method further comprises: Acquire switching related information, where the switching related information indicates whether to switch the server; Get the type of the current server; A switching mode between servers is determined according to the switching related information and the type of the current server.
4. The method according to claim 3, characterized in that Determining a switching mode between servers according to the switching related information and the type of the current server includes: When the switching related information indicates that the server is to be switched from the primary server to the backup server, and the current server is the backup server, determining not to switch the server and controlling the backup server to continue working; When the switching related information indicates that the main server is to be switched to the backup server, and the current server is the main server, a switching server is determined, the main server is controlled to suspend operation, and the backup server is controlled to start operation.
5. A server abnormality processing device, characterized in that: include: A first acquisition unit is used to acquire the number of active services in the main server, wherein the services are used to execute the functions of the system; A first determining unit is used to determine whether the main server is abnormal according to the number of the services active in the main server, wherein the abnormality of the main server indicates that the failure of the main server causes the main server to be unable to continue to provide relevant data of the service; A first control unit is used to control the main server to stop working and control the backup server to start working when it is determined that the main server is abnormal, wherein the main server and the backup server are respectively in the same target area; The first determination unit includes an acquisition module, a first determination module, and a second determination module. The acquisition module is used to acquire the number of abnormal services in the main server to obtain the number of abnormal services; the first determination module is used to determine that the main server is abnormal when the proportion of the number of abnormal services in the number of services is greater than or equal to the proportion threshold; the second determination module is used to determine that the main server is not abnormal when the proportion of the number of abnormal services in the number of services is less than the proportion threshold; The acquisition module includes an acquisition submodule, a first determination submodule and a second determination submodule, the acquisition submodule is used to acquire the target identification information of the service in the main server, the target identification information indicates whether the service has been updated; the first determination submodule is used to determine that the service is a non-abnormal service when the target identification information indicates that the service has been updated, wherein the service update refers to the upgrade of the deployed service; the second determination submodule is used to determine that the service is an abnormal service when the target identification information indicates that the service has not been updated, and count the number of abnormal services to obtain the abnormal number; The second control unit is used to control the primary server and the backup server to stop working and control the disaster recovery server to start working when both the primary server and the backup server are abnormal, wherein the disaster recovery server is located in a non-target area.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method of any one of claims 1 to 4.
7. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include methods for executing any one of claims 1 to 4.
Citation Information
Patent Citations
Server switching method, MooseFS system and storage medium
CN115145782A