CN116633764A - System switching method, apparatus, computer device, storage medium and computer program product - Google Patents

System switching method, apparatus, computer device, storage medium and computer program product Download PDF

Info

Publication number
CN116633764A
CN116633764A CN202310604973.5A CN202310604973A CN116633764A CN 116633764 A CN116633764 A CN 116633764A CN 202310604973 A CN202310604973 A CN 202310604973A CN 116633764 A CN116633764 A CN 116633764A
Authority
CN
China
Prior art keywords
service
micro
registry
micro service
instances
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310604973.5A
Other languages
Chinese (zh)
Inventor
赵海涛
李明明
宋琳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Taiping Financial Technology Services Shanghai Co Ltd Shenzhen Branch
Original Assignee
Taiping Financial Technology Services Shanghai Co Ltd Shenzhen Branch
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Taiping Financial Technology Services Shanghai Co Ltd Shenzhen Branch filed Critical Taiping Financial Technology Services Shanghai Co Ltd Shenzhen Branch
Priority to CN202310604973.5A priority Critical patent/CN116633764A/en
Publication of CN116633764A publication Critical patent/CN116633764A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/202Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where processing functionality is redundant
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements

Abstract

The present application relates to a system switching method, apparatus, computer device, storage medium and computer program product. The method comprises the following steps: acquiring configuration information of each target registry; acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information; and when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, switching the system corresponding to the faulty micro service into a non-faulty system. The method can enable the system to quickly recover external service, and the registration mechanism of the system registration center taking the whole set of system as a unit avoids system faults caused by thorough faults of micro services in one system, and when all examples of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to a non-faulty system, so that intelligent switching of the system is realized, and normal external service is ensured.

Description

