Business service high-availability system, main-standby switching method and device and electronic equipment
By designing service management component clusters and service node registration and switching mechanisms for multi-region and multi-computer rooms in a high-availability system for service services, the service service interruption problem caused by service node failure or excessive load in the existing technology is solved, and the service service is realized high availability and continuous operation.
Patent Information
- Application Number
- CN202411453153.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-02-11
AI Technical Summary
When the service node fails or the load is too high, the existing application architecture cannot guarantee the continuous operation of business services, resulting in a decline in user experience.
Design a high-availability system for business services, including a service management component cluster and multiple service nodes deployed with the same business service application. The service node registers temporary nodes based on host information when starting, and the service management component cluster determines the master according to the registration order. Service nodes and standby service nodes, and monitor delete events in real time to redefine the primary and standby nodes.
It realizes that when the service node fails or the load is too high, it quickly switches to the backup service node to ensure the continuous operation of business services, greatly improving the user experience.
Smart Images

Figure CN119420633A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of software technology, and in particular to a business service high-availability system, a primary-standby switching method, a device, and an electronic device. Background Art
[0002] Most of the existing application architectures are stand-alone environments. When the service node where the application is located encounters a network failure, service downtime, or the CPU or memory of the service node exceeds a certain threshold, resulting in service unavailability, the entire system will be unable to provide the business services required by users, seriously affecting normal user use and causing a decline in user experience. Summary of the invention
[0003] In view of this, in order to ensure the continuous operation of business services, embodiments of the present application provide a business service high-availability system, a primary-standby switching method, a device, and an electronic device.
[0004] In a first aspect, an embodiment of the present application provides a business service high availability system, the business service high availability system comprising a service management component cluster and a plurality of service nodes deployed with the same business service application, the plurality of service nodes being located in computer rooms in different regions;
[0005] The service node is used to register the temporary node under the registration directory node of the service management component cluster based on the host information at startup;
[0006] The service management component cluster is used to determine a primary service node and a backup service node from a plurality of service nodes according to the registration order of each temporary node; wherein the primary service node is used to execute a business service based on a business service application program;
[0007] The deletion events of each temporary node are monitored in real time. When the deletion event is detected to be the deletion event of the temporary node corresponding to the primary service node, the primary and backup nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node.
[0008] In a possible implementation, registering a temporary node under a registration directory node of a service management component cluster based on host information includes:
[0009] Create a temporary node under the registration directory node of the service management component cluster;
[0010] Write the host information into the corresponding temporary node.
[0011] In a possible implementation, determining a primary service node and a backup service node from a plurality of service nodes according to the registration order of each temporary node includes:
[0012] Extract host information from the temporary node that is registered first;
[0013] Write the host information into the registration directory node;
[0014] The service node corresponding to the host information written into the registration directory node is determined as the primary service node, and the service node corresponding to the host information not written into the registration directory node is determined as the backup service node.
[0015] In a possible implementation manner, the service node is further configured to:
[0016] Establish a first listening thread for the registration directory node;
[0017] Based on the first monitoring thread, real-time monitoring is performed on the registration directory node to determine whether the host information is written;
[0018] When monitoring the host information written by the registration directory node, determine whether the written host information is consistent with the host information of the service node;
[0019] If the written host information is consistent with the host information of the service node, the service upgrade main thread is executed, and after the service upgrade main thread is completed, the business service thread is started to execute the business service based on the business service application; wherein, the service upgrade main thread is a thread with a distributed lock;
[0020] If the written host information is inconsistent with the host information of the service node, the master-slave establishment thread is executed based on the written host information, and after the master-slave establishment thread is completed, the business service thread that executes the business service based on the business service application is closed.
[0021] In a possible implementation, the business service high availability system further includes a storage database deployed on each service node;
[0022] The main service node is also used to, after the service upgrade thread is completed, trigger the database upgrade thread to set the storage database under the main service node as the main storage database, and after the database upgrade thread is completed, write the library information of the main storage database to the database supervision node of the service management component cluster; wherein the library information includes the database upgrade completion mark and host information;
[0023] The standby service node is used to establish a second monitoring thread for the database supervision node;
[0024] In the case where the database supervision node writes the library information based on the second listening thread, the database master-slave establishment thread is executed based on the host information in the library information to set the storage database under the standby service node as the standby storage database;
[0025] The main storage database is used to store the business data generated by the main service node when executing business services;
[0026] The backup storage database is used to synchronously store the business data on the primary storage database.
[0027] In one possible implementation, the service node is also used to re-register a temporary node under the registration directory node after fault recovery, and execute the master-slave establishment thread and the database master-slave establishment thread after registration is completed to synchronize business data during the fault and real-time business data with the main storage database under the new main service node after the re-determination of the master-slave.
[0028] In a second aspect, an embodiment of the present application provides a primary-standby switching method, which is applied to the above-mentioned business service high availability system, and the method includes:
[0029] At startup, register the temporary node under the registration directory node of the service management component cluster based on the host information;
[0030] The trigger service management component cluster determines the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node, and monitors the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and backup service nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node; among which, the main service node is used to execute business services based on business service applications.
[0031] In a third aspect, an embodiment of the present application provides a primary-standby switching method, which is applied to the above-mentioned business service high availability system, and the method includes:
[0032] After monitoring that the service node completes the temporary node registration based on the host information, a main service node and a backup service node are determined from multiple service nodes according to the registration order of each temporary node; wherein the main service node is used to execute the business service based on the business service application;
[0033] The deletion events of each temporary node are monitored in real time. When the deletion event is detected to be the deletion event of the temporary node corresponding to the primary service node, the primary and backup nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node.
[0034] In a fourth aspect, an embodiment of the present application provides a master-slave switching device, the device comprising:
[0035] A registration module, used to register a temporary node under a registration directory node of a service management component cluster based on host information at startup;
[0036] A trigger module is used to trigger the service management component cluster to determine the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node, and monitor the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and backup nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node; wherein the main service node is used to execute business services based on business service applications.
[0037] In a fifth aspect, an embodiment of the present application provides a master-slave switching device, the device comprising:
[0038] A primary and backup determination module is used to determine a primary service node and a backup service node from multiple service nodes according to the registration order of each temporary node after monitoring that the service node completes the temporary node registration based on the host information; wherein the primary service node is used to execute the business service based on the business service application;
[0039] The master-slave switching module is used to monitor the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the primary service node, the master-slave is re-determined according to the registration order of the temporary nodes corresponding to each backup service node.
[0040] In a sixth aspect, an embodiment of the present application provides an electronic device, which includes: a processor and a memory, the processor is used to execute the master-slave switching program stored in the memory to implement the above-mentioned master-slave switching method.
[0041] In a seventh aspect, an embodiment of the present application provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned master-slave switching method.
[0042] The embodiments of the present application provide a high-availability system for business services, a method for switching between active and standby nodes, an apparatus, and an electronic device. The high-availability system for business services includes a service management component cluster and multiple service nodes deployed with the same business service application, and the multiple service nodes are located in different regional computer rooms; the service node is used to register a temporary node under the registration directory node of the service management component cluster based on the host information at startup; the service management component cluster is used to determine the main service node and the standby service node from multiple service nodes according to the registration order of each temporary node; wherein the main service node is used to perform business services based on the business service application; the deletion events of each temporary node are monitored in real time, and when the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and standby are re-determined according to the registration order of the temporary nodes corresponding to each standby service node. The above-mentioned high-availability system for business services adopts a multi-regional, multi-computer room, multi-node, and multi-active disaster recovery architecture. When the main service node providing business services fails, the service management component cluster can determine the main and standby service nodes to ensure the high availability of the service nodes, thereby ensuring the continuity of business services, which greatly improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of the structure of a high-availability business service system provided in an embodiment of the present application;
[0044] Figure 2 A schematic diagram of the structure of another business service high availability system provided in an embodiment of the present application;
[0045] Figure 3 A flowchart of an embodiment of a primary-standby switching method provided in an embodiment of the present application;
[0046] Figure 4 A flowchart of another active-standby switching method provided in an embodiment of the present application;
[0047] Figure 5 A block diagram of an embodiment of a master-slave switching device provided in an embodiment of the present application;
[0048] Figure 6 A block diagram of another embodiment of a master-slave switching device provided in an embodiment of the present application;
[0049] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, 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 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 are within the scope of protection of this application.
[0051] To facilitate understanding of the embodiments of the present application, further explanation will be given below with reference to specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present application.
[0052] The present application embodiment provides a high-availability business service system, such as Figure 1 As shown, the business service high availability system 100 includes a service management component cluster 101 and multiple service nodes 102 deployed with the same business service application, and the multiple service nodes 102 are located in different regional computer rooms. The service management component cluster 101 is in communication connection with each service node 102 .
[0053] In this embodiment, a business service application that implements the same business service is deployed on at least one service node in different regional computer rooms, where there are at least three regional computer rooms. For example, a two-site three-center solution can be used, which includes a production center computer room, a disaster recovery center computer room in the same city, and a disaster recovery center computer room in a different location. In this case, the business service application is deployed on at least one service node in each center computer room so that the service node where the business service application is deployed can execute the same business service.
[0054] Among them, the deployment of business service applications on service nodes is based on the required business service requirements. If the required business service is to synchronously migrate data from a relational database to a distributed database, then a business service application that can implement asynchronous database data migration is deployed on the service node, so that the service node can implement asynchronous data migration based on the business service application. If the required business service is a network transaction, then a business service application that can implement a network transaction is deployed on the service node.
[0055] Since the service management component cluster is a zookeeper cluster, in order to ensure the high availability of the service management component cluster, at least three or five odd-numbered service nodes are selected in different regional computer rooms to deploy the service management component cluster. For example, if it relies on three centers in two locations, one service node can be selected in each central computer room to deploy the service management component cluster.
[0056] The service node 102 is used to register a temporary node under a registration directory node of a service management component cluster based on host information when starting up;
[0057] In a specific implementation, the host information includes but is not limited to the IP (Internet Protocol, a protocol for interconnecting networks) address and external port number of the service node. The temporary node is registered under the registration directory node of the service management component cluster based on the host information, including:
[0058] Create a temporary node under the registration directory node of the service management component cluster; write the host information into the corresponding temporary node.
[0059] Each service node creates a temporary node with the same prefix under the same registration directory node of the service management component cluster, and writes the host information to the corresponding temporary node to complete the registration. Due to the difference in the startup time of each service node, the created temporary nodes are sorted in order under the registration directory node according to the creation time.
[0060] For ease of understanding, Figure 2 As shown, the business service application 200 is deployed on server1, server2 and server3, where server1, server2 and server3 are all service nodes 102, server1 creates temporary node 1 under the registration directory node 201, server2 creates temporary node 2 under the registration directory node 201, and server3 creates temporary node 3 under the registration directory node 201. The three temporary nodes are arranged in descending order according to the order of creation.
[0061] The characteristic of temporary nodes is that they will be automatically deleted when the service node encounters network failure, service downtime, or CPU (Central Processing Unit) or memory exceeds a certain threshold, resulting in service unavailability and disconnection. The order of temporary nodes is a sequence maintained by the service management component cluster itself, which can ensure the correctness of the creation order of each temporary node.
[0062] The above-mentioned service management component cluster 101 is used to determine the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node; wherein the main service node is used to execute business services based on business service applications; and monitor the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and backup nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node.
[0063] In a specific implementation, a main service node and a backup service node are determined from multiple service nodes according to the registration order of each temporary node, including: extracting host information from the temporary node that completes registration first; writing the host information into a registration directory node; determining the service node corresponding to the host information written into the registration directory node as the main service node, and determining the service node corresponding to the host information not written into the registration directory node as the backup service node.
[0064] For ease of understanding, Figure 2 As shown, since server1 first completed the registration of temporary node 1 under registration directory node 201, host information 1 of server1 is written in temporary node 1, and service management component cluster 101 extracts host information 1 in temporary node 1 and writes it into the parent directory of each temporary node, namely registration directory node 201, to determine that server1 corresponding to host information 1 is the primary service node, and server2 and server3 are backup service nodes corresponding to server1, the primary service node. In this embodiment, server1, as the primary service node, executes business services based on business service application 200, while server2 and server3, as backup service nodes of server1, do not execute business services on the business service application 200 deployed on their nodes.
[0065] In specific applications, after the service management component cluster learns through the deletion event that the temporary node of the primary service node has been deleted, it will re-determine the primary and backup nodes according to the registration order of the temporary nodes corresponding to each backup service node, so that after the original primary service node fails, other backup service nodes can take over the original primary service node and become the new primary service node to execute business services, fully ensuring the high availability of business services. If the deletion event is not the deletion of the temporary node of the primary service node, there is no need to re-determine the primary and backup nodes.
[0066] Among them, the master and backup are re-determined according to the registration order of the temporary nodes corresponding to each backup service node, including: determining the temporary node corresponding to the backup service node that has completed registration first according to the registration order of the temporary nodes corresponding to each backup service node, and extracting the host information of the corresponding backup service node from the temporary node; writing the host information into the registration directory node; determining the backup service node corresponding to the host information written into the registration directory node as the new master service node, and determining the backup service node corresponding to the host information not written into the registration directory node as the backup service node corresponding to the new master service node.
[0067] For ease of explanation, Figure 2As shown, after temporary node 1 is deleted from the registration directory node, only temporary node 2 and temporary node 3 are left. Since temporary node 2 completes registration before temporary node 3, the service management component cluster extracts host information 2 of server2 from temporary node 2 and writes it into the registration directory node to determine that server2 corresponding to host information 2 is the new primary service node, and server3 is the backup service node corresponding to server2, the new primary service node server2, executes business services based on business service applications.
[0068] For example, when a failure occurs during the execution of the asynchronous database data migration business service by the primary service node server1 based on the business service application, the new primary service node server2 determined by the service management component cluster continues to execute the asynchronous database data migration business service based on the business service application.
[0069] The service management component cluster 101 is only used to determine the master and backup. After the master and backup are determined, the master service node needs to perform an upgrade operation to perform business service processing. Each backup service node also needs to establish a master-backup relationship to prevent the backup service node from performing business service processing. Specifically, after the service management component cluster 101 determines the master and backup service nodes or re-determines the master and backup, each service node 102 is used to: establish a first listening thread for the registration directory node; monitor the registration directory node in real time based on the first listening thread to see if the host information is written ; When monitoring the host information written by the registration directory node, determine whether the written host information is consistent with the host information of the service node; if the written host information is consistent with the host information of the service node, execute the service upgrade thread, and start the business service thread after the service upgrade thread is completed, so as to execute the business service based on the business service application; wherein, the service upgrade thread is a thread with a distributed lock; if the written host information is inconsistent with the host information of the service node, execute the master-slave establishment thread based on the written host information, and close the business service thread that executes the business service based on the business service application after the master-slave establishment thread is completed.
[0070] The above-mentioned first listening thread is established when the service node is started, and is mainly used to monitor the registration directory node in real time, so as to determine whether the host information written by the registration directory node is consistent with its own host information after monitoring it. If the host information written to the registration directory node is consistent with its own host information, it indicates that it is the main service node, then it is necessary to execute the service upgrade thread. The service upgrade thread is the specific operation of upgrading the service node to the main one, which can be further understood as upgrading the business service application deployed on its own service node to the main one, so as to start the business service thread after the service upgrade thread is completed, and execute business services based on the business service application; the business service thread includes but is not limited to opening page access, background timer task global switch and processing business service threads.
[0071] Among them, the service upgrade main thread is a thread with a distributed lock, that is, other processes are blocked during the execution of the service upgrade main thread to prevent multiple service nodes from operating the same data at the same time, resulting in data inconsistency.
[0072] If the host information written into the registration directory node is inconsistent with its own host information, it indicates that it is a backup service node. Then, after the main service upgrade thread is completed, it is necessary to execute the master-slave establishment thread based on the host information of the main service node written into the registration directory node, so as to connect each backup service node to the main service node based on the host information of the main service node. After each backup service node establishes a master-slave relationship with the main service node, each backup service node needs to close the business service thread and stop working. However, each backup service node is in a survival state, so that after the service management component cluster re-determines the master and backup, the backup service node can quickly complete the service upgrade thread and continue to execute related business services.
[0073] The high-availability business service system provided by this embodiment can achieve rapid master-slave switching when encountering network failure or machine failure during the business service process, which greatly improves the high availability of the system; it avoids the probability of the entire business service being paralyzed or unavailable due to sudden failures to a very high degree, and the disaster recovery architecture with multiple regions, multiple computer rooms, and multiple active service nodes has basically the same business service processing capabilities, thereby ensuring the continuous operation of business services and greatly improving user experience.
[0074] In order to be able to have a detailed understanding of the execution process of the main service node in executing business services based on business service applications, such as Figure 2 As shown, the above-mentioned business service high availability system also includes a storage database 202 deployed on each service node; in order to enable each storage database to be used normally, it is also necessary to perform corresponding settings on the storage database deployed under each service node after the active and standby service nodes execute the threads after the active and standby determination.
[0075] Specifically, the main service node is also used to trigger the database upgrade thread after the service upgrade thread is completed, so as to set the storage database under the main service node as the main storage database, and after the database upgrade thread is completed, write the library information of the main storage database to the database supervision node of the service management component cluster; wherein the library information includes the database upgrade completion identifier and host information; the standby service node is used to establish a second listening thread for the database supervision node; when the second listening thread monitors the database supervision node writing library information, execute the database master-standby establishment thread based on the host information in the library information, so as to set the storage database under the standby service node as the standby storage database; the main storage database is used to store the business data generated by the main service node executing the business service; the standby storage database is used to synchronously store the business data on the main storage database.
[0076] like Figure 2 As shown, after the main service node sets the storage database deployed by itself as the main storage database, the main storage database can store business data, and at the same time, the main service node writes the library information to the database supervision node 203 of the service management component cluster to indicate that the main storage database is set up. Among them, the database upgrade thread is also a thread with a distributed lock to prevent the storage databases of other service nodes from starting to execute data storage before the main storage database is upgraded to the main one, resulting in inconsistent data stored between the storage databases.
[0077] When each standby service node monitors the database supervision node for library information writing through the established second listening thread, it indicates that the database upgrade thread has been completed, then each standby service node can execute the database master-standby establishment thread to set the storage database under each standby service node as a standby storage database, and connect each standby storage database to the main storage database to synchronize the business data on the main storage database; wherein, the second listening thread can be established during or after the main service node executes the service upgrade thread.
[0078] The business service high-availability system includes multiple backup storage databases that store business data copies. In the event of a disaster, it can perform disaster recovery emergency switching with little data loss to keep the business running continuously.
[0079] Usually, any service node in the business service high-availability system can re-register as a temporary node under the registration directory node after failure recovery. After registration is completed, the master-slave establishment thread and the database master-slave establishment thread are executed to synchronize business data during the failure and real-time business data with the main storage database under the new main service node after the re-master-slave determination.
[0080] The failed service node re-establishes the master-slave relationship with the new master service node, so that it can participate in a new round of master-slave determination when the new master service node fails, and the storage database deployed under the failed service node is connected to the new master storage database and reused for business data synchronization of the new master service node.
[0081] Based on the above-mentioned business service high availability system, the embodiment of the present application provides a primary-standby switching method, which is applied to the service node of the above-mentioned business service high availability system, see Figure 3 , Figure 3 A flow chart of an embodiment of a primary-standby switching method provided in an embodiment of the present application. Figure 3 The process shown may include the following steps:
[0082] Step 301, at startup, registering a temporary node under a registration directory node of a service management component cluster based on host information;
[0083] When multiple service nodes in the business service high availability system are started, they are registered as temporary nodes under the registration directory node of the service management component cluster based on their respective host information to indicate that their own service nodes are in a surviving state and can be used to determine the primary and backup service nodes and perform corresponding operations.
[0084] Step 302, trigger the service management component cluster to determine the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node, and monitor the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and backup service nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node; wherein, the main service node is used to execute business services based on business service applications.
[0085] The service management component cluster can determine the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node, so as to use the main service node to perform business services based on the business service application, and after the temporary node is deleted in the service management component cluster when the main service node fails, it can re-determine the new main service node from multiple backup service nodes based on the registration order of the temporary nodes of each backup service node. The specific main and backup determination process can be found in the above description and will not be repeated here. The above-mentioned main-backup switching method can determine the new main service node in time after the original main service node fails, so that the new main service node can continue to perform business services based on the business service application, thereby ensuring the high availability of the service node, which can be further understood as ensuring the high availability of the business service application, thereby ensuring the continuity of the business service, and greatly improving the user experience.
[0086] Based on the above-mentioned business service high availability system, the embodiment of the present application provides a primary-standby switching method, which is applied to the service management component cluster of the above-mentioned business service high availability system, see Figure 4 , Figure 4 A flow chart of an embodiment of a primary-standby switching method provided in an embodiment of the present application. Figure 4 The process shown may include the following steps:
[0087] Step 401, after monitoring that the service node completes the temporary node registration based on the host information, determine the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node; wherein the main service node is used to perform business services based on the business service application;
[0088] Step 402, monitoring deletion events of each temporary node in real time, when monitoring the deletion event is a deletion event of the temporary node corresponding to the primary service node, re-determine the primary and backup nodes according to the registration order of the temporary nodes corresponding to each backup service node.
[0089] The implementation process is the same as above and will not be described here. The above-mentioned master-slave switching method can promptly determine a new master service node after the original master service node fails, so that the new master service node can continue to perform business services based on the business service application, thereby ensuring the high availability of the service node. It can be further understood as ensuring the high availability of the business service application, thereby ensuring the continuity of the business service, and greatly improving the user experience.
[0090] See also Figure 5 , which is a block diagram of an embodiment of a master-slave switching device provided in an embodiment of the present application.
[0091] like Figure 5 As shown, the device comprises:
[0092] The registration module 501 is used to register the temporary node under the registration directory node of the service management component cluster based on the host information at startup;
[0093] Trigger module 502 is used to trigger the service management component cluster to determine the main service node and the backup service node from multiple service nodes according to the registration order of each temporary node, and monitor the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and backup service nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node; wherein, the main service node is used to execute business services based on business service applications.
[0094] See also Figure 6 , which is a block diagram of an embodiment of a master-slave switching device provided in an embodiment of the present application.
[0095] like Figure 6 As shown, the device comprises:
[0096] The primary and backup determination module 601 is used to determine the primary service node and the backup service node from multiple service nodes according to the registration order of each temporary node after monitoring that the service node completes the temporary node registration based on the host information; wherein the primary service node is used to perform business services based on the business service application;
[0097] The active / standby switching module 602 is used to monitor the deletion events of each temporary node in real time. When the deletion event is detected to be the deletion event of the temporary node corresponding to the active service node, the active / standby switching module 602 re-determines the active / standby status according to the registration order of the temporary nodes corresponding to the standby service nodes.
[0098] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, Figure 7 The electronic device 700 shown includes: at least one processor 701, a memory 702, at least one network interface 704 and other user interfaces 703. The various components in the electronic device 700 are coupled together via a bus system 705. It is understood that the bus system 705 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 705 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 705 is not described in detail. Figure 7 Various buses are labeled as bus system 705.
[0099] The user interface 703 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0100] It can be understood that the memory 702 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 702 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0101] In some implementations, the memory 702 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 7021 and an application 7022 .
[0102] The operating system 7021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 7022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present application can be included in the application 7022.
[0103] In the embodiment of the present application, by calling the program or instructions stored in the memory 702, specifically, the program or instructions stored in the application 7022, the processor 701 is used to execute the method steps provided by each method embodiment.
[0104] The method disclosed in the above embodiment of the present application can be applied to the processor 701, or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 701 or the instruction in the form of software. The above processor 701 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 702, and the processor 701 reads the information in the memory 702 and completes the steps of the above method in combination with its hardware.
[0105] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0106] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0107] The electronic device provided in this embodiment may be Figure 7 The electronic device shown in FIG. 1 may perform the following steps: Figure 3-4 All steps of the active-standby switching method in the Figure 3-4 For details, please refer to Figure 3-4 For the sake of brevity, the relevant description is not repeated here.
[0108] The embodiment of the present application also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0109] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned active-standby switching method can be implemented.
[0110] The processor is used to execute the active / standby switching program stored in the memory to implement the following steps of the active / standby switching method.
[0111] The professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0112] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0113] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation method of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A business service high availability system, characterized in that: The business service high availability system includes a service management component cluster and multiple service nodes deployed with the same business service application, and the multiple service nodes are located in computer rooms in different regions; The service node is used to register a temporary node under a registration directory node of the service management component cluster based on host information when starting; The service management component cluster is used to determine a primary service node and a backup service node from a plurality of the service nodes according to a registration order of each of the temporary nodes; wherein the primary service node is used to execute a business service based on the business service application; The deletion events of the temporary nodes are monitored in real time. When the deletion event is detected to be the deletion event of the temporary node corresponding to the primary service node, the primary and backup nodes are re-determined according to the registration order of the temporary nodes corresponding to the backup service nodes.
2. The business service high availability system according to claim 1, characterized in that: The registering of the temporary node under the registration directory node of the service management component cluster based on the host information includes: Creating a temporary node under a registration directory node of the service management component cluster; The host information is written into the corresponding temporary node.
3. The business service high availability system according to claim 2, characterized in that: The determining the main service node and the backup service node from the plurality of service nodes according to the registration order of each of the temporary nodes includes: Extracting host information from the temporary node that is first registered; Writing the host information into the registration directory node; The service node corresponding to the host information written into the registration directory node is determined as the primary service node, and the service node corresponding to the host information not written into the registration directory node is determined as the backup service node.
4. The business service high availability system according to claim 3, characterized in that: The service node is also used for: Establishing a first listening thread for the registration directory node; Based on the first monitoring thread, real-time monitoring is performed on the registration directory node to determine whether the host information is written; In the case of monitoring that the registration directory node writes the host information, determining whether the written host information is consistent with the host information of the service node; If the written host information is consistent with the host information of the service node, the service upgrade main thread is executed, and after the service upgrade main thread is completed, the business service thread is started to execute the business service based on the business service application; wherein the service upgrade main thread is a thread with a distributed lock; If the written host information is inconsistent with the host information of the service node, the master-slave establishment thread is executed based on the written host information, and after the master-slave establishment thread is completed, the business service thread that executes the business service based on the business service application is closed.
5. The business service high availability system according to claim 4, characterized in that: The business service high availability system also includes a storage database deployed on each of the service nodes; The master service node is also used to trigger the database upgrade thread after the service upgrade thread is completed, so as to set the storage database under the master service node as the master storage database, and write the library information of the master storage database to the database supervision node of the service management component cluster after the database upgrade thread is completed; wherein the library information includes the database upgrade completion mark and the host information; The standby service node is used to establish a second monitoring thread for the database supervision node; In the case where the database supervision node writes the library information based on the second listening thread, executing the database master-slave establishment thread based on the host information in the library information to set the storage database under the standby service node as the standby storage database; The primary storage database is used to store the service data generated by the primary service node executing the service service; The backup storage database is used to synchronously store the business data on the primary storage database.
6. The business service high availability system according to claim 5, characterized in that: The service node is also used to re-register a temporary node under the registration directory node after fault recovery, and execute the master-slave establishment thread and the database master-slave establishment thread after registration is completed to synchronize business data and real-time business data during the fault with the main storage database under the new main service node after the re-master-slave determination.
7. A method for switching between active and standby devices, characterized in that: The method is applied to the business service high availability system according to any one of claims 1 to 6, and the method comprises: At startup, register the temporary node under the registration directory node of the service management component cluster based on the host information; The service management component cluster is triggered to determine the main service node and the backup service node from the multiple service nodes according to the registration order of each temporary node, and monitor the deletion events of each temporary node in real time. When the deletion event is monitored to be the deletion event of the temporary node corresponding to the main service node, the main and backup service nodes are re-determined according to the registration order of the temporary nodes corresponding to each backup service node; wherein the main service node is used to execute business services based on business service applications.
8. A method for switching between active and standby devices, characterized in that: The method is applied to the business service high availability system according to any one of claims 1 to 7, and the method comprises: After monitoring that the service node completes the temporary node registration based on the host information, determining a primary service node and a backup service node from the plurality of service nodes according to the registration order of each of the temporary nodes; wherein the primary service node is used to execute the business service based on the business service application; The deletion events of the temporary nodes are monitored in real time. When the deletion event is detected to be the deletion event of the temporary node corresponding to the primary service node, the primary and backup nodes are re-determined according to the registration order of the temporary nodes corresponding to the backup service nodes.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is used to execute the active-standby switching program stored in the memory to implement the active-standby switching method described in claim 7 or 8.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the active-standby switching method described in claim 7 or 8.