Node switching method and device
By setting up working and standby nodes in the node group and utilizing the storage module monitoring and switching mechanism, the problem of business interruption caused by node failure is solved, and a high-availability business processing solution is implemented.
Patent Information
- Application Number
- CN202310289269.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-23
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2043-03-23
AI Technical Summary
In the existing technology, servers or processing nodes may experience operational failures, resulting in the business system being unable to provide services normally, and there is a lack of reliable and highly available business processing solutions.
In the node group, the target node is determined to be in working state and the other nodes are in standby state. The target node runs the application and updates the status information regularly. The standby node monitors the running status of the target application, detects faults in time and switches to the standby node to continue running the application.
It achieves multi-node fault tolerance and provides reliable high-availability business processing, ensuring that the business system can quickly resume normal operation in the event of a node failure.
Smart Images

Figure CN116319281B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of system disaster recovery processing, and in particular to a node switching method and device. Background Art
[0002] With the development of internet technology, the processing logic of business systems has become increasingly complex, placing increasing pressure on them. Many systems require 24 / 7 service. However, servers or processing nodes may experience operational failures, preventing the business system from providing normal services. Therefore, a reliable and highly available business processing solution is urgently needed. Summary of the Invention
[0003] In view of this, an embodiment of the present invention provides a node switching method and apparatus, which can provide a reliable and highly available service processing solution.
[0004] In a first aspect, an embodiment of the present invention provides a node switching method, which is applied to a node group, wherein the node group includes: multiple deployment nodes, each of which has a target application deployed therein, and the method includes:
[0005] Determine a target node from the multiple deployment nodes, set the node state of the target node to a working state, and set the node states of other nodes except the target node to a standby state;
[0006] Controlling the target node to run the target application, and writing the running status information of the target application into the storage module at a preset period;
[0007] In response to the state information of the target application in the storage module indicating that the target application has an operation failure, determining a switching node from the other nodes, and setting the node state of the switching node to a working state;
[0008] The switching node is controlled to run the target application, and after the target application is successfully run, the state information of the target application is written into the storage module at a preset period.
[0009] Optionally, after controlling the switching node to run the target application, the method further includes:
[0010] Determining whether the target node is operating normally;
[0011] In response to the target node operating normally, the node state of the target node is set to a standby state.
[0012] Optionally, after determining the switching node from the other nodes, the method further includes:
[0013] generating state information of the switching node, wherein the state information of the switching node indicates that the switching node is in a call-up state;
[0014] The state information of the switching node is written into the storage module.
[0015] Optionally, determining the switching node from the other nodes includes:
[0016] Any one of the other nodes obtains the operation status information from the storage module;
[0017] Determining, based on the running status information, whether the target application has a running fault and whether there is a node in a call-up state;
[0018] In response to an operation failure occurring on the target node and no node being in a call-up state, any one of the nodes is determined as a switching node.
[0019] Optionally, the running status information includes: status information of the target application;
[0020] The determining, based on the running status information, whether the target application has a running fault and whether there is a node in a call-up state includes:
[0021] Determining the latest update time corresponding to the target application according to the status information of the target application;
[0022] Determine the current time;
[0023] In response to a time difference between the latest update time and the current time being greater than a first time threshold, it is determined that an operation failure occurs on the target node.
[0024] Optionally, the operation status information includes: status information of the switching node;
[0025] The determining, based on the running status information, whether the target application has a running fault and whether there is a node in a call-up state includes:
[0026] In response to an operation failure of the target node, determining whether state information of the switching node exists in the storage module;
[0027] In response to the existence of the state information of the switching node, it is determined whether there is a node in the call-up state according to the state information of the switching node.
[0028] Optionally, determining whether any node is in a call-up state according to the state information of the switching node includes:
[0029] Determining a call-up time of the switching node according to the state information of the switching node;
[0030] Determine the current time;
[0031] In response to a time difference between the call-up time and the current time being not greater than a second time threshold, determining that there is a node in the call-up state;
[0032] In response to a time difference between the tune-up time and the current time being greater than the second time threshold, it is determined that no node is in the tune-up state.
[0033] In a second aspect, an embodiment of the present invention provides a node switching device, which is applied to a node group, wherein the node group includes: a plurality of deployment nodes, each of which has a target application deployed therein, and the device includes:
[0034] A state setting module is used to determine a target node from the multiple deployment nodes, set the node state of the target node to a working state, and set the node states of other nodes except the target node to a standby state;
[0035] a first running module, configured to control the target node to run the target application, and write the running status information of the target application into the storage module at a preset period;
[0036] a switching module, configured to, in response to the state information of the target application in the storage module indicating that the target application has an operation failure, determine a switching node from the other nodes, and set the node state of the switching node to a working state;
[0037] The second running module is configured to control the switching node to run the target application, and after successfully running the target application, write the state information of the target application into the storage module at a preset period.
[0038] Optionally, the status setting module is further configured to:
[0039] Determining whether the target node is operating normally;
[0040] In response to the target node operating normally, the node state of the target node is set to a standby state.
[0041] Optionally, it also includes:
[0042] A state writing module, configured to generate state information of the switching node, wherein the state information of the switching node indicates that the switching node is in a call-up state;
[0043] The state information of the switching node is written into the storage module.
[0044] Optionally, the switching module is specifically configured to:
[0045] Any one of the other nodes obtains the operation status information from the storage module;
[0046] Determining, based on the running status information, whether the target application has a running fault and whether there is a node in a call-up state;
[0047] In response to an operation failure occurring on the target node and no node being in a call-up state, any one of the nodes is determined as a switching node.
[0048] Optionally, the running status information includes: status information of the target application;
[0049] The switching module is specifically used for:
[0050] Determining the latest update time corresponding to the target application according to the status information of the target application;
[0051] Determine the current time;
[0052] In response to a time difference between the latest update time and the current time being greater than a first time threshold, it is determined that an operation failure occurs on the target node.
[0053] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0054] one or more processors;
[0055] a storage device for storing one or more programs,
[0056] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0057] In a fourth aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, which implements the method described in any of the above embodiments when the program is executed by a processor.
[0058] In a fifth aspect, an embodiment of the present invention provides a computer program product, including a computer program, which implements the method described in any of the above embodiments when executed by a processor.
[0059] One embodiment of the above invention has the following advantages or beneficial effects: the target application is deployed in each deployment node in the node group. The node in the working state runs the target application and writes the running status of the target application to the storage module at a preset period. The node in the standby state can determine whether the target application is running normally by reading the running status of the target application in the storage module. When the target application encounters an operational failure, a switching node is determined from other nodes and the switching node is set to the working state. The switching node in the working state continues to run the target application and writes the running status of the target application to the storage module at a preset period.
[0060] As can be seen, at any given moment, only one active node exists in a node group; the other nodes are in standby mode. The active node runs the target application and periodically writes its status information to the storage module. Using this information, the standby nodes can monitor the target application's operation, promptly detect any operational failures, and reassign active nodes, achieving multi-node fault tolerance and providing a reliable and highly available business processing solution.
[0061] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.
[0063] Figure 1 is a flowchart of a node switching method provided by the first embodiment of the present invention;
[0064] Figure 2 is a flowchart of a node switching method provided by the second embodiment of the present invention;
[0065] Figure 3 1 is a flow chart of a method for determining a working node provided by a third embodiment of the present invention;
[0066] Figure 4a is a schematic diagram of a node operating state provided by a fourth embodiment of the present invention;
[0067] Figure 4b is a schematic diagram of another node operating state provided by the fourth embodiment of the present invention;
[0068] Figure 4c is a schematic diagram of another node operating state provided by the fourth embodiment of the present invention;
[0069] Figure 4d is a schematic diagram of another node operating state provided by the fourth embodiment of the present invention;
[0070] Figure 5 is a schematic structural diagram of a node switching device provided by an embodiment of the present invention;
[0071] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0072] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0073] It should be noted that the collection, analysis, use, transmission, and storage of user personal information involved in the technical solutions of the present invention comply with relevant laws and regulations, are used for legitimate and reasonable purposes, are not shared, disclosed, or sold outside of these legitimate uses, and are subject to oversight and management by regulatory authorities. Necessary measures should be taken to prevent unauthorized access to such personal information data, ensure that persons with access to such personal information data comply with relevant laws and regulations, and ensure the security of user personal information. Once such user personal information data is no longer needed, risks should be minimized by restricting or even prohibiting its collection and / or deleting it.
[0074] Figure 1 FIG. 1 is a flow chart of a node switching method provided by the first embodiment of the present invention. Figure 1 As shown, the method includes:
[0075] Step 101: Determine a target node from a plurality of deployment nodes, set the node state of the target node to a working state, and set the node states of all nodes other than the target node to a standby state.
[0076] The method is applied to a node group, which includes: multiple deployment nodes, each of which has a target application deployed. The deployment node can be a server or a server machine.
[0077] The target node can be randomly determined from the node group. The target node can also be determined based on the performance and resource consumption of each deployed node.
[0078] Step 102: Control the target node to run the target application, and write the running status information of the target application into the storage module at a preset period.
[0079] At any given moment, there is only one active node in the node group, and the other nodes are in standby mode. The active node runs the target application and periodically writes the target application's status information to the storage module.
[0080] Each deployment node in a node group has read and write permissions for the storage module. The preset period can be set based on business needs, such as 5 minutes, 10 minutes, or 15 minutes. The target application's operating status information may include application ID, node ID, and update time. This information can be used to determine whether the target application is operating normally.
[0081] Step 103: In response to the target application status information in the storage module indicating that the target application has a running failure, a switching node is determined from other nodes, and the node status of the switching node is set to a working state.
[0082] Each node in the standby state does not run the target application, and periodically reads the state information of the target application in the storage module to monitor whether the target application is running normally.
[0083] If the target application fails to operate, a switching node is determined from the nodes in the standby state, the node state of the switching node is set to the working state, and the switching node is determined as the new target node.
[0084] Step 104: Control the switching node to run the target application. After the target application is successfully run, write the state information of the target application into the storage module at a preset period.
[0085] The switching node serves as the new target node, continues to run the target application, and periodically writes the status information of the target application to the storage module.
[0086] If the target application experiences a failure, steps 103 and 104 are executed repeatedly. Each node in the candidate state can monitor the target application's operation through the storage module, promptly detect the failure, and re-determine the switch node. The switch node becomes the new target node, continues to run the target application, and periodically writes the target application's status information to the storage module.
[0087] In an embodiment of the present invention, a target application is deployed on each deployment node in a node group. A node in an active state runs the target application and writes the target application's operating status to a storage module at a preset period. A node in a standby state can determine whether the target application is operating normally by reading the target application's operating status from the storage module. If an operational failure occurs in the target application, a switching node is identified from other nodes and set to an active state. The active switching node continues to run the target application and writes the target application's operating status to the storage module at a preset period.
[0088] By using the status information of the target application in the storage module, each node in the alternative state can monitor the operation of the target application, promptly detect any operating failures of the target application, and re-determine the working node to achieve multi-node fault tolerance, providing a reliable and highly available business processing solution.
[0089] Figure 2 FIG. 1 is a flow chart of a node switching method provided by the second embodiment of the present invention. Figure 2 As shown, the method includes:
[0090] Step 201: Determine a target node from a plurality of deployment nodes, set the node state of the target node to a working state, and set the node states of all nodes other than the target node to a standby state.
[0091] Step 202: Control the target node to run the target application, and write the running status information of the target application into the storage module at a preset period.
[0092] Step 203: In response to the target application status information in the storage module indicating that the target application has a running failure, a switching node is determined from other nodes, and the node status of the switching node is set to a working state.
[0093] Step 204: Control the switching node to run the target application. After the target application is successfully run, write the state information of the target application into the storage module at a preset period.
[0094] Step 205: Determine whether the target node is operating normally.
[0095] Step 206: In response to the target node operating normally, the node state of the target node is set to a standby state.
[0096] In this embodiment of the present invention, if a target node fails, the target application is run by the switch node. After the target node recovers from the failure, it is placed in a standby state. The standby node no longer runs the target application and periodically reads status information from the storage module to monitor whether the target application is running normally.
[0097] Figure 3 FIG. 1 is a flow chart of a method for determining a working node provided by the third embodiment of the present invention. Figure 3 As shown, the method includes:
[0098] Step 301: Any of the other nodes obtains the operation status information from the storage module.
[0099] Any node determines whether a target application has a running fault and whether any node is in the call-up state based on the running status information. If the target node has a running fault and no node is in the call-up state, any node can set its own running status to the working state and determine the any node as the switching node.
[0100] Step 302: Determine whether a target application has an operation failure based on the operation status information.
[0101] The operation status information includes: state information of the target application; determining a latest update time corresponding to the target application based on the state information of the target application; determining a current time; and determining that an operation failure has occurred in the target node in response to a time difference between the latest update time and the current time being greater than a first time threshold.
[0102] Active nodes report the target application's status information to the storage module at a preset interval. Based on the target application's status information in the storage module, the latest update time for the target application is determined. If the target node fails to report the target application's status information for an extended period, the target application is deemed faulty. The first time threshold can be set based on business needs, such as 5 minutes, 10 minutes, or 15 minutes.
[0103] Step 303: In response to an operation failure occurring at the target node, determine whether there is a node in a call-up state according to the operation status information.
[0104] The operation status information includes: status information of the switching node. Determining whether the status information of the switching node exists in the storage module; and in response to the existence of the status information of the switching node, determining whether there is a node in the call-up state according to the status information of the switching node.
[0105] In one embodiment of the present invention, after determining the switching node from other nodes, the method further includes: generating state information of the switching node, the state information of the switching node indicating that the switching node is in a call-up state; and writing the state information of the switching node into a storage module.
[0106] The state information of the switching node may include: application ID, node ID, current state, update time, etc. Writing the state information of the switching node into the storage module can effectively prevent conflicts caused by two nodes calling the target application at the same time.
[0107] Determine whether there is a node in the call-up state based on the status information of the switching node, including: determining the call-up time of the switching node based on the status information of the switching node; determining the current time; in response to the time difference between the call-up time and the current time being no greater than a second time threshold, determine that there is a node in the call-up state; in response to the time difference between the call-up time and the current time being greater than the second time threshold, determine that there is no node in the call-up state.
[0108] Any node obtains the latest status information corresponding to the target application from the target storage. If the latest status information is the status information of the target application and it is determined based on the status information of the target application that the target application has a running failure, any node is determined to be a switching node.
[0109] If the latest status information is that of a switching node and the target application experiences a running fault, the process then determines whether any node is in the startup state based on the switching node's status information. If no node is in the startup state, any node is determined as the switching node. If a node is in the startup state, the process ends.
[0110] Specifically, the time difference between the call-up time and the current time is used as the call-up time. If the call-up time is short, it is determined that a node is in the call-up state. If the call-up time is long, it is determined that the node switch has failed to call up and no node is in the call-up state. The second time threshold can be set according to specific needs, such as 10 minutes, 15 minutes, or half an hour.
[0111] Step 304: In response to a target node experiencing an operational failure and no node being in a call-up state, any node is determined as a switching node.
[0112] In this embodiment of the present invention, any node determines whether a target application has experienced an operational failure and whether any nodes are in the startup state based on the operational status information in the target storage. If a target node has experienced an operational failure and no nodes are in the startup state, the node is designated as the switching node and the target application is started. If the target application is successfully started, the switching node is designated as the new target node and the target application continues to run. Utilizing the status information in the target storage, each deployment node can automatically monitor application status and transition node status, efficiently achieving multiple fault tolerance for multiple nodes.
[0113] To make the solution of the embodiments of the present invention easier to understand, the embodiments of the present invention also provide a business processing solution. In this business processing solution, every three machines form a node group, and each machine deploys two theme applications. Each theme application is run by one machine at a time, while the other two machines are in standby mode. When a machine fails, one of the theme applications on the other two machines in the same group will be called up.
[0114] Considering the interdependencies of businesses and the differences in metric calculation methods for different businesses, and to facilitate the future addition of new applications, metrics, and code maintenance, the entire system is divided into multiple target applications by theme, such as car purchase and renovation. Each target application for each theme is deployed in a different node group. Applications for each theme consume messages from their own theme and process data independently.
[0115] Figure 4a-4d FIG4 is a schematic diagram of a node operation state provided by the fourth embodiment of the present invention. Figures 4a-4d As shown, the three machines are divided into a node group, each machine is a deployment node, and each machine deploys two theme applications: car purchase application and decoration application. Figure 4a As shown, the car purchase application and the decoration application are running normally on machine 1. The monitoring program in machine 1 reports the running status of the car purchase application and the decoration application in real time to the database (redis). The monitoring programs of machines 2 and 3 read the application status from the database and find that the car purchase and decoration instances on machine 1 are running normally and no operations are performed. An example of the status information reported by machine 1 is: {"key":"cars","value":{"machine_id":"1","update_time":"2023-2-19
[0116] 14:34", cars represents the car purchase application, "machine_id":"1" represents machine number 1, update_time":"2023-2-19 14:34", represents the reporting time: 2023-2-19 14:34.
[0117] like Figure 4b As shown, machine 1 experiences a downtime and is unable to report its application status, exceeding the initial time threshold (e.g., 5 minutes). The monitoring programs on machines 2 and 3 read this status information, determine that the car purchase and renovation applications are not functioning properly, and prepare to activate their respective applications.
[0118] like Figure 4c As shown, the monitoring program of machine 2 preemptively updates the status information, pulls up the car purchase and renovation applications, and reports the application status of the car purchase and renovation applications normally. The monitoring program of machine 3 reads the status normally and does not operate. The example of the status information reported by machine 2 is: {"key":"cars","value":{"machine_id":"2","update_time":"2023-2-19
[0119] 14:45", cars represents the car purchase application, "machine_id":"2" represents machine 2, update_time":"2023-2-19 14:45", represents the reporting time: 2023-2-19 14:45.
[0120] like Figure 4d As shown in the figure, after machine 1 restarts, the car purchase and renovation applications on machine 1 do not start. Only the monitoring program is started. The monitoring program reads the application status and finds it normal, without any operation. At this point, the fault has been automatically recovered, but the target application is no longer running on machine 1, but on machine 2. Machines 1 and 3 are in standby mode.
[0121] The solution of the embodiment of the present invention splits the business computing unit, effectively improving the overall data processing and business computing capabilities through a distributed approach, and realizing convenient business expansion. Combined with the multi-application split, a multi-node fault-tolerant solution is designed, which uses less server resources.
[0122] Figure 5 Schematic diagram of a node switching device provided by an embodiment of the present invention, which is applied to a node group. The node group includes: multiple deployment nodes, each of which has a target application deployed, such as Figure 5 As shown, the device includes:
[0123] The state setting module 501 is used to determine a target node from multiple deployment nodes, set the node state of the target node to a working state, and set the node states of other nodes except the target node to a standby state;
[0124] The first running module 502 is used to control the target node to run the target application and write the running status information of the target application to the storage module at a preset period;
[0125] A switching module 503 is configured to determine a switching node from other nodes in response to the target application status information in the storage module indicating that the target application has an operation failure, and set the node status of the switching node to a working state;
[0126] The second running module 504 is configured to control the switching node to run the target application, and write the state information of the target application into the storage module at a preset period after successfully running the target application.
[0127] Optionally, the status setting module 501 is further configured to:
[0128] Determine whether the target node is operating normally;
[0129] In response to the target node operating normally, the node state of the target node is set to a standby state.
[0130] Optionally, it also includes:
[0131] A state writing module 505 is used to generate state information of the switching node, where the state information of the switching node indicates that the switching node is in a call-up state;
[0132] Write the status information of the switching node into the storage module.
[0133] Optionally, the switching module 503 is specifically configured to:
[0134] Any of the other nodes obtains the operation status information from the storage module;
[0135] Determine, based on the running status information, whether the target application has a running fault and whether there are any nodes in the startup state;
[0136] In response to a target node having an operation failure and no node being in a call-up state, any node is determined as a switching node.
[0137] Optionally, the running status information includes: status information of the target application;
[0138] The switching module 503 is specifically used for:
[0139] Determine the latest update time corresponding to the target application based on the status information of the target application;
[0140] Determine the current time;
[0141] In response to a time difference between the latest update time and the current time being greater than a first time threshold, it is determined that an operation failure occurs on the target node.
[0142] Optionally, the operation status information includes: status information of the switching node;
[0143] The switching module 503 is specifically used for:
[0144] In response to an operation failure of the target node, determining whether there is state information of the switching node in the storage module;
[0145] In response to the presence of the state information of the switching node, it is determined whether there is a node in the call-up state according to the state information of the switching node.
[0146] Optionally, the switching module 503 is specifically configured to:
[0147] Determine the time to switch the node based on the state information of the switch node;
[0148] Determine the current time;
[0149] In response to a time difference between the call-up time and the current time being not greater than a second time threshold, determining that there is a node in the call-up state;
[0150] In response to a time difference between the tune-up time and the current time being greater than a second time threshold, it is determined that no node is in the tune-up state.
[0151] An embodiment of the present invention provides an electronic device, including:
[0152] one or more processors;
[0153] a storage device for storing one or more programs,
[0154] When one or more programs are executed by one or more processors, the one or more processors implement the method of any of the above embodiments.
[0155] An embodiment of the present invention provides a computer program product, including a computer program. When the computer program is executed by a processor, the enterprise risk assessment method in the embodiment of the present invention is implemented.
[0156] Reference below Figure 6 , which shows a schematic structural diagram of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0157] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage unit 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the system 600 are also stored in the RAM 603. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0158] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, and the like; an output section 607 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 608 including a hard disk; and a communication section 609 including a network interface card such as a LAN card or a modem. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 610 as needed, so that computer programs read therefrom can be installed into the storage section 608 as needed.
[0159] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from a removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are performed.
[0160] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0161] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0162] The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The modules described may also be provided in a processor, for example, they may be described as: a state setting module, a first operation module, a switching module, and a second operation module. The names of these modules do not, in certain cases, constitute a limitation on the module itself. For example, the state setting module may also be described as "a module that determines a target node from the multiple deployment nodes, sets the node state of the target node to a working state, and sets the node states of all nodes other than the target node to a standby state."
[0163] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiments, or may exist independently without being incorporated into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes:
[0164] Determine a target node from multiple deployment nodes, set the node status of the target node to a working state, and set the node status of other nodes except the target node to a standby state;
[0165] Control the target node to run the target application, and write the running status information of the target application to the storage module at a preset period;
[0166] In response to the target application status information in the storage module indicating that the target application has a running failure, determining a switching node from other nodes, and setting the node status of the switching node to a working state;
[0167] The control switching node runs the target application, and after the target application is successfully run, the state information of the target application is written into the storage module at a preset period.
[0168] According to the technical solution of an embodiment of the present invention, a target application is deployed on each deployment node in a node group. A node in a working state runs the target application and writes the target application's running status to a storage module at a preset period. A node in a standby state can determine whether the target application is running normally by reading the target application's running status from the storage module. When an operational failure occurs in the target application, a switching node is identified from other nodes and set to a working state. The working switching node continues to run the target application and writes the target application's running status to the storage module at a preset period.
[0169] As can be seen, at any given moment, only one active node exists in a node group; the other nodes are in standby mode. The active node runs the target application and periodically writes its status information to the storage module. Using this information, the standby nodes can monitor the target application's operation, promptly detect any operational failures, and reassign active nodes, achieving multi-node fault tolerance and providing a reliable and highly available business processing solution.
[0170] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A node switching method, characterized in that: Applied to a node group, the node group includes: a plurality of deployment nodes, each of the deployment nodes having a target application deployed therein, the method includes: Determine a target node from the plurality of deployment nodes, set the node state of the target node to a working state, and set the node states of all nodes other than the target node to a standby state; wherein each node in the standby state does not run a target application; Controlling the target node to run the target application, and writing the running status information of the target application into the storage module at a preset period; In response to the state information of the target application in the storage module indicating that the target application has an operation failure, determining a switching node from the other nodes, and setting the node state of the switching node to a working state; controlling the switching node to run the target application, and after successfully running the target application, writing the state information of the target application into the storage module at a preset period; After determining the switching node from the other nodes, the method further includes: generating state information of the switching node, wherein the state information of the switching node indicates that the switching node is in a call-up state; and writing the state information of the switching node into the storage module; The method of determining the switching node from the other nodes includes: any one of the other nodes obtaining operation status information from the storage module; determining whether an operation failure occurs in the target application and whether there is a node in a call-up state based on the operation status information; in response to an operation failure occurs in the target node and no node is in a call-up state, determining any one of the nodes as a switching node; wherein the operation status information includes: status information of the target application and status information of the switching node; the status information of the switching node includes: application ID, node ID, current status, and update time.
2. The method according to claim 1, characterized in that After controlling the switching node to run the target application, the method further includes: Determining whether the target node is operating normally; In response to the target node operating normally, the node state of the target node is set to a standby state.
3. The method according to claim 1, characterized in that The running status information includes: status information of the target application; The determining, based on the running status information, whether the target application has a running fault and whether there is a node in a call-up state includes: Determining the latest update time corresponding to the target application according to the status information of the target application; Determine the current time; In response to a time difference between the latest update time and the current time being greater than a first time threshold, it is determined that an operation failure occurs on the target node.
4. The method according to claim 3, characterized in that The operation status information includes: status information of the switching node; The determining, based on the running status information, whether the target application has a running fault and whether there is a node in a call-up state includes: In response to an operation failure of the target node, determining whether state information of the switching node exists in the storage module; In response to the existence of the state information of the switching node, it is determined whether there is a node in the call-up state according to the state information of the switching node.
5. The method according to claim 4, characterized in that The determining, according to the state information of the switching node, whether there is a node in the call-up state includes: Determining a call-up time of the switching node according to the state information of the switching node; Determine the current time; In response to a time difference between the call-up time and the current time being not greater than a second time threshold, determining that there is a node in the call-up state; In response to a time difference between the tune-up time and the current time being greater than the second time threshold, it is determined that no node is in the tune-up state.
6. A node switching device, characterized in that: Applied to a node group, the node group includes: a plurality of deployment nodes, each of the deployment nodes has a target application deployed therein, the device includes: a state setting module, configured to determine a target node from the plurality of deployment nodes, set the node state of the target node to a working state, and set the node states of all nodes other than the target node to a standby state; wherein each node in the standby state does not run a target application; a first running module, configured to control the target node to run the target application, and write the running status information of the target application into the storage module at a preset period; a switching module, configured to, in response to the state information of the target application in the storage module indicating that the target application has an operation failure, determine a switching node from the other nodes, and set the node state of the switching node to a working state; a second running module, configured to control the switching node to run the target application, and write the state information of the target application into the storage module at a preset period after successfully running the target application; a state writing module, configured to generate state information of the switching node, wherein the state information of the switching node indicates that the switching node is in a call-up state; and write the state information of the switching node into the storage module; The switching module is specifically used to: any one of the other nodes obtains operating status information from the storage module; based on the operating status information, determines whether the target application has an operating failure and whether there is a node in the call-up state; in response to the target node having an operating failure and no node in the call-up state, determines any one of the nodes as a switching node; wherein, the operating status information includes: status information of the target application and status information of the switching node; the status information of the switching node includes: application ID, node ID, current status, and update time.
7. The device according to claim 6, characterized in that The state setting module is also used for: Determining whether the target node is operating normally; In response to the target node operating normally, the node state of the target node is set to a standby state.
8. The device according to claim 6, characterized in that The running status information includes: status information of the target application; The switching module is specifically used for: Determining the latest update time corresponding to the target application according to the status information of the target application; Determine the current time; In response to a time difference between the latest update time and the current time being greater than a first time threshold, it is determined that an operation failure occurs on the target node.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
10. A computer readable medium having a computer program stored thereon, characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
11. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method for performing node switching in case of node fault and related equipment
CN112199240A
Main and standby management system and management method for wide-area distributed service
CN112787855A