System switching method, apparatus, computer device, storage medium and computer program product
Technical Field
The present application relates to the field of computer technology, and in particular, to a system switching method, apparatus, computer device, storage medium, and computer program product.
Background
With the development of computer technology, a micro-service technology appears, and the traditional micro-service technology is generally registered in a registry, specifically, in general, the same service can start a plurality of instances and register in the registry, and when one service instance is abnormal, the other service instance can ensure the normal operation of the system, so that high availability is realized.
However, current registries can only register and discover each micro-service of an application system, and if all instances of a micro-service in a set of operating systems are problematic, the system cannot be quickly restored.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a system switching method, apparatus, computer device, computer-readable storage medium, and computer program product that enable a system to quickly resume an external service.
In a first aspect, the present application provides a system switching method, the method including:
acquiring configuration information of each target registry;
Acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information;
and when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, switching the system corresponding to the faulty micro service into a non-faulty system.
In one embodiment, the configuration information includes a registry address; the step of obtaining the state information of each micro service in the system corresponding to each target registry according to the configuration information comprises the following steps:
accessing the corresponding target registry according to the registry address to obtain the total number of instances and the number of healthy instances of each micro service;
after the state information of each micro service in the system corresponding to each target registry is obtained according to the configuration information, the method further comprises the following steps:
when the total number of instances of the micro service is larger than a preset value and the number of healthy instances is smaller than the preset value, judging that the micro service has faults;
and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
In one embodiment, the configuration information further includes a system corresponding to the target registry and a system access address corresponding to the system; when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the micro service with the switching fault is a corresponding non-faulty system, and the method comprises the following steps:
and when at least one micro-service in the system corresponding to the target registry fails, replacing the system access address of the system corresponding to the failed micro-service by the system access address of the non-failure system.
In one embodiment, the configuration information includes connection key information; the step of obtaining the state information of each micro service in the system corresponding to each target registry according to the configuration information comprises the following steps:
carrying out one-way or two-way identity verification with the target registry according to the connection key information;
and when the identity verification passes, acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
In one embodiment, the switching the system corresponding to the failed micro service to the non-failed system includes:
The balancing strategy of the load balancing server is modified to not access the system corresponding to the failed micro service and to access the non-failed system.
In one embodiment, before obtaining the configuration information of each target registry, the method includes:
and receiving configuration information in a system unit, and registering the corresponding micro-service in the system to a target registration center corresponding to each system in the micro-service unit.
In a second aspect, the present application also provides a system switching device, including:
the configuration information acquisition module is used for acquiring configuration information of each target registry;
the state information acquisition module is used for acquiring state information of each micro service in the system corresponding to each target registry according to the configuration information;
and the switching module is used for switching the system corresponding to the failed micro service into a non-failed system when all the instances of at least one micro service are judged to be failed according to the state information of each micro service of the system.
In a third aspect, the present application also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of the method of any one of the embodiments described above when the computer program is executed by the processor.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method of any of the embodiments described above.
In a fifth aspect, the application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method of any of the embodiments described above.
The system switching method, the device, the computer equipment, the storage medium and the computer program product adopt the registration mechanism of the system registration center with the whole set of system as a unit, avoid the system fault caused by the complete fault of micro services in one system, and switch the system corresponding to the faulty micro services into a non-faulty system when all the examples of at least one micro service are judged to be faulty according to the state information of each micro service of the system, thereby realizing the intelligent switching of the system and ensuring the normal service to be provided outwards.
Drawings
FIG. 1 is an application environment diagram of a system handoff method in one embodiment;
FIG. 2 is a flow chart of a system switching method in one embodiment;
FIG. 3 is a schematic diagram of a primary and secondary system and a registry in one embodiment;
FIG. 4 is a diagram of configuration information of a target registry in one embodiment;
FIG. 5 is a block diagram of a system switching device in one embodiment;
fig. 6 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The system switching method provided by the embodiment of the application can be applied to an application environment shown in figure 1. Wherein the integrated registry 102 communicates with respective target registries 104 via a network, each target registry 104 communicating with a respective one of the systems 106.
Wherein, each micro-service in each system 106 is registered in a corresponding target registry 104, and each target registry 104 is registered in the integrated registry 102.
The target registries 104 may acquire the state of each micro service in the corresponding system 106, specifically, when the micro service is started, by establishing communication with the server and the port where the corresponding target registries 104 are located, the current starting service instance IP and the instance port information are sent to the target registries 104 in an http request manner, and the target registries store the received starting service instance IP and the port information in json format data to the data file of the target registries 104, so that the target registries 104 can present an available service instance. So that the target registry 104 can monitor the status of each micro-service in the system 106 in real time.
The comprehensive registry 102 may obtain configuration information of each target registry 104; acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information; and when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system and are not recovered within the preset time, switching the system corresponding to the faulty micro service into a non-faulty system. Therefore, the registration mechanism of the system registration center taking the whole set of system as a unit avoids system faults caused by thorough faults of micro services in one system, and when all the examples of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to a non-faulty system, so that intelligent switching of the system is realized, and normal service provision to the outside is ensured.
The integrated registry 102 and the target registry 104 may be implemented by a separate server or a server cluster formed by a plurality of servers. The system 106 may be a system of an application program, where the application program includes a plurality of micro services, and each micro service is registered in a corresponding target registry 104.
In one embodiment, as shown in fig. 2, a system handover method is provided, and the method is applied to the comprehensive registry in fig. 1 for illustration, and includes the following steps:
s202: and acquiring configuration information of each target registry.
Specifically, the target registry corresponds to a system, and one system registers its micro service to one target registry, for example, in an application scenario, the system includes two sets of systems, one set is a main system and one set is a standby system, and two target registries are correspondingly configured, one set is a target registry corresponding to the main system and one set is a target registry corresponding to the standby system, and in other embodiments, other numbers of systems and target registries corresponding to the systems may be configured.
For convenience, in connection with fig. 3, the registry M is a comprehensive registry, the registry a is a target registry corresponding to the main system, and the registry B is a target registry corresponding to the standby system. In the embodiment, the registration mechanism taking the whole set of system as a unit can dynamically monitor the availability of the application in the main system, and dynamically switch to the standby system when all service anomalies are monitored, so that the seamless connection of the main system and the standby system is realized.
One of the systems includes a plurality of micro services, each micro service including a plurality of service instances, such that each system registers its respective service instance of each micro service with a corresponding registry, e.g., the host system registers its respective service instance of each micro service with registry a, and the standby system registers its respective service instance of each micro service with registry B. In other real-time, for example, in a large scene of substitution of domestic software, one system can completely adopt domestic software, and the other system adopts non-domestic software, so that the system can completely perform one-time substitution in the subsequent reconstruction.
When the system is started, relevant configuration of a target registry is configured in project starting configuration files of each system, such as starting service discovery, service name, instance IP, port, health detection address, heartbeat starting, servers and ports where the target registry is located, and the like, so that when the service is started, the current starting service instance IP and instance port information are sent to the target registry 104 in an http request mode through establishing communication with the corresponding servers and ports where the target registry 104 is located, and the target registry stores the received starting service instance IP and the port information in a json format data file of the target registry 104, so that an available service instance appears in the target registry 104. So that the target registry 104 can monitor the status of each micro-service in the system 106 in real time.
The configuration information of the target registry includes information such as the target registry address and port parameters, the system corresponding to the target registry and the system access address corresponding to the system, the identification of the target registry (if in the main and standby system architecture, the code of the target registry may also be included, that is, the code is used to distinguish the main system from the standby system), and the connection key information. It should be noted that the configuration information may be configured by the user in advance, for example, in some alternative embodiments, before the configuration information of each target registry is obtained, the configuration information includes: and receiving configuration information in a system unit, and registering the corresponding micro service in the system to a target registration center corresponding to each system in the micro service unit. For example, a configuration interface of the integrated registry may be opened, and configuration may be completed by inputting relevant configuration information of the target configuration center in the interface. In other embodiments, if the system is an internal system, the corresponding target registry may directly send its own configuration information to the comprehensive registry, so as to complete configuration in units of the system.
S204: and acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
Specifically, the state information of the micro service may include state information of each service instance of the micro service and the number of service instances of the service, for example, state information of instance Q1, state information of instance Q2, and 2 service instances of the micro service Q in one system.
The target registry stores state information of each micro service of the corresponding system, for example, in a data file of the target registry, so that the comprehensive registry can send a request for acquiring the state information of each micro service to each target registry according to the configuration information, thereby receiving the state information of each micro service sent by each target registry.
In one embodiment, in order to ensure data security, the comprehensive registry performs identity verification before acquiring the state information of each micro service from the target registry, so that information leakage is avoided, and in some alternative embodiments, the information communicated between the comprehensive registry and the target registry may be encrypted to ensure information security.
S206: when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to a non-faulty system.
Wherein, since a system includes a plurality of micro services, each micro service corresponds to a plurality of service instances, when all service instances of one micro service fail, the micro service failure is determined, and when all instances of at least one micro service in the system fail and are not recovered within a preset time, the system failure is determined.
In some optional embodiments, the comprehensive registry may switch the system corresponding to the failed micro service to a non-failed system, so that the system providing the service to the outside may still operate normally, and in order to ensure smooth switching, each system shares the database, so that even in the processing process of one task, after the system fails, another system is started, the corresponding data may be obtained from the shared database, so as to continue the task that has not been completed in processing, so as to ensure smooth switching of the system.
In some alternative embodiments, the system may provide services outside in clusters such that upon receiving a service processing request, the load balancing server distributes the service processing request to the corresponding non-failed system. Wherein the balancing policy in the load balancing server is updated by the integrated registry.
In some optional embodiments, the configuration information further includes a system corresponding to the target registry and a system access address corresponding to the system; when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to be a corresponding non-faulty system, and the method comprises the following steps: when at least one micro-service in the system corresponding to the target registry fails, replacing the system access address of the system corresponding to the failed micro-service by the system access address of the non-failed system.
In some of these alternative embodiments, switching the system corresponding to the failed micro service to a non-failed system includes: the balancing strategy of the load balancing server is modified to not access the system corresponding to the failed micro service and to access the non-failed system. For example, when the comprehensive registry determines that one of the systems fails, the information of the system failure is sent to the load balancing server, so that the load balancing server deletes the failed system from the cluster capable of providing service to the outside. In other alternative embodiments, if only the main system and the standby system are included, when the comprehensive registry determines that the main system fails, the comprehensive registry sends information of the main system failure to the load balancing server, so that after the load balancing server obtains the information of the main system failure, the standby system is switched to provide services to the outside, for example, the system access address of the main system is directly replaced by the system access address of the standby system, so that the services are directly routed back to the corresponding standby system.
In other embodiments, after the integrated registry switches the system, the integrated registry further continues to obtain the state information of each micro service of the failed system, and when it is determined that at least one service instance of each micro service in the system is normal according to the state information of each micro service of the failed system, the failed system is reconfigured into a normal system, and corresponding information is sent to the load balancing server, so that the system can continue to provide services to the outside, so that a plurality of systems provide services, the processing capacity of each system is reduced, and the processing efficiency is improved. When only the main system is in standby state, the main system can be used as the standby system after the main system is recovered, and the standby system can be switched to be used as the main system, so that the main system still provides service to the outside, and the standby system only provides service to the outside when the main system fails, so that most of service is provided by domestic software under the condition of substitution of domestic software.
The system switching method uses the registration mechanism of the system registration center with the whole set of system as a unit, avoids the system fault caused by the complete fault of the micro service in one system, and switches the system corresponding to the faulty micro service into a non-faulty system when judging that all the examples of at least one micro service are faulty according to the state information of each micro service of the system, thereby realizing the intelligent switching of the system and ensuring the normal service provision to the outside
In one embodiment, the configuration information includes a target registry address; according to the configuration information, acquiring state information of each micro service in the system corresponding to each target registry, including: accessing a corresponding target registry according to the registry address to obtain the total number of instances and the number of healthy instances of each micro service; according to the configuration information, after obtaining the state information of each micro service in the system corresponding to each target registry, the method further comprises the following steps: when the total number of instances of the micro-service is larger than a preset value and the number of healthy instances is smaller than the preset value, judging that the micro-service fails; and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
The configuration information includes addresses of the respective target registries, so that the comprehensive registry may acquire the state information of the respective micro services from the respective target registries, for example, access the corresponding target registries according to the addresses of the registries, specifically, access the data files of the corresponding target registries, so as to obtain the number of service instances and the number of health instances of the respective micro services of the system registered in the target registries.
For example, taking the above embodiment as an example, the registry M (can be understood as a program) configures, in the start configuration file, server addresses, ports, connection key information, access load addresses corresponding to the system, and registry system codes (used to distinguish between a main system and a standby system) of the registry a and the registry B that need to be connected, respectively, acquires, when starting, server addresses and port parameters of the registry a and the registry B in the configuration, and actively sends a service query http request interface (a service query interface opened by the registry), where the key is used to verify identity information.
At this time, the registry M acquires two service instances Q corresponding to the registry a, and assembles the name of the service instance Q, the number of service instances, the registration center code number and the number of healthy instances into json format data, which is temporarily stored in the memory, and persists to the data file catalog under the relative catalog of the registry M. And calling an interface of the service health state opened by the registry A to acquire the number of the healthy service instances, and updating the number of the healthy instances in the data stored in the last step. In practical applications, the data format is as follows: { "registry A code": "A", "service information": [ { "service name": "Q", "number of service instances": "2", "number of health instances": "2" } ], "whether healthy": true "," run time ":"5H "}.
Similarly, the registry M obtains service instance information corresponding to the registry B, and finally obtains the data structure as follows: the registration center A code number is [ { "A", "service information [ {" service name ":" Q "," number of service instances ":"2"," number of health instances ":"2"} ]," whether the host system ":" true "," whether the host system is healthy ":" true "," running time ":"5H "}, { registration center B code number": "B", "service information" [ { "service name": "Q", "number of service instances": "2", "number of health instances": "2" } ], "whether the host system": "false", "whether the host system is healthy": "true", "running time": "5H" } ].
The above embodiments are described by taking two systems and two target registries as examples, and other numbers of systems and target registries may be provided in other embodiments, which are not limited in particular.
When the total number of instances of the micro service is larger than a preset value and the number of healthy instances is smaller than the preset value, determining that the micro service has a fault; and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal. The preset value here refers to 0, for example, when the number of instances of the service in the system corresponding to the registry a is scanned to be greater than 1, and the number of healthy instances of the current service is smaller than 1, it represents that the set of host systems currently using the registry a has a situation that the individual service is unavailable, and the "whether healthy" attribute value corresponding to the code number of the registry a in the modified memory is false.
In one embodiment, the configuration information includes connection key information; according to the configuration information, acquiring state information of each micro service in the system corresponding to each target registry, including: carrying out one-way or two-way identity verification with a target registration center according to the connection key information; and when the identity verification passes, acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
Specifically, the connection key information may be preconfigured, for example, a token, an asymmetric key or a symmetric key is generated according to information of a corresponding target registry, and then the key is stored in each target registry and a comprehensive registry, so that when micro service state information is acquired, one-way or two-way identity verification is performed with the target registry according to the connection key information, for example, identity authentication is performed according to the token, and then state information of each micro service in the transmission process is encrypted according to the asymmetric key or the symmetric key, so as to ensure data security. When the identity authentication is carried out according to the token, the token transmission can be encrypted through an asymmetric key or a symmetric key, so that the security is ensured.
For the convenience of understanding by those skilled in the art, please continue to refer to fig. 3, where one host system contains different microservices, and the different microservices have multiple service instances, and each of the different microservices is registered with the registry a, and the whole host system is denoted by a reference number S1. One backup system contains different micro services, the different micro services also have a plurality of service instances which are respectively registered in a registration center B, and the code number S2 of the whole backup system is shown in the specification; the primary system S1 and the backup system S2 are registered in atomic units with a registry (M), which is different from conventional service registration and discovery. After the S1 and the S2 are registered in the registry M, each micro-service in the S1 system has health detection in the registry A, when the service is offline or abnormal, the registry A actively takes the abnormal service offline when sending healthy heartbeat to the service instance, if the same service has multiple normal running instances, the normal running of the system is not affected, and if all the instances of the same service are abnormal, the service is affected. At this time, the registration center M needs to be notified through a heartbeat mechanism, the system S1 is abnormal and needs to be disconnected, and then the automatic switching system S2 provides services for the outside normally.
Specifically, firstly, each micro-service of the system S1 is introduced for registration, each micro-service in the system S1 is started respectively, relevant configuration (starting service discovery, service name, instance IP, port, health detection address, heartbeat start, server and port where the registry is located) of the registry is configured in a project starting configuration file, when the service is started, communication is established with the server and port where the registry A is located, the current starting service instance IP and instance port information are sent to the registry in an http request mode to the registry A, and the registry stores the received starting service instance IP and port information in json format data to the registry A data file. At this point the registry will present an available service instance.
In this embodiment, taking one micro service Q in the system S1 as an example, the micro service Q is deployed and two instances (Q1, Q2) are started according to the steps described above, so that there are two available instances of the service Q in the registry.
The registry M (may be understood as a program) configures, in the start configuration file, a server address, a port, connection key information, an access load address corresponding to a system, and a registry system code (for distinguishing a host system and a standby system) of a registry A, B to be connected, obtains, in the start configuration, a server address and a port parameter of a target registry A, B in the configuration, and actively sends a service query http request interface (a service query interface opened by the registry), where the key is used to verify identity information. The key configuration of the starting configuration is shown in the following fig. 4, at this time, the registry M will acquire two service instances Q corresponding to the registry a, and assemble the name, number, code number and number information of healthy instances of the service instances Q into json format data, temporarily store the json format data in the memory, and persist the json format data under the data file directory of the relative directory where the registry M is located. And calling an interface of the service health state opened by the registry A to acquire the number of the healthy service instances, and updating the number of the healthy instances in the data stored in the last step. The data format is as follows: { "registry A code": "A", "service information": [ { "service name": "Q", "number of service instances": "2", "number of health instances": "2" } ], "whether healthy": true "," run time ":"5H "}.
Similarly, the registry M obtains service instance information corresponding to the registry B, and finally obtains the data structure as follows: the registration center A code number is [ { "A", "service information [ {" service name ":" Q "," number of service instances ":"2"," number of health instances ":"2"} ]," whether the host system ":" true "," whether the host system is healthy ":" true "," running time ":"5H "}, { registration center B code number": "B", "service information" [ { "service name": "Q", "number of service instances": "2", "number of health instances": "2" } ], "whether the host system": "false", "whether the host system is healthy": "true", "running time": "5H" } ].
The registration center M establishes connection with the server addresses, ports and keys of the registration centers of the main system and the standby system configured in the starting configuration file from the start, carries out heartbeat control, periodically acquires the registration service information, health information and the like of the registration centers of the main system and the standby system according to the starting parameters (heartbeat time interval, default 10s and other values in other embodiments) in the starting configuration file, updates the data in the memory, and sustains the latest data. Thus, the registration center M acquires the latest registration center A and the latest information and health information of registration services in the registration center B by using a periodical heartbeat mechanism. And meanwhile, the registered data stored in the current memory information are compared regularly, when the number of the instances of the service in the system corresponding to the registry A is greater than 1 and the number of the healthy instances of the current service is less than 1, the condition that the individual service is unavailable exists in the set of main system in the currently used registry A is represented, and whether the attribute value of health corresponding to the code number of the registry A in the memory is modified.
In one embodiment, the default load ratio is 1, where the default system access address URL for providing the service to the outside, the mapped load balancing address URL1 (corresponding to the entry address of the main system access in the registry M configuration file) and URL2 (corresponding to the entry address of the standby system access in the registry M configuration file) are configured: 0, i.e. the primary system is preferentially used. When the health attribute of the main system is detected to be false, and the health attribute of the standby system is detected to be true, the load balancing is notified to set a system interface, and the load ratio is modified to be 0: and 1, the user accesses the URL, and automatically switches to the standby system to operate under the abnormal condition of the main system.
In the above embodiment, the registration mechanism using the whole set of system as a unit is realized, the availability of the application in the main system can be dynamically monitored, and when all service anomalies are monitored, the system is dynamically switched to the standby system, so that the seamless connection of the main system and the standby system is realized.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a system switching device for realizing the above related system switching method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the system switching device provided below may refer to the limitation of the system switching method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 5, there is provided a system switching device, including: a configuration information acquisition module 501, a status information acquisition module 502, and a switching module 503, wherein:
the configuration information obtaining module 501 is configured to obtain configuration information of each target registry.
The state information obtaining module 502 is configured to obtain, according to the configuration information, state information of each micro service in the system corresponding to each target registry.
And a switching module 503, configured to switch, when it is determined that all instances of at least one micro service are faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service to a non-faulty system.
In one embodiment, the configuration information includes a registry address; according to the configuration information, the above-mentioned status information obtaining module 502 is configured to access a corresponding target registry according to the registry address, so as to obtain the total number of instances and the number of healthy instances of each micro service.
The system switching device further includes:
the state judging module is used for judging the micro-service faults when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is smaller than the preset value; and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
In one embodiment, the configuration information further includes a system corresponding to the target registry and a system access address corresponding to the system; the switching module 503 is configured to replace, when at least one micro service in the system corresponding to the target registry fails, the system access address of the system corresponding to the failed micro service with the system access address of the non-failed system.
In one embodiment, the configuration information includes connection key information; the status information acquisition module 502 includes:
and the verification unit is used for carrying out one-way or two-way identity verification with the target registry according to the connection key information.
And the state information acquisition unit is used for acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information when the identity verification passes.
In one embodiment, the switching module 503 is configured to modify the balancing policy of the load balancing server to access the system corresponding to the failed micro service and to access the non-failed system.
In one embodiment, the system switching device further includes:
and the receiving module is used for receiving the configuration information taking the system as a unit, and the corresponding micro-service in the system is registered to the corresponding target registration center of each system by taking the micro-service as a unit.
The respective modules in the system switching device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used to store configuration information. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a system switching method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 6 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided comprising a memory and a processor, the memory having stored therein a computer program, the processor when executing the computer program performing the steps of: acquiring configuration information of each target registry; acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information; when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to a non-faulty system.
In one embodiment, the configuration information involved in executing the computer program by the processor includes a registry address; the processor obtains the state information of each micro service in the system corresponding to each target registry according to the configuration information when executing the computer program, and the method comprises the following steps: accessing a corresponding target registry according to the registry address to obtain the total number of instances and the number of healthy instances of each micro service; after acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information, which is realized when the processor executes the computer program, the method further comprises the steps of: when the total number of instances of the micro-service is larger than a preset value and the number of healthy instances is smaller than the preset value, judging that the micro-service fails; and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
In one embodiment, the configuration information involved in executing the computer program by the processor further includes a system corresponding to the target registry and a system access address corresponding to the system; when all instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to be a corresponding non-faulty system, wherein the system is realized when the processor executes the computer program and comprises: when at least one micro-service in the system corresponding to the target registry fails, replacing the system access address of the system corresponding to the failed micro-service by the system access address of the non-failed system.
In one embodiment, the configuration information involved in executing the computer program by the processor includes connection key information; the processor obtains the state information of each micro service in the system corresponding to each target registry according to the configuration information when executing the computer program, and the method comprises the following steps: carrying out one-way or two-way identity verification with a target registration center according to the connection key information; and when the identity verification passes, acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
In one embodiment, a system implemented when a processor executes a computer program to switch a failed micro-service corresponding system to a non-failed system, includes: the balancing strategy of the load balancing server is modified to not access the system corresponding to the failed micro service and to access the non-failed system.
In one embodiment, before obtaining configuration information of each target registry implemented when the processor executes the computer program, the method includes: and receiving configuration information in a system unit, and registering the corresponding micro service in the system to a target registration center corresponding to each system in the micro service unit.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of: acquiring configuration information of each target registry; acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information; when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to a non-faulty system.
In one embodiment, the configuration information involved in the execution of the computer program by the processor includes a registry address; according to the configuration information, the computer program is executed by the processor to obtain the state information of each micro service in the system corresponding to each target registry, including: accessing a corresponding target registry according to the registry address to obtain the total number of instances and the number of healthy instances of each micro service; according to the configuration information, after obtaining the state information of each micro service in the system corresponding to each target registry, the computer program is implemented when being executed by the processor, and further comprises: when the total number of instances of the micro-service is larger than a preset value and the number of healthy instances is smaller than the preset value, judging that the micro-service fails; and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
In one embodiment, the configuration information involved in the execution of the computer program by the processor further includes a system corresponding to the target registry and a system access address corresponding to the system; when all instances of at least one micro-service are determined to be faulty according to state information of each micro-service of the system, the system corresponding to the faulty micro-service is switched to be a corresponding non-faulty system, which is implemented when the computer program is executed by the processor, and the method comprises the following steps: when at least one micro-service in the system corresponding to the target registry fails, replacing the system access address of the system corresponding to the failed micro-service by the system access address of the non-failed system.
In one embodiment, the configuration information involved when the computer program is executed by the processor includes connection key information; according to the configuration information, the computer program is executed by the processor to obtain the state information of each micro service in the system corresponding to each target registry, including: carrying out one-way or two-way identity verification with a target registration center according to the connection key information; and when the identity verification passes, acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
In one embodiment, a system implemented when a computer program is executed by a processor to switch a failed micro-service corresponding system to a non-failed system, comprising: the balancing strategy of the load balancing server is modified to not access the system corresponding to the failed micro service and to access the non-failed system.
In one embodiment, before obtaining configuration information for each target registry, which is implemented when the computer program is executed by the processor, comprises: and receiving configuration information in a system unit, and registering the corresponding micro service in the system to a target registration center corresponding to each system in the micro service unit.
In one embodiment, a computer program product is provided comprising a computer program which, when executed by a processor, performs the steps of: acquiring configuration information of each target registry; acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information; when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the faulty micro service is switched to a non-faulty system.
In one embodiment, the configuration information involved in the execution of the computer program by the processor includes a registry address; according to the configuration information, the computer program is executed by the processor to obtain the state information of each micro service in the system corresponding to each target registry, including: accessing a corresponding target registry according to the registry address to obtain the total number of instances and the number of healthy instances of each micro service; according to the configuration information, after obtaining the state information of each micro service in the system corresponding to each target registry, the computer program is implemented when being executed by the processor, and further comprises: when the total number of instances of the micro-service is larger than a preset value and the number of healthy instances is smaller than the preset value, judging that the micro-service fails; and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
In one embodiment, the configuration information involved in the execution of the computer program by the processor further includes a system corresponding to the target registry and a system access address corresponding to the system; when all instances of at least one micro-service are determined to be faulty according to state information of each micro-service of the system, the system corresponding to the faulty micro-service is switched to be a corresponding non-faulty system, which is implemented when the computer program is executed by the processor, and the method comprises the following steps: when at least one micro-service in the system corresponding to the target registry fails, replacing the system access address of the system corresponding to the failed micro-service by the system access address of the non-failed system.
In one embodiment, the configuration information involved when the computer program is executed by the processor includes connection key information; according to the configuration information, the computer program is executed by the processor to obtain the state information of each micro service in the system corresponding to each target registry, including: carrying out one-way or two-way identity verification with a target registration center according to the connection key information; and when the identity verification passes, acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
In one embodiment, a system implemented when a computer program is executed by a processor to switch a failed micro-service corresponding system to a non-failed system, comprising: the balancing strategy of the load balancing server is modified to not access the system corresponding to the failed micro service and to access the non-failed system.
In one embodiment, before obtaining configuration information for each target registry, which is implemented when the computer program is executed by the processor, comprises: and receiving configuration information in a system unit, and registering the corresponding micro service in the system to a target registration center corresponding to each system in the micro service unit.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile memory may include Read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high density embedded nonvolatile memory, resistive memory (ReRAM), magnetic memory (MagnetoresistiveRandomAccessMemory, MRAM), ferroelectric memory (FerroelectricRandomAccessMemory, FRAM), phase change memory (PhaseChange Memory, PCM), graphene memory, and the like. Volatile memory may include random access memory (RandomAccessMemory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can take many forms, such as static random access memory (StaticRandomAccess Memory, SRAM) or dynamic random access memory (DynamicRandomAccessMemory, DRAM), among others. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (10)

1. A system handoff method, the method comprising:
acquiring configuration information of each target registry;
acquiring state information of each micro service in a system corresponding to each target registry according to the configuration information;
and when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, switching the system corresponding to the faulty micro service into a non-faulty system.
2. The method of claim 1, wherein the configuration information comprises a registry address; the step of obtaining the state information of each micro service in the system corresponding to each target registry according to the configuration information comprises the following steps:
accessing the corresponding target registry according to the registry address to obtain the total number of instances and the number of healthy instances of each micro service;
after the state information of each micro service in the system corresponding to each target registry is obtained according to the configuration information, the method further comprises the following steps:
when the total number of instances of the micro service is larger than a preset value and the number of healthy instances is smaller than the preset value, judging that the micro service has faults;
and when the total number of the instances of the micro-service is larger than a preset value and the number of the healthy instances is larger than or equal to the preset value, judging that the micro-service is normal.
3. The method of claim 2, wherein the configuration information further includes a system corresponding to the target registry and a system access address corresponding to the system; when all the instances of at least one micro service are judged to be faulty according to the state information of each micro service of the system, the system corresponding to the micro service with the switching fault is a corresponding non-faulty system, and the method comprises the following steps:
And when all the instances of at least one micro service in the system corresponding to the target registry are failed, replacing the system access address of the system corresponding to the failed micro service by the system access address of the non-failed system.
4. The method of claim 1, wherein the configuration information comprises connection key information; the step of obtaining the state information of each micro service in the system corresponding to each target registry according to the configuration information comprises the following steps:
carrying out one-way or two-way identity verification with the target registry according to the connection key information;
and when the identity verification passes, acquiring the state information of each micro service in the system corresponding to each target registry according to the configuration information.
5. The method according to any one of claims 1 to 4, wherein switching the system corresponding to the failed micro service to a non-failed system comprises:
the balancing strategy of the load balancing server is modified to not access the system corresponding to the failed micro service and to access the non-failed system.
6. The method according to any one of claims 1 to 4, wherein before obtaining the configuration information of each target registry, the method includes:
And receiving configuration information in a system unit, and registering the corresponding micro-service in the system to a target registration center corresponding to each system in the micro-service unit.
7. A system switching device, the device comprising:
the configuration information acquisition module is used for acquiring configuration information of each target registry;
the state information acquisition module is used for acquiring state information of each micro service in the system corresponding to each target registry according to the configuration information;
and the switching module is used for switching the system corresponding to the failed micro service into a non-failed system when all the instances of at least one micro service are judged to be failed according to the state information of each micro service of the system.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202310604973.5A 2023-05-26 2023-05-26 System switching method, apparatus, computer device, storage medium and computer program product Pending CN116633764A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310604973.5A CN116633764A (en) 2023-05-26 2023-05-26 System switching method, apparatus, computer device, storage medium and computer program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310604973.5A CN116633764A (en) 2023-05-26 2023-05-26 System switching method, apparatus, computer device, storage medium and computer program product

Publications (1)

Publication Number Publication Date
CN116633764A true CN116633764A (en) 2023-08-22

Family

ID=87612920

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310604973.5A Pending CN116633764A (en) 2023-05-26 2023-05-26 System switching method, apparatus, computer device, storage medium and computer program product

Country Status (1)

Country Link
CN (1) CN116633764A (en)

Similar Documents

Publication Publication Date Title
US9817721B1 (en) High availability management techniques for cluster resources
US9037899B2 (en) Automated node fencing integrated within a quorum service of a cluster infrastructure
CN109618000B (en) Master-slave switching method, device and system of load balancing service and server
CN103795553B (en) Active and standby server switching based on monitoring
US7518983B2 (en) Proxy response apparatus
CN106210151A (en) A kind of zedis distributed caching and server cluster monitoring method
WO2019210580A1 (en) Access request processing method, apparatus, computer device, and storage medium
EP1518385A1 (en) Opc server redirection manager
CN111176888B (en) Disaster recovery method, device and system for cloud storage
CN112866408B (en) Service switching method, device, equipment and storage medium in cluster
CN111198921A (en) Database switching method and device, computer equipment and storage medium
CN105490847B (en) A kind of private cloud storage system interior joint failure real-time detection and processing method
JP5326308B2 (en) Computer link method and system
CN116633764A (en) System switching method, apparatus, computer device, storage medium and computer program product
CN113596195B (en) Public IP address management method, device, main node and storage medium
CN114840495A (en) Database cluster split-brain prevention method, storage medium and device
JP2022524931A (en) Detection and resolution of node failures in distributed databases
CN117478299B (en) Block chain consensus algorithm switching method, device and computer equipment
CN112801769B (en) Accounting data processing method, device and system
CN116647468A (en) Registration center configuration method, registration center configuration device, computer equipment and storage medium
CN114928654A (en) Node state monitoring method, device, equipment, storage medium and program product
Khramenkova et al. Tasks of decentralized SpaceWire-Plug-and-Play algorithm
CN115277379A (en) Distributed lock disaster tolerance processing method and device, electronic equipment and storage medium
CN116760695A (en) Server switching method, device, apparatus, storage medium and program product
CN117472537A (en) Financial business processing method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination