Disclosure of Invention
The invention provides a dual-system hot standby switching method and system for a 2-by-2 fetch-2 structure, and aims to solve the technical problem that data consistency and synchronism between main and standby systems are difficult to ensure when switching connection pipe work of the main and standby systems is performed in the prior art.
The technical scheme for solving the technical problems is as follows, the double-system hot standby switching method for the 2-by-2 taking-2 structure comprises the following steps:
periodically acquiring state factors of two systems, and calculating the own system state and the opposite system state of each system based on the state factors;
The system state is used for representing the target state of the other system except the current system;
The two systems respectively send the own calculated own system state and opposite system state to the opposite system;
Judging whether the cut system calculation is correct or not in each system according to the system state and the opposite system state calculated by the current system and the system state and the opposite system state sent by the opposite system, and if so, generating a cut system result;
each system performs a slicing operation based on the slicing results generated by the current system.
Further, the target states include a master state and a non-master state, and the non-master state includes a standby state and a standby state.
Further, the state factors include a communication state and a working state, and calculating the local system state and the opposite system state of each system specifically includes:
detecting the communication state between two systems, if the communication is normal, calculating the local system state and the opposite system state of each system by detecting the working state of the system;
If the communication is abnormal, the system in the main system state and the opposite system state are respectively output as the main system state and the standby state, and the system in the non-main system state and the opposite system state are respectively output as the standby state and the main system state;
if the communication is interrupted, the system state of both systems is outputted as a master system state, and the system state of both systems is outputted as a standby state.
Further, the above state factors further include a synchronization state, and calculating the local system state and the opposite system state of each system by detecting the working state of the system specifically includes:
detecting the working state between two systems, if the working state is normal, calculating the local system state and the opposite system state of each system by detecting the synchronous state between the two systems;
If the working state fails, defining the target state of one system as the main system state and the target state of the other system as the standby state, and correspondingly generating the main system states of the two systems and outputting the main system states.
Further, the above state factor further includes a cut request, and calculating the local state and the opposite state of each system by detecting the synchronization state between two systems specifically includes:
Detecting the synchronous state between two system systems, if the synchronous state is normal, calculating the local system state and the opposite system state of each system through the system cutting request;
if the synchronization state is abnormal, the system in the master state and the slave state are respectively outputted as the master state and the standby state, and the system in the non-master state and the slave state are respectively outputted as the standby state and the master state.
Further, the above state factor further includes a health state, and calculating the local state and the opposite state of each system by the cut request specifically includes:
judging whether each system has faults or not through application software, if not, calculating the own system state and the opposite system state of each system by detecting the health states of the two systems;
If one of the systems has a fault, the system state and the opposite system state of the system with the fault are respectively output as a standby state and a main system state, and the system state and the opposite system state of the system without the fault are respectively output as the main system state and the standby state;
If both systems have faults, the system in the master state and the slave state are respectively output as the master state and the standby state, and the system in the non-master state and the slave state are respectively output as the standby state and the master state.
Further, the calculating the local system state and the opposite system state of each system by detecting the health states of the two systems specifically includes:
And calculating health values of the two systems, judging whether the health values of the two systems are equal, if not, outputting the system state and the opposite system state of the system with high health value as a main system state and a standby system state respectively, and outputting the system state and the opposite system state of the system with low health value as the standby system state and the main system state respectively.
Further, the determining whether the cut system calculation is correct specifically is:
Judging whether the cut system calculation is correct or not through a state judgment equation, wherein the formula of the state judgment equation is shown as follows:
G The system =G′ Pairing system
G Pairing system =G′ The system
Wherein, G The system represents the present system state, G Pairing system represents the present system state, G ' Pairing system represents the calculated system state, and G' The system represents the calculated present system state;
If the cut calculation is correct, G The system is taken as the cut result of the current system.
The technical scheme has the beneficial effects that each system not only calculates the own target state, but also receives the target state of the other system, and the state judgment equation is used for verification, so that the consistency of the calculation results of the two systems is ensured. The double checking mechanism reduces the possibility of misjudgment and improves the stability and the safety of the system.
In a second aspect, the present invention further provides a dual-system hot standby switching system for a2 by 2 access 2 structure, for solving the above technical problems, including:
The state calculation module is used for periodically acquiring state factors of the two systems and calculating the own system state and the opposite system state of each system based on the state factors;
The system state is used for representing the target state of the other system except the current system;
the state transmission module is used for respectively transmitting the own calculated local system state and opposite system state to the opposite system by the two systems;
The state judging module is used for judging whether the cutting calculation is correct or not in each system according to the local system state and the opposite system state calculated by the current system and the local system state and the opposite system state sent by the opposite system, and generating a cutting result if the cutting calculation is correct;
And the system is used for executing the cutting operation according to the cutting result generated by the current system.
Further, the status factors include a communication status, an operating status, a synchronization status, a handoff request, and a health status.
Compared with the prior art, the invention has the following advantages:
1. When the system and the method calculate the local system state and the opposite system state of each system, a plurality of factors such as the communication state, the working state, the synchronous state, the cutting system request and the health state are comprehensively considered, and more comprehensive fault detection and processing are ensured. By periodically acquiring and analyzing the state factors of each system, potential faults can be found in time, and corresponding measures are taken for isolation. Once a fault or inconsistent state is detected, the system can rapidly switch the main and standby, reduce the service interruption time and improve the recovery speed of the system.
2. According to the invention, each system calculates the own target state, receives the target state of the other system, and checks the target state through the state judgment equation, so that the calculation results of the two systems are consistent. The double checking mechanism reduces the possibility of misjudgment and improves the stability and the safety of the system.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 shows a flow diagram of a dual-system hot standby switching method for a2 by 2 fetch 2 structure according to an embodiment of the present invention, as shown in fig. 1 and fig. 2, the dual-system hot standby switching method for a2 by 2 fetch 2 structure according to an embodiment of the present invention includes:
periodically acquiring state factors of two systems, and calculating the own system state and the opposite system state of each system based on the state factors;
The system state is used for representing the target state of the other system except the current system;
The two systems respectively send the own calculated own system state and opposite system state to the opposite system;
Judging whether the cut system calculation is correct or not in each system according to the system state and the opposite system state calculated by the current system and the system state and the opposite system state sent by the opposite system, and if so, generating a cut system result;
each system performs a slicing operation based on the slicing results generated by the current system.
In the embodiment, the whole cutting process is automatic, the cutting operation is performed after the cutting result is generated from the state detection, the requirement of manual intervention is reduced, and the response speed and the accuracy of the system are improved.
Optionally, the target state includes a master state and a non-master state, and the non-master state includes a standby state and a standby state.
Optionally, the state factors include a communication state and a working state, and calculating the local system state and the opposite system state of each system specifically includes:
detecting the communication state between two systems, if the communication is normal, calculating the local system state and the opposite system state of each system by detecting the working state of the system;
If the communication is abnormal, the system in the main system state and the opposite system state are respectively output as the main system state and the standby state, and the system in the non-main system state and the opposite system state are respectively output as the standby state and the main system state;
if the communication is interrupted, the system state of both systems is outputted as a master system state, and the system state of both systems is outputted as a standby state.
Among them, since the subsequent status factor requires the two systems to perform data transmission to perform detection, the communication status of the two systems is preferentially detected.
In this embodiment, the checking of the status factors is performed in order of priority from the communication status to the health status, so that the priority processing of the key factors (communication status) is ensured, thereby ensuring the stable operation of the system.
In this embodiment, as shown in fig. 3, 6 general-purpose computers are used to build a 2-by-2-fetch structure, three devices are respectively defined as a machine a, a machine B and a machine C in the system I and I I, the two systems realize a 2-by-2 hot standby redundancy function, the machine a and the machine B in the system realize a 2-fetch safety operation function, and the machine C serves as a communication machine. The three devices in the system and the corresponding devices between the systems are connected through redundant Ethernet, and all communication interfaces of the external devices are only connected with the C machines of the two systems through Ethernet.
When the IA-IA, I B-IIB and I C-IIC are partially interrupted and partially normal, the communication is abnormal, and when the I A-IIA, I B-IIB and I C-IIC are all interrupted, the communication is interrupted.
Optionally, the state factors further include a synchronization state, and calculating the local system state and the opposite system state of each system by detecting the working state of the system specifically includes:
detecting the working state between two systems, if the working state is normal, calculating the local system state and the opposite system state of each system by detecting the synchronous state between the two systems;
If the working state fails, defining the target state of one system as the main system state and the target state of the other system as the standby state, and correspondingly generating the main system states of the two systems and outputting the main system states.
In this embodiment, as shown in FIG. 2, the dual system includes an I system and a I I system, if the dual system has a fault and the current states are identical (dual main system, dual standby system), defining the target state of the I system as the main system state and the target state of the I I system as the standby state, and correspondingly generating the own system states and outputting the system states of the two systems;
if the two systems are in failure and are inconsistent (one system is standby and the other system is standby), the system in standby state and the opposite system in standby state are respectively output as the main system state and the standby state, and the system in standby state and the opposite system in standby state are respectively output as the standby state and the main system state.
Optionally, the state factor further includes a cut request, and calculating the local state and the opposite state of each system by detecting a synchronization state between two systems specifically includes:
Detecting the synchronous state between two system systems, if the synchronous state is normal, calculating the local system state and the opposite system state of each system through the system cutting request;
if the synchronization state is abnormal, the system in the master state and the slave state are respectively outputted as the master state and the standby state, and the system in the non-master state and the slave state are respectively outputted as the standby state and the master state.
Optionally, the state factors further include health states, and calculating the local state and the opposite state of each system through the cut request specifically includes:
judging whether each system has faults or not through application software, if not, calculating the own system state and the opposite system state of each system by detecting the health states of the two systems;
If one of the systems has a fault, the system state and the opposite system state of the system with the fault are respectively output as a standby state and a main system state, and the system state and the opposite system state of the system without the fault are respectively output as the main system state and the standby state;
If both systems have faults, the system in the master state and the slave state are respectively output as the master state and the standby state, and the system in the non-master state and the slave state are respectively output as the standby state and the master state.
In this embodiment, the system provides an interface for the application software, allowing the application software to send the cut-line request according to its own judgment. This enhances the flexibility and adaptability of the system so that the application layer can also participate in the fault management and handover process of the system.
Optionally, calculating the local system state and the opposite system state of each system by detecting the health states of the two systems specifically includes:
And calculating health values of the two systems, judging whether the health values of the two systems are equal, if not, outputting the system state and the opposite system state of the system with high health value as a main system state and a standby system state respectively, and outputting the system state and the opposite system state of the system with low health value as the standby system state and the main system state respectively.
In this embodiment, by calculating and comparing the health values of the two systems, a healthier system can be selected as the master system under the condition that both systems are normal but have different health degrees, thereby further improving the reliability and stability of the system.
Optionally, determining whether the cut-line calculation is correct is:
Judging whether the cut system calculation is correct or not through a state judgment equation, wherein the formula of the state judgment equation is shown as follows:
G The system =G′ Pairing system
G Pairing system =G′ The system
Optionally, G The system represents the current system's own system state, G Pairing system represents the current system's own system state, G ' Pairing system represents the own system state calculated by the own system, and G' The system represents the own system state calculated by the own system;
If the cut calculation is correct, G The system is taken as the cut result of the current system.
In this embodiment, the state judgment equation is used to verify, so as to ensure that the calculation results of both sides are consistent. If the calculation results are inconsistent, the fault is indicated, and the cutting is not executed at the moment, so that the cutting scene with the fault is prevented, and double-series recalculation and interactive confirmation are waited. The double checking mechanism reduces the possibility of misjudgment and improves the stability and the safety of the system.
In this embodiment, if the two systems have confirmed the cutting result, immediately execute the cutting, directly modify the working state of the system into the confirmed target cutting state G The system of the system, and according to this rule, correspondingly modify the working state into the target cutting state G Pairing system of the system, so as to complete the complete cutting logic.
Based on the same principle as the method shown in fig. 1, the embodiment of the present invention further provides a dual-system hot standby switching system for a 2 by 2 access 2 structure, as shown in fig. 4, including:
The state calculation module is used for periodically acquiring state factors of the two systems and calculating the own system state and the opposite system state of each system based on the state factors;
The system state is used for representing the target state of the other system except the current system;
the state transmission module is used for respectively transmitting the own calculated local system state and opposite system state to the opposite system by the two systems;
The state judging module is used for judging whether the cutting calculation is correct or not in each system according to the local system state and the opposite system state calculated by the current system and the local system state and the opposite system state sent by the opposite system, and generating a cutting result if the cutting calculation is correct;
And the system is used for executing the cutting operation according to the cutting result generated by the current system.
The dual hot standby switching system for a 2 by 2 access 2 structure according to the embodiments of the present invention may execute the dual hot standby switching method for a 2 by 2 access 2 structure according to the embodiments of the present invention, and its implementation principle is similar, and actions executed by each module and unit in the dual hot standby switching system for a 2 by 2 access 2 structure according to the embodiments of the present invention correspond to steps in the dual hot standby switching method for a 2 by 2 access 2 structure according to the embodiments of the present invention, and detailed functional descriptions of each module of the dual hot standby switching system for a 2 by 2 access 2 structure may be specifically referred to the descriptions in the corresponding dual hot standby switching method for a 2 by 2 access 2 structure shown in the foregoing, which are not repeated herein.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The name of a module does not in some cases define the module itself.
Based on the same principles as the methods shown in the embodiments of the present invention, there is also provided in the embodiments of the present invention an electronic device that may include, but is not limited to, a processor and a memory, the memory storing a computer program, the processor being configured to execute the methods shown in any of the embodiments of the present invention by invoking the computer program.
The memory is used for storing application program codes (computer programs) for executing the scheme of the invention, and the execution is controlled by the processor. The processor is configured to execute the application code stored in the memory to implement what is shown in the foregoing method embodiments.
Embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, which when run on a computer, causes the computer to perform the corresponding method embodiments described above.
According to another aspect of the present invention, there is also provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the methods provided in the implementation of the various embodiments described above.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, SMA L L TA L K, C++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
It should be appreciated that the flow charts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The computer-readable storage medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above-described embodiments.
The above description is only illustrative of the preferred embodiments of the present invention and of the principles of the technology employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in the present invention is not limited to the specific combinations of technical features described above, but also covers other technical features formed by any combination of the technical features described above or their equivalents without departing from the spirit of the disclosure. Such as the above-mentioned features and the technical features disclosed in the present invention (but not limited to) having similar functions are replaced with each other.