Method, device and equipment for switching between primary and backup services based on cold backup mode and medium
By using polling rules and metric values to determine the status of the primary host in cold standby mode, and combining the mapping between IP address and application directory path, the system automatically switches to the backup host, solving the problem of automatic switching when the primary host fails in cold standby mode and achieving fast and efficient service switching.
Patent Information
- Application Number
- CN202111559262.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2041-12-20
AI Technical Summary
In cold standby mode, the system cannot automatically switch to the standby host in a timely manner when the primary host fails, and the existing technical solutions are complex and have low system availability.
The system determines whether the primary host is working properly by polling rules and preset indicator values. It automatically obtains and starts applications on the backup host by using the pre-configured IP address and application directory path mapping relationship, so as to achieve automatic switching without the need for business layer differentiation.
It enables fast and automatic primary/backup service switching in cold standby mode, reducing switching time from minutes to seconds, improving switching efficiency, and requiring no additional hardware investment.
Smart Images

Figure CN114237991B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for primary / standby service switching based on a cold standby mode. Background Technology
[0002] The application's cold standby mode refers to using two or more hosts. One host or group acts as the primary host running the application, while the other host or group acts as a backup host that remains powered on but does not run the application. In this way, if the primary host fails or crashes, the application on the backup host takes over and continues to provide service. However, since this solution usually requires manual switching, it cannot switch to the backup host in a timely manner when the primary host fails.
[0003] While existing technologies allow for automatic failover between two hosts—meaning data changes on either host are synchronized to the other and both hosts can provide services simultaneously—this approach suffers from several drawbacks. The presence of two primary devices necessitates differentiation between them at the business layer. Otherwise, arbitrary selection of the primary device by businesses could lead to large-scale primary key conflicts. Consequently, this solution is extremely complex to implement and suffers from low system availability. Summary of the Invention
[0004] In view of the above, the present invention provides a method, apparatus, device and storage medium for primary and secondary service switching based on cold standby mode, the purpose of which is to realize automatic and fast service switching in cold standby mode without distinguishing the host at the business layer.
[0005] To achieve the above objectives, the present invention provides a primary / standby service switchover method based on cold standby mode, the method comprising:
[0006] The polling rules are used to poll and determine whether the primary hosts in the primary host group are working properly, or the preset index values of the primary hosts in the primary host group are used to determine whether the primary hosts are working properly.
[0007] When it is determined that the primary host is malfunctioning, the application directory path of the backup host corresponding to the IP address of the primary host is obtained based on the pre-determined mapping relationship between the IP address of the primary host and the application directory path of the backup host.
[0008] Based on the directory path of the application on the backup host corresponding to the primary host's IP address, the application is located on the backup host. Based on the pre-configured script information for starting the application, the account information for starting the application is filled into the corresponding area of the application's launch interface. The application on the backup host is then launched using the launch button on the launch interface.
[0009] Preferably, the polling rules include:
[0010] Based on the sequence number pre-assigned to each primary host in the primary host group, each primary host in the primary host group is polled in a round-robin fashion.
[0011] Preferably, determining whether the primary host in the primary host group is working properly includes:
[0012] A ping test is performed on the primary host. If the number of successful ping tests performed by the primary host within a preset time period is greater than or equal to a preset number, the primary host is determined to be working normally.
[0013] If the number of successful ping tests performed by the primary host is less than the preset number, the primary host is deemed to be malfunctioning.
[0014] Preferably, the method further includes:
[0015] When the primary host is determined to be malfunctioning, an exception record is generated based on the primary host's sequence number and stored in the log file. The malfunctioning primary host is then removed from the polling list corresponding to the primary host group.
[0016] Preferably, the application directory path of the backup host includes multiple path nodes, and the last path node of the application directory path of the backup host corresponding to the primary host is the IP address of the primary host.
[0017] Preferably, the step of determining whether a primary host is working properly based on a preset indicator value of the primary host in the primary host group includes:
[0018] Read the preset indicator values of each primary host, and calculate the resource utilization rate of each primary host based on the preset indicator values and preset calculation rules.
[0019] When the resource utilization rate of the primary host is greater than or equal to a preset threshold, the primary host is judged to be malfunctioning.
[0020] When the resource utilization rate of the primary host is less than the preset threshold, the primary host is determined to be working normally.
[0021] Preferably, the preset calculation rules include:
[0022] R i =1-(1-W1×X) i1 )×(1-W2×X i2 )×(1-W3×X i3 )
[0023] Among them, R i X represents the resource utilization rate of the i-th primary host. i1 X represents the CPU utilization of the i-th master host. i2 X represents the memory utilization rate of the i-th primary host. i3 W1 represents the IO utilization rate of the i-th master host, W2 represents the preset weight of the CPU of the i-th master host, W3 represents the preset weight of the memory of the i-th master host, and W3 represents the preset weight of the IO of the i-th master host.
[0024] To achieve the above objectives, the present invention also provides a primary / standby service switching device based on a cold standby mode, the primary / standby service switching device based on a cold standby mode comprising:
[0025] Polling module: used to poll and determine whether the primary hosts in the primary host group are working properly based on pre-configured polling rules, or to determine whether the primary hosts are working properly based on preset indicator values of the primary hosts in the primary host group;
[0026] Judgment module: When it is determined that the primary host is malfunctioning, it obtains the application directory path of the backup host corresponding to the IP address of the primary host based on a pre-determined mapping relationship between the IP address of the primary host and the application directory path of the backup host.
[0027] Switching module: Based on the directory path of the application on the backup host corresponding to the primary host's IP address, it locates the application on the backup host, fills the account information for opening the application into the corresponding area of the application's opening interface based on the pre-configured script information for opening the application, and opens the application on the backup host based on the start button on the opening interface.
[0028] To achieve the above objectives, the present invention also provides an electronic device, the electronic device comprising:
[0029] At least one processor; and,
[0030] A memory communicatively connected to the at least one processor; wherein,
[0031] The memory stores a program that can be executed by the at least one processor, which enables the at least one processor to perform any step of the primary / standby service switching method based on the cold standby mode as described above.
[0032] To achieve the above objectives, the present invention also provides a computer-readable storage medium storing a primary / backup service switching program based on a cold standby mode. When the primary / backup service switching program based on a cold standby mode is executed by a processor, it implements any step of the primary / backup service switching method based on a cold standby mode as described above.
[0033] This invention proposes a primary / backup service switchover method, apparatus, device, and storage medium based on a cold standby mode. By polling and judging whether the primary hosts in the primary host group are working normally, it can quickly determine whether a primary host is faulty. When a primary host is determined to be faulty, based on a pre-determined mapping relationship between the primary host IP address and the application directory path of the backup host, it obtains the application directory path of the backup host corresponding to the primary host IP address, and automatically fills in the account information required to start the application according to a pre-configured script, and automatically starts the application on the backup host. When a primary host fails, it can automatically switch to the backup host. Compared with manual switching, the switching time is reduced from several minutes to several seconds, and no additional hardware investment is required. It also eliminates the need to distinguish hosts at the business layer, thus improving the efficiency of primary / backup service switchover. Attached Figure Description
[0034] Figure 1 This is a flowchart illustrating a preferred embodiment of the primary / standby service switching method based on cold standby mode of the present invention.
[0035] Figure 2 This is a schematic diagram of a preferred embodiment of the primary / standby service switching device based on cold standby mode of the present invention.
[0036] Figure 3 This is a schematic diagram of a preferred embodiment of the electronic device of the present invention;
[0037] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.
[0039] The embodiments of this invention can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that utilize digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.
[0040] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0041] This invention provides a primary / standby service switching method based on cold standby mode. (Refer to...) Figure 1 The diagram shown is a flowchart illustrating an embodiment of the primary / standby service switchover method based on cold standby mode according to the present invention. This method can be executed by an electronic device, which can be implemented in software and / or hardware. The primary / standby service switchover method based on cold standby mode includes:
[0042] Step S10: Poll and determine whether the primary hosts in the primary host group are working properly based on the pre-configured polling rules, or determine whether the primary hosts are working properly based on the preset index values of the primary hosts in the primary host group.
[0043] The application's cold standby mode refers to using two or more hosts. One host or group acts as the primary host running the application, while the other host or group acts as a backup host that remains powered on but does not run the application. In this way, if the primary host fails or crashes, the application on the backup host takes over and continues to provide service. However, since this solution usually requires manual switching, it cannot switch to the backup host in a timely manner when the primary host fails.
[0044] This embodiment uses the switching between the primary and backup hosts in a cold standby mode as an example to illustrate this solution. Examples include the Shanghai Stock Exchange's order placement programs EZOES and EZSTEP. Since the entire process from hardware failure to monitoring and handling takes a considerable amount of time (approximately 5 minutes), automatic switching between the primary and backup hosts can be achieved by determining the normal operation of each running primary host in real-time or periodically based on pre-configured polling rules. This involves checking whether the primary host has failed or crashed, or by determining the normal operation of the primary hosts based on preset indicator values in the primary host group. These preset indicator values include the primary host's CPU utilization, memory utilization, and I / O utilization. The pre-configured polling rules can be set by the user (operations personnel) according to actual needs.
[0045] In one embodiment, the polling rule includes:
[0046] Based on the sequence number pre-assigned to each primary host in the primary host group, each primary host in the primary host group is polled in a round-robin fashion.
[0047] Assign sequence numbers to each primary host in the primary host cluster. Each primary host has only one sequence number. Based on the sequence number, poll each primary host in the cluster sequentially. A host polling list can be generated based on the sequence numbers of each primary host and imported into a configuration file. This configuration file enables automatic backups. Specifically, a backup function is embedded in the close control of the configuration file. The function imports the current system time and copies the current table, renaming it to a file named "time + filename". If there are updates, the file is automatically saved as a new file; otherwise, no backup is performed.
[0048] Users can also import configuration files. If the configuration file does not exist in the preset storage path, a preset prompt message will be sent to the user, prompting them to import the configuration file. Supporting configuration file import allows this master-slave service switchover method to be applied to different projects.
[0049] In one embodiment, determining whether the primary hosts in the primary host group are functioning normally includes:
[0050] A ping test is performed on the primary host. If the number of successful ping tests performed by the primary host within a preset time period is greater than or equal to a preset number, the primary host is determined to be working normally.
[0051] If the number of successful ping tests performed by the primary host is less than the preset number, the primary host is deemed to be malfunctioning.
[0052] Ping is a command used in Windows, Unix, and Linux systems. Ping is also a communication protocol, part of the TCP / IP protocol suite. The "ping" command can be used to check network connectivity. Because the data packets sent by the ping command are very small, they travel very quickly over the network, allowing for rapid detection of whether a target site is reachable. The default number of ping attempts is 8.
[0053] In one embodiment, determining whether a primary host is functioning correctly based on preset indicator values of the primary hosts in the primary host group includes:
[0054] Read the preset indicator values of each primary host, and calculate the resource utilization rate of each primary host based on the preset indicator values and preset calculation rules.
[0055] When the resource utilization rate of the primary host is greater than or equal to a preset threshold, the primary host is judged to be malfunctioning.
[0056] When the resource utilization rate of the primary host is less than the preset threshold, the primary host is determined to be working normally.
[0057] The preset metrics include the CPU utilization, memory utilization, and I / O utilization of the primary host. Since the resource utilization of a primary host may suddenly increase during actual application operation, and high concurrency may cause that primary host to fail, the resource utilization of each primary host is calculated. When the resource utilization of a primary host is greater than or equal to a preset threshold (e.g., 80%), the primary host is considered to be malfunctioning; when the resource utilization of a primary host is less than the preset threshold, the primary host is considered to be malfunctioning.
[0058] Furthermore, the preset calculation rules include:
[0059] R i =1-(1-W1×X) i1 )×(1-W2×X i2 )×(1-W3×X i3 )
[0060] Among them, R i X represents the resource utilization rate of the i-th primary host. i1 X represents the CPU utilization of the i-th master host. i2 X represents the memory utilization rate of the i-th primary host. i3 W1 represents the CPU utilization rate of the i-th master host, W2 represents the memory utilization rate of the i-th master host, and W3 represents the I / O utilization rate of the i-th master host. The preset weights can be set according to actual business needs.
[0061] Step S20: When it is determined that the primary host is malfunctioning, based on the pre-determined mapping relationship between the primary host IP address and the application directory path of the backup host, obtain the application directory path of the backup host corresponding to the IP address of the primary host.
[0062] In this embodiment, when it is determined that the primary host is working normally, that is, the primary host is working normally without failure, it is then determined whether the next primary host is working normally. For example, when the primary host of serial number 1 is working normally, it is then determined whether the next primary host (i.e., the primary host of serial number 2) is working normally.
[0063] When it is determined that the primary host (serial number 1) is not functioning properly, the application directory path of the backup host corresponding to the IP address of the primary host (serial number 1) is obtained based on the pre-determined mapping relationship between the primary host's IP address and the application directory path of the backup host. The application directory path of the backup host stores the same application data as the primary host. Specifically, a script can be written using rsync to incrementally synchronize the applications from the primary host to the backup host daily. rsync is a data mirroring and backup tool for Linux systems. Remote Sync can be used for remote synchronization, supports local copying, or synchronization with other SSH / rsync hosts.
[0064] In one embodiment, the method further includes:
[0065] When the primary host is determined to be malfunctioning, an exception record is generated based on the primary host's sequence number and stored in the log file. The malfunctioning primary host is then removed from the polling list corresponding to the primary host group.
[0066] When any primary host malfunctions, an exception record is generated based on the primary host's sequence number and stored in the log file. A notification message can also be sent to the terminal to remind maintenance personnel to address the primary host's failure as soon as possible. The malfunctioning primary host is then removed from the polling list associated with the polling rules. For example, if primary host number 3 malfunctions and the corresponding application on the backup host is started, primary host number 3 is removed from the polling list; that is, primary host number 3 will not be polled until the primary host's failure is resolved.
[0067] In one embodiment, the application directory path of the standby host includes multiple path nodes, and the last path node of the application directory path of the standby host corresponding to the primary host is the IP address of the primary host. This allows for quick and accurate resolution of the mapping relationship between the primary and standby hosts. For example, d:\bak\ip1, using the IP address as the directory name, allows for quick searching of applications on the primary host within the standby host, thus obtaining the application directory path of the standby host corresponding to the primary host's IP address.
[0068] Step S30: Based on the directory path of the application on the backup host corresponding to the primary host IP address, locate the application on the backup host, fill the account information for opening the application into the corresponding area of the application's opening interface based on the pre-configured script information for opening the application, and open the application on the backup host based on the start button on the opening interface.
[0069] In this embodiment, the application is located on the standby host based on the directory path of the application on the standby host corresponding to the primary host's IP address. Then, according to the pre-configured application startup script, the required account information is filled into the username and password fields on the application's startup interface. The application on the standby host is then launched using the start button on the startup interface. All GUI operations are implemented in the automated workflow code. When the primary host experiences hardware failure, manual startup is unnecessary. Currently, monitoring (which takes 2 minutes for polling) detects human login and requires user input and password for restart, taking approximately 5 minutes. Using this solution for primary / standby failover can reduce the time to within 20 seconds, significantly improving the efficiency of primary / standby service failover. A timestamp for the primary / standby service failover operation can also be generated for subsequent traceability.
[0070] In one embodiment, since the sequence number of the malfunctioning primary host is removed from the polling list when the primary host malfunctions, and the primary host needs to be added back to the polling list after the fault of the primary host has been resolved, the method may further include:
[0071] The system receives a request from a preset terminal to add a primary host to the primary host group, obtains the IP address of the primary host to be added carried in the request, checks whether the IP address of the primary host to be added is a valid IP address, and when the IP address of the primary host to be added is a valid IP address, responds to the request and adds the primary host to the primary host group.
[0072] Furthermore, when the IP address of the new primary host is detected to be invalid, a second prompt message is sent to the preset terminal.
[0073] When a user adds a valid IP address, a timestamp and the user's information are added to the corresponding configuration file. The validity of the IP address can be checked using regular expressions, or by splitting the IP address by the character "." and verifying the number of decimal digits in the split, as well as whether each decimal digit is within the range of 0-247 or 0-255. This format check of the new IP address entered by the user can reduce input errors to some extent.
[0074] Reference Figure 2 The diagram shown is a functional module schematic of the primary / standby service switching device 100 based on the cold standby mode of the present invention.
[0075] The primary / standby service switching device 100 based on cold standby mode described in this invention can be installed in an electronic device. Depending on the functions implemented, the primary / standby service switching device 100 based on cold standby mode may include a polling module 110, a judgment module 120, and a switching module 130. The module described in this invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and which are stored in the memory of the electronic device.
[0076] In this embodiment, the functions of each module / unit are as follows:
[0077] Polling module 110: used to poll and determine whether the primary host in the primary host group is working normally based on pre-configured polling rules, or to determine whether the primary host is working normally based on the preset index value of the primary host in the primary host group;
[0078] Judgment module 120: When it is determined that the primary host is malfunctioning, it obtains the application directory path of the backup host corresponding to the IP address of the primary host based on a pre-determined mapping relationship between the IP address of the primary host and the application directory path of the backup host.
[0079] Switching module 130: Based on the directory path of the application on the backup host corresponding to the primary host IP address, it locates the application on the backup host, fills the account information for opening the application into the corresponding area of the application's opening interface based on the pre-configured script information for opening the application, and opens the application on the backup host based on the start button on the opening interface.
[0080] In one embodiment, the polling rule includes:
[0081] Based on the sequence number pre-assigned to each primary host in the primary host group, each primary host in the primary host group is polled in a round-robin fashion.
[0082] In one embodiment, determining whether the primary hosts in the primary host group are functioning normally includes:
[0083] A ping test is performed on the primary host. If the number of successful ping tests performed by the primary host within a preset time period is greater than or equal to a preset number, the primary host is determined to be working normally.
[0084] If the number of successful ping tests performed by the primary host is less than the preset number, the primary host is deemed to be malfunctioning.
[0085] In one embodiment, the determining module 120 is further configured to:
[0086] When the primary host is determined to be malfunctioning, an exception record is generated based on the primary host's sequence number and stored in the log file. The malfunctioning primary host is then removed from the polling list corresponding to the primary host group.
[0087] In one embodiment, the application directory path of the backup host includes multiple path nodes, and the last path node of the application directory path of the backup host corresponding to the primary host is the IP address of the primary host.
[0088] In one embodiment, determining whether a primary host is functioning correctly based on preset indicator values of the primary hosts in the primary host group includes:
[0089] Read the preset indicator values of each primary host, and calculate the resource utilization rate of each primary host based on the preset indicator values and preset calculation rules.
[0090] When the resource utilization rate of the primary host is greater than or equal to a preset threshold, the primary host is judged to be malfunctioning.
[0091] When the resource utilization rate of the primary host is less than the preset threshold, the primary host is determined to be working normally.
[0092] In one embodiment, the preset calculation rule includes:
[0093] R i =1-(1-W1×X) i1 )×(1-W2×X i2 )×(1-W3×X i3 )
[0094] Among them, R i X represents the resource utilization rate of the i-th primary host. i1 X represents the CPU utilization of the i-th master host. i2 X represents the memory utilization rate of the i-th primary host.i3 W1 represents the IO utilization rate of the i-th master host, W2 represents the preset weight of the CPU of the i-th master host, W3 represents the preset weight of the memory of the i-th master host, and W3 represents the preset weight of the IO of the i-th master host.
[0095] Reference Figure 3 The diagram shown is a schematic representation of a preferred embodiment of the electronic device 1 of the present invention.
[0096] The electronic device 1 includes, but is not limited to, a memory 11, a processor 12, a display 13, and a network interface 14. The electronic device 1 connects to a network via the network interface 14 to acquire raw data. The network can be an intranet, the Internet, a Global System for Mobile Communications (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth, Wi-Fi, a voice communication network, or other wireless or wired networks.
[0097] The memory 11 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 1, such as the hard disk or memory of the electronic device 1. In other embodiments, the memory 11 may also be an external storage device of the electronic device 1, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. of the electronic device 1. Of course, the memory 11 may include both the internal storage unit and the external storage device of the electronic device 1. In this embodiment, the memory 11 is typically used to store the operating system and various application software installed on the electronic device 1, such as the program code of the master / slave service switchover program 10 based on cold standby mode. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or will be output.
[0098] In some embodiments, processor 12 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. Processor 12 is typically used to control the overall operation of the electronic device 1, such as performing data interaction or communication-related control and processing. In this embodiment, processor 12 is used to run program code stored in memory 11 or process data, such as running program code for a primary / standby service switchover program 10 based on cold standby mode.
[0099] The display 13 may be referred to as a display screen or display unit. In some embodiments, the display 13 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an organic light-emitting diode (OLED) touch screen, etc. The display 13 is used to display information processed in the electronic device 1 and to display a visual working interface, such as displaying the results of data statistics.
[0100] The network interface 14 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface), which is typically used to establish communication connections between the electronic device 1 and other electronic devices.
[0101] Figure 3 Only an electronic device 1 with components 11-14 and a primary / standby service switching procedure 10 based on cold standby mode is shown. However, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0102] Optionally, the electronic device 1 may further include a user interface, which may include a display, an input unit such as a keyboard, and optionally, a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an organic light-emitting diode (OLED) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device 1 and to display a visual user interface.
[0103] The electronic device 1 may also include radio frequency (RF) circuits, sensors, and audio circuits, etc., which will not be described in detail here.
[0104] In the above embodiments, when the processor 12 executes the primary / standby service switchover program 10 based on cold standby mode stored in the memory 11, it can perform the following steps:
[0105] The polling rules are used to poll and determine whether the primary hosts in the primary host group are working properly, or the preset index values of the primary hosts in the primary host group are used to determine whether the primary hosts are working properly.
[0106] When it is determined that the primary host is malfunctioning, the application directory path of the backup host corresponding to the IP address of the primary host is obtained based on the pre-determined mapping relationship between the IP address of the primary host and the application directory path of the backup host.
[0107] Based on the directory path of the application on the backup host corresponding to the primary host's IP address, the application is located on the backup host. Based on the pre-configured script information for starting the application, the account information for starting the application is filled into the corresponding area of the application's launch interface. The application on the backup host is then launched using the launch button on the launch interface.
[0108] The storage device can be the memory 11 of the electronic device 1, or it can be other storage devices that are communicatively connected to the electronic device 1.
[0109] For a detailed explanation of the above steps, please refer to the above. Figure 2 Functional block diagram of an embodiment of a primary / standby service switching device 100 based on cold standby mode and Figure 1 A flowchart illustrating an embodiment of a primary / standby service switching method based on cold standby mode.
[0110] Furthermore, this invention also proposes a computer-readable storage medium, which can be non-volatile or volatile. This computer-readable storage medium can be any one or any combination of several of the following: hard disk, multimedia card, SD card, flash memory card, SMC, read-only memory (ROM), erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, etc. The computer-readable storage medium includes a data storage area and a program storage area. The data storage area stores data created based on the use of blockchain nodes, and the program storage area stores a master-slave service switchover program 10 based on a cold standby mode. When executed by a processor, the master-slave service switchover program 10 based on a cold standby mode performs the following operations:
[0111] The polling rules are used to poll and determine whether the primary hosts in the primary host group are working properly, or the preset index values of the primary hosts in the primary host group are used to determine whether the primary hosts are working properly.
[0112] When it is determined that the primary host is malfunctioning, the application directory path of the backup host corresponding to the IP address of the primary host is obtained based on the pre-determined mapping relationship between the IP address of the primary host and the application directory path of the backup host.
[0113] Based on the directory path of the application on the backup host corresponding to the primary host's IP address, the application is located on the backup host. Based on the pre-configured script information for starting the application, the account information for starting the application is filled into the corresponding area of the application's launch interface. The application on the backup host is then launched using the launch button on the launch interface.
[0114] The specific implementation of the computer-readable storage medium of the present invention is largely the same as the specific implementation of the primary / standby service switching method based on the cold standby mode described above, and will not be repeated here.
[0115] In another embodiment, the primary / standby service switching method based on cold standby mode provided by the present invention further ensures the privacy and security of all the aforementioned data by storing all of it in a blockchain node. For example, polling rules and application directory paths can all be stored in the blockchain node.
[0116] It should be noted that the blockchain referred to in this invention is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0117] It should be noted that the sequence numbers of the above embodiments of the present invention are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0118] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, electronic device, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0119] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A primary / standby service switching method based on cold standby mode, applied to electronic devices, characterized in that, The method includes: The polling rules are used to poll and determine whether the primary hosts in the primary host group are working properly, or the preset index values of the primary hosts in the primary host group are used to determine whether the primary hosts are working properly. When it is determined that the primary host is malfunctioning, based on the pre-determined mapping relationship between the primary host IP address and the application directory path of the backup host, the application directory path of the backup host corresponding to the primary host IP address is obtained. The application directory path of the backup host includes multiple path nodes and application data that is the same as that of the corresponding primary host. The last path node of the application directory path of the backup host corresponding to the primary host is the IP address of the primary host. Based on the directory path of the application on the backup host corresponding to the primary host's IP address, the application is located on the backup host. Based on the pre-configured script information for starting the application, the account information for starting the application is filled into the corresponding area of the application's startup interface. The application on the backup host is started based on the startup button on the startup interface, and a timestamp of the primary / backup service switchover operation is generated.
2. The primary / standby service switching method based on cold standby mode as described in claim 1, characterized in that, The polling rules include: Based on the sequence number pre-assigned to each primary host in the primary host group, each primary host in the primary host group is polled in a round-robin fashion.
3. The primary / standby service switching method based on cold standby mode as described in claim 1, characterized in that, The process of polling and determining whether the primary hosts in the primary host group are working properly based on pre-configured polling rules includes: A ping test is performed on the primary host. If the number of successful ping tests performed by the primary host within a preset time period is greater than or equal to a preset number, the primary host is determined to be working normally. If the number of successful ping tests performed by the primary host is less than the preset number, the primary host is deemed to be malfunctioning.
4. The primary / standby service switching method based on cold standby mode as described in claim 1, characterized in that, The method further includes: When the primary host is determined to be malfunctioning, an exception record is generated based on the primary host's sequence number and stored in the log file. The malfunctioning primary host is then removed from the polling list corresponding to the primary host group.
5. The primary / standby service switching method based on cold standby mode as described in claim 1, characterized in that, The method of determining whether a primary host is working properly based on preset indicator values of the primary hosts in the primary host group includes: Read the preset indicator values of each primary host, and calculate the resource utilization rate of each primary host based on the preset indicator values and preset calculation rules. When the resource utilization rate of the primary host is greater than or equal to a preset threshold, the primary host is judged to be malfunctioning. When the resource utilization rate of the primary host is less than the preset threshold, the primary host is determined to be working normally.
6. The primary / standby service switching method based on cold standby mode as described in claim 5, characterized in that, The preset calculation rules include: in, This represents the resource utilization rate of the i-th primary host. This represents the CPU utilization rate of the i-th master host. This represents the memory utilization rate of the i-th primary host. This represents the I / O utilization rate of the i-th master host. This represents the preset weight of the CPU in the i-th master host. This represents the preset weight of the memory of the i-th master host. This represents the preset weight of the I / O of the i-th master host.
7. A primary / standby service switching device based on cold standby mode, characterized in that, The device includes: Polling module: used to poll and determine whether the primary hosts in the primary host group are working properly based on pre-configured polling rules, or to determine whether the primary hosts are working properly based on preset indicator values of the primary hosts in the primary host group; Judgment module: When it is determined that the primary host is malfunctioning, it obtains the application directory path of the backup host corresponding to the IP address of the primary host based on a pre-determined mapping relationship between the IP address of the primary host and the application directory path of the backup host. The application directory path of the backup host includes multiple path nodes and application data that is the same as that of the corresponding primary host. The last path node of the application directory path of the backup host corresponding to the primary host is the IP address of the primary host. Switching module: Based on the directory path of the application on the backup host corresponding to the primary host's IP address, it locates the application on the backup host, fills the account information for starting the application into the corresponding area of the application's launch interface based on the pre-configured script information for starting the application, launches the application on the backup host based on the launch button on the launch interface, and generates a timestamp for the primary / backup service switchover operation.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a program that can be executed by the at least one processor, the program being executed by the at least one processor to enable the at least one processor to perform the primary / standby service switching method based on cold standby mode as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a primary / backup service switching program based on cold standby mode. When the primary / backup service switching program based on cold standby mode is executed by a processor, it implements the steps of the primary / backup service switching method based on cold standby mode as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method for managing and switching high availability multi-machine backup routing table
CN102938705A
Main and standby management system and management method for wide-area distributed service
CN112787855A