Dual-computer hot standby method and device in dual-computer cluster, equipment and medium
By detecting the availability of shared storage resources in a dual-machine cluster and switching to local storage, the application abnormality caused by the unavailability of shared storage is solved, ensuring business continuity and reliability.
Patent Information
- Application Number
- CN202411614495.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-13
AI Technical Summary
In a dual-machine cluster, when active nodes and standby nodes jointly access shared storage, the unavailability of shared storage resources may lead to active node failure, which in turn affects the continuity and reliability of services.
By detecting whether the storage resources of the application in the shared storage are available, if not available, the storage address of the application is switched from the shared storage to the corresponding location in the local storage of the active node. If the application status is still abnormal, close the application of the active node and enable the application of the standby node.
It solves the application abnormality caused by the unavailability of shared storage resources, avoids business interruptions, and ensures the business continuity and reliability of dual-machine clusters.
Smart Images

Figure CN119484252A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of dual-machine hot standby, and in particular to a dual-machine hot standby method, device, equipment and medium in a dual-machine cluster. Background Art
[0002] In a dual-machine hot standby scenario of a highly available (HA) dual-machine cluster, the standby node replicates the data of the normal operation of the active node, and when the active node fails, the standby node is switched to the active node. However, in some cases, the active node and the standby node may need to access storage resources in the shared storage together, and the unavailability of the storage resources may also cause the active node to fail. In this case, switching the standby node to the active node cannot solve the failure, making the dual-machine cluster unable to guarantee business continuity and reliability. Summary of the invention
[0003] The embodiments of the present application provide a dual-machine hot standby method, apparatus, device and medium in a dual-machine cluster, which are used to ensure the continuity and reliability of the services of the dual-machine cluster.
[0004] In a first aspect, an embodiment of the present application provides a dual-machine hot standby method in a dual-machine cluster, wherein the dual-machine cluster includes an active node and a standby node, and the method includes:
[0005] sequentially detecting an application state of at least one application in the active node;
[0006] When an application state of any of the applications is abnormal and any of the applications uses shared storage, detecting whether storage resources corresponding to any of the applications in the shared storage are available; wherein the shared storage is a storage that is accessed jointly by the active node and the standby node;
[0007] If it is not available, the storage address in the configuration file of any of the applications is switched from the first storage location in the shared storage to the corresponding second storage location in the local storage of the active node; wherein the local storage is synchronized with the storage resources in the shared storage;
[0008] After using the local storage, if the application state of any of the applications is still abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
[0009] In the embodiment of the present application, for at least one application deployed in the active node, the application status of each application is detected in turn; when the application status of the application using the shared storage is abnormal, it can be first determined whether the storage resources of the application in the shared storage can be used normally. If it cannot be used normally, the local storage is used instead. Since the storage resources in the shared storage are synchronized in the local storage, the local storage can provide the same storage resources as the shared storage. If the abnormality of the application is caused by the unavailability of the storage resources in the shared storage, the abnormality of the application can be solved by using the local storage, thereby avoiding the business interruption of the application due to the unavailability of the shared storage. After using the local storage, if the application status of the application is still abnormal, it means that the abnormality of the application is not caused by the unavailability of the storage resources in the shared storage. At this time, shut down at least one application in the active node and enable at least one corresponding application in the standby node, which can avoid the business interruption of the application due to the failure of the active node. Therefore, the embodiment of the present application can ensure the continuity and reliability of the business of the dual-machine cluster.
[0010] In some embodiments, after sequentially detecting the application status of at least one application in the active node, the method further includes:
[0011] When an application state of any of the applications is abnormal and any of the applications does not use the shared storage, restart and repair any of the applications;
[0012] When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
[0013] In some embodiments, after detecting whether the storage resource corresponding to any of the applications in the shared storage is available, the method further includes:
[0014] If the storage resources of any of the applications in the shared storage are available, restart and repair any of the applications;
[0015] When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
[0016] In some embodiments, after the storage address in the configuration file of any of the applications is switched from the shared storage to the local storage, the method further includes:
[0017] When the application state of any of the applications returns to normal, determining whether there are other applications among the multiple applications that use the shared storage;
[0018] If so, when it is detected that the storage resource corresponding to the other application in the shared storage is unavailable, the storage address in the configuration file of the other application is switched from the third storage location in the shared storage to the corresponding fourth storage location in the local storage;
[0019] When it is detected that the application status of the other application is abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
[0020] In some embodiments, determining that an application state of any of the applications is abnormal includes:
[0021] When detecting that an application process of any of the applications exists, if it is determined that the application process is in a non-service state, then determining that an application state of any of the applications is abnormal; or
[0022] When it is detected that the application process of any of the applications does not exist, it is determined whether any of the applications has a shutdown mark. If the shutdown mark does not exist, it is determined that the application state of any of the applications is abnormal; wherein the shutdown mark indicates that when the application process does not exist, the application state of any of the applications is normal.
[0023] In some embodiments, sequentially detecting the application status of at least one application in the active node includes:
[0024] dividing the plurality of applications into a first application set that uses the shared storage and a second application set that does not use the shared storage;
[0025] The application state of at least one first application in the first application set is detected in sequence, and when it is determined that the application state of at least one first application is normal, the application state of at least one second application in the second application set is detected in sequence.
[0026] In some embodiments, the method further comprises:
[0027] Backing up the storage resources in the shared storage to the local storage;
[0028] The changed storage resources in the shared storage are detected in real time, and the detected changed storage resources are synchronized to the local storage.
[0029] In a second aspect, an embodiment of the present application provides a dual-machine hot standby device in a dual-machine cluster, wherein the dual-machine cluster includes an active node and a standby node, and the device includes:
[0030] A detection module, used to detect the application status of at least one application in the active node in sequence;
[0031] A judgment module, used for detecting whether the storage resources corresponding to any of the applications in the shared storage are available when an application state of any of the applications is abnormal and any of the applications uses shared storage; wherein the shared storage is a storage commonly accessed by the active node and the standby node;
[0032] A switching module, configured to switch the storage address in the configuration file of any of the applications from the first storage location in the shared storage to the corresponding second storage location in the local storage of the active node if the storage resources of any of the applications in the shared storage are unavailable; wherein the local storage is synchronized with the storage resources in the shared storage;
[0033] A transfer module is used to close at least one of the applications in the active node and enable at least one corresponding application in the standby node if the application status of any of the applications is still abnormal after using the local storage.
[0034] In some embodiments, the apparatus further comprises a first repair module, configured to:
[0035] When an application state of any of the applications is abnormal and any of the applications does not use the shared storage, restart and repair any of the applications;
[0036] When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
[0037] In some embodiments, the apparatus further comprises a second repair module, configured to:
[0038] If the storage resources of any of the applications in the shared storage are available, restart and repair any of the applications;
[0039] When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
[0040] In some embodiments, the apparatus further comprises a third repair module, configured to:
[0041] When the application state of any of the applications returns to normal, determining whether there are other applications among the multiple applications that use the shared storage;
[0042] If so, when it is detected that the storage resource corresponding to the other application in the shared storage is unavailable, the storage address in the configuration file of the other application is switched from the third storage location in the shared storage to the corresponding fourth storage location in the local storage;
[0043] When it is detected that the application status of the other application is abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
[0044] In some embodiments, the determination module is further configured to:
[0045] When detecting that an application process of any of the applications exists, if it is determined that the application process is in a non-service state, then determining that an application state of any of the applications is abnormal; or
[0046] When it is detected that the application process of any of the applications does not exist, it is determined whether any of the applications has a shutdown mark. If the shutdown mark does not exist, it is determined that the application state of any of the applications is abnormal; wherein the shutdown mark indicates that when the application process does not exist, the application state of any of the applications is normal.
[0047] In some embodiments, the detection module is further configured to:
[0048] dividing the plurality of applications into a first application set that uses the shared storage and a second application set that does not use the shared storage;
[0049] The application state of at least one first application in the first application set is detected in sequence, and when it is determined that the application state of at least one first application is normal, the application state of at least one second application in the second application set is detected in sequence.
[0050] In some embodiments, the apparatus further comprises a synchronization module, configured to:
[0051] Backing up the storage resources in the shared storage to the local storage;
[0052] The changed storage resources in the shared storage are detected in real time, and the detected changed storage resources are synchronized to the local storage.
[0053] In a third aspect, the present application provides an electronic device, including:
[0054] A memory for storing program instructions;
[0055] A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect or any one of the second aspect according to the obtained program instructions.
[0056] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods in the first aspect or any one of the methods in the second aspect.
[0057] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, which, when executed on a computer, enables the computer to execute any one of the methods in the first aspect or any one of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;
[0059] Figure 2 A flowchart of a dual-machine hot standby method in a dual-machine cluster provided in an embodiment of the present application;
[0060] Figure 3 A schematic diagram of a synchronization process between a shared storage and a local storage provided in an embodiment of the present application;
[0061] Figure 4A A flowchart of another dual-machine hot standby method in a dual-machine cluster provided in an embodiment of the present application;
[0062] Figure 4B A flowchart of another dual-machine hot standby method in a dual-machine cluster provided in an embodiment of the present application;
[0063] Figure 5 A structural diagram of a dual-machine hot standby device in a dual-machine cluster provided in an embodiment of the present application;
[0064] Figure 6 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0066] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0067] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0068] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.
[0069] Before introducing the dual-machine hot standby method in a dual-machine cluster provided by an embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.
[0070] In the related art, in a dual-machine hot standby scenario of a dual-machine cluster (Highly Available, HA), the standby node replicates the data of the normal operation of the active node, and when the active node fails, the standby node is switched to the active node. Normally, there are shared resources in each node in the HA dual-machine hot standby system, and the resources are taken over by the standby node when the active node fails. However, if the resource fails, the entire system will not be able to continue to undertake business. However, in some cases, the active node and the standby node may need to jointly access storage resources in the shared storage. For example, the shared storage includes SAN (Storage Area Network) storage. When the active node fails, the shared storage is taken over by the standby node.
[0071] However, the unavailability of storage resources in the shared storage may also cause the active node to fail. At this time, switching the standby node to the active node cannot solve the failure, and the dual-machine cluster will be unable to continue to undertake business, making the dual-machine cluster unable to guarantee business continuity and reliability. At the same time, considering that in some scenarios, both the active node and the standby node need to deploy multiple applications, in order to ensure business continuity, it is necessary to ensure that all applications can run on the standby node when the active node fails.
[0072] In view of this, the embodiment of the present application provides a dual-machine hot standby method, device, equipment and medium in a dual-machine cluster. For at least one application deployed in the active node, the application status of each application is detected in turn; when the application status of the application using the shared storage is abnormal, it can be first determined whether the storage resources of the application in the shared storage can be used normally. If it cannot be used normally, the local storage is used instead. Since the local storage is synchronized with the storage resources in the shared storage, the local storage can provide the same storage resources as the shared storage. If the abnormality of the application is caused by the unavailability of the storage resources in the shared storage, the abnormality of the application can be solved by using the local storage, thereby avoiding the business interruption of the application due to the unavailability of the shared storage. After using the local storage, if the application status of the application is still abnormal, it means that the abnormality of the application is not caused by the unavailability of the storage resources in the shared storage. At this time, shut down at least one application in the active node and enable the corresponding at least one application in the standby node, which can avoid the business interruption of the application due to the failure of the active node. Therefore, the embodiment of the present application can ensure the continuity and reliability of the business of the dual-machine cluster.
[0073] The application scenarios of the embodiments of the present application are described in detail below.
[0074] like Figure 1 As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes an active node 110 and a standby node 120 in a dual-machine cluster, and the active node 110 and the standby node 120 can communicate with each other through a communication network, which can be a wired network or a wireless network.
[0075] The active node is the node that is executing tasks in the dual-machine cluster. The standby node is used to take over the service of the active node when the active node fails, so as to ensure that the overall service of the dual-machine cluster is not interrupted. One or more applications can be deployed in the active node 110. For example, the application can be a message queue middleware software, a Web (World Wide Web) server software, etc. The same application as that in the active node 110 can be deployed in the standby node 120, and during the normal operation of each application in the active node, the operation data of each application is synchronized to the standby node 120. In this way, when the active node 110 fails, the standby node 120 can be enabled and used as the new active node.
[0076] Specifically, the active node and the standby node can be deployed in a server respectively. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.
[0077] It should be noted that Figure 1 The figure is only an example. In fact, the number of standby nodes 120 is not limited and is not specifically limited in the embodiments of the present application.
[0078] like Figure 2 As shown, it is a flowchart of a dual-machine hot standby method in a dual-machine cluster provided in an embodiment of the present application. The method is described by taking the active node in the dual-machine cluster as an example. The method includes the following S21-S24:
[0079] S21. Detect application status of at least one application in an active node in sequence.
[0080] Among them, one or more applications can be deployed in the active node, and the application can be a message queue middleware software, or a Web server software, etc. A corresponding detection script is deployed for each application, and the detection script is used to detect the application status of the corresponding application, that is, abnormal operation status or normal operation status.
[0081] When multiple applications are deployed in an active node, the multiple applications may include applications that use shared storage or applications that do not use shared storage. Shared storage is storage that is accessed by both the active node and the standby node and can be deployed in a storage device. Specifically, shared storage is storage that is used exclusively by the primary and standby nodes. When the active node is operating normally, the shared storage is mounted to the active node. When the active node fails, the shared storage needs to be mounted to the standby node and then restarted. For example, shared storage can be SAN storage. Shared storage provides centralized storage management functions, allowing multiple servers (such as active nodes and standby nodes) to access the same storage pool at the same time, thereby improving the utilization and flexibility of storage resources.
[0082] In some embodiments, when an active node is deployed with applications that use shared storage and applications that do not use shared storage, when detecting the application status of at least one application in the active node in sequence, the multiple applications can be divided into a first application set that uses shared storage and a second application set that does not use shared storage; the application status of at least one first application in the first application set is detected in sequence, and when it is determined that the application status of at least one first application is normal, the application status of at least one second application in the second application set is detected in sequence.
[0083] Specifically, for different applications among multiple applications, corresponding application status monitoring instructions can be executed. For example, when the application is message queue middleware software, it is necessary to judge the channel status. The channel is a communication path used to transmit messages between two queue managers, which can be understood as an application process. The special instructions that come with the message queue middleware software (such as the dspmqsc instruction and the runmqsc instruction) can be used to check the channel status to determine whether fault repair is needed. For another example, when the application is Web server software, general process viewing instructions can be used, such as the ps-ef instruction, which is a commonly used Linux command used to display detailed information of all running processes in the system.
[0084] In the embodiment of the present application, it is necessary not only to detect whether the application process of the application exists, but also to detect whether the state of the application process is abnormal. When the application process enters a non-service state such as sleep or suspension, the application state is considered abnormal. When the application process is in a service state (i.e., active state), the application state is authenticated to be normal. In addition, if the application process of the application does not exist, it can be further determined whether the application has been manually shut down, which can be determined specifically by whether there is a shutdown mark; if it has not been manually shut down, the application state is considered abnormal and fault repair is required; if it has been manually shut down, the application state is considered normal and no fault repair is required.
[0085] Therefore, it is determined that the application status of any application is abnormal, including the following two situations:
[0086] In the first case, when the existence of an application process of any application is detected, if it is determined that the application process is in a non-service state, it is determined that an application state of any application is abnormal.
[0087] In the second case, when it is detected that the application process of any application does not exist, it is determined whether any application has a shutdown mark. If there is no shutdown mark, it is determined that the application state of any application is abnormal; wherein the shutdown mark indicates that when the application process does not exist, the application state of any application is normal.
[0088] In the embodiment of the present application, when detecting the application status of each application, when it is detected that the application process exists, it is determined whether the application status is abnormal by judging whether the application process is in a non-service state; when it is detected that the application process does not exist, it is necessary to judge again whether the application process is manually shut down. Since there are scenarios in actual application scenarios such as business suspension that require active shutdown of applications, in order to prevent inaccurate detection results of the application status, a shutdown mark is added to the manual shutdown script to indicate that the application is manually shut down, that is, when the shutdown mark exists, it means that the application is normal when the application process does not exist.
[0089] It should be noted that there is no limitation on the detection order of multiple applications. The application using shared resources may be detected first, and then the application not using shared resources may be detected. Alternatively, multiple applications may be detected in a set order without distinguishing whether the application uses shared resources.
[0090] S22: When an application state of any application is abnormal and any application uses shared storage, detect whether storage resources corresponding to any application in the shared storage are available.
[0091] Among them, when the application status of any application is abnormal, if the application uses shared storage, it is considered that the application abnormality may be caused by the unavailability of shared storage or the abnormality of active nodes. At this time, first check whether the storage resources corresponding to the application in the shared storage are available. Specifically, it can be determined whether the storage resources corresponding to the application are accessible. If not, it is unavailable.
[0092] Specifically, when the active node includes multiple applications using shared storage, the shared storage can store storage resources that each application needs to access. The storage address of the storage resource to be accessed is stored in the configuration file of each application, which corresponds to a storage location in the shared storage.
[0093] S23. If it is not available, the storage address in the configuration file of any application is switched from the first storage location in the shared storage to the corresponding second storage location in the local storage of the active node; wherein the local storage is synchronized with the storage resources in the shared storage.
[0094] There may be many reasons why the storage resources corresponding to the application in the shared storage are unavailable, for example, a network failure occurs in the storage device where the shared storage is located, the hard disk is damaged, etc. The storage resources in the shared storage that any application needs to access are located in the above-mentioned first storage location, and the second storage location in the local storage stores the same storage resources as the first storage location. For example, the first storage location may be the storage location where file b is located under folder a in the shared storage, and the second storage location may be the storage location where file b is located under folder a in the local storage. After switching the storage address in the configuration file of any of the above-mentioned applications from the above-mentioned first storage location to the above-mentioned second storage location, the application can be restarted to determine whether the application has been repaired successfully.
[0095] At the same time, the standby node copies the running data of any of the above applications in the active node, and also switches the storage address in the configuration file of the application from the first storage location in the shared storage to the corresponding storage location in the local storage of the standby node.
[0096] In some embodiments, before executing the above S23, the active node may back up the storage resources in the shared storage to the local storage of the active node; then, detect the changed storage resources in the shared storage in real time, and synchronize the detected changed storage resources to the local storage.
[0097] At the same time, the standby node also backs up the storage resources in the shared storage to the local storage of the standby node; then, the changed storage resources in the shared storage are detected in real time, and the detected changed storage resources are synchronized to the local storage.
[0098] Among them, Figure 3 As shown, the changed storage resources in the shared storage can be detected by a detection tool, and then the changed storage resources can be synchronized to the local storage by a synchronization tool.
[0099] Specifically, the shared storage includes one or more folders, and the monitoring interface provided by the operating system can be used to monitor changes in the specified directory or specified file in the shared storage, such as creation, modification, deletion, move and other events, so as to detect the changed storage resources in the shared storage in real time. Specifically, when the file content in the folder changes or the file directory changes, the changed file content or file directory can be synchronized to the corresponding file or folder in the local storage through the file synchronization tool. In the process of synchronizing the local storage with the shared storage, only the changed storage resources can be synchronized, thereby improving the synchronization efficiency.
[0100] In an embodiment of the present application, in order to overcome the single point risk of shared storage, a real-time backup method is adopted to write the storage resources in the shared storage to the local storage. When the shared storage is unavailable, the application is restarted using the real-time backed-up local storage to ensure that the application's business is not interrupted, thereby ensuring business continuity and system robustness.
[0101] S24. After using the local storage, if the application status of any application is still abnormal, at least one application in the active node is closed, and at least one corresponding application in the standby node is enabled.
[0102] After any of the above applications uses local storage, if it is detected that the application status of the application is still abnormal, it means that the application is abnormal due to the failure of the active node itself. Therefore, at least one application in the active node is closed, and a shutdown flag is set for the at least one application, and then the corresponding at least one application in the standby node is enabled. In the normal operation of at least one application in the active node, the standby node will synchronize the operation data of at least one application in the active node.
[0103] In an embodiment of the present application, when an application state of an application using shared storage is abnormal, if it is determined that the storage resources of the application in the shared storage cannot be used normally, local storage is used instead. Since the local storage is synchronized with the storage resources in the shared storage, the local storage can provide the same storage resources as the shared storage. If the abnormality of the application is caused by the unavailability of the storage resources in the shared storage, the abnormality of the application can be solved by using the local storage, thereby avoiding the business interruption of the application due to the unavailability of the shared storage. After using the local storage, if the application state of the application is still abnormal, it means that the abnormality of the application is not caused by the unavailability of the storage resources in the shared storage. At this time, shutting down at least one application in the active node and enabling at least one corresponding application in the standby node can avoid the business interruption of the application due to the failure of the active node. Therefore, the embodiment of the present application can ensure the continuity and reliability of the business of the dual-machine cluster.
[0104] In some embodiments, in the process of sequentially detecting the application status of at least one application in the active node in the above S21, when the application status of any application is abnormal and any application does not use shared storage, any application is restarted and repaired; when the restart and repair fails, at least one application in the active node is closed, and a shutdown flag is set for at least one application, indicating that at least one application in the active node is manually shut down; then, at least one corresponding application in the standby node is enabled; in addition, when any of the above applications is successfully restarted and repaired, there is no need to enable the standby node.
[0105] In an embodiment of the present application, when an application that does not use shared storage encounters an abnormality, a repair-first-then-transfer approach is adopted, that is, if the restart and modification fail, the standby node is enabled to minimize unnecessary start and stop of the application, thereby ensuring business continuity and the availability of the dual-machine cluster.
[0106] In some embodiments, after detecting whether the storage resources corresponding to any application in the shared storage are available, the above S22 also includes: if the storage resources of any application in the shared storage are available, restarting and repairing any application; when the restart and repair fails, shutting down at least one application in the active node, and setting a shutdown flag for at least one application, indicating that at least one application in the active node is manually shut down; then, enabling at least one corresponding application in the standby node; in addition, when any of the above applications is successfully restarted and repaired, there is no need to enable the standby node.
[0107] In an embodiment of the present application, when an application using shared storage encounters an abnormality, if the storage resources corresponding to the application in the shared storage are available, a repair-first-then-transfer approach is adopted, that is, if the restart and modification fail, the standby node is enabled, thereby minimizing unnecessary start and stop of the application and ensuring business continuity and availability of the dual-machine cluster.
[0108] In some embodiments, after the storage address in the configuration file of any application is switched from shared storage to local storage, when the application state of any application returns to normal, it is determined whether there are other applications among the multiple applications that use the shared storage; if so, when it is detected that the storage resources corresponding to the other applications in the shared storage are unavailable, the storage address in the configuration file of the other application is switched from the third storage location in the shared storage to the corresponding fourth storage location in the local storage; wherein the storage resources in the shared storage that other applications need to access are located at the above-mentioned third storage location, and the fourth storage location in the local storage stores the same storage resources as the third storage location.
[0109] Furthermore, when an abnormality is detected in the application status of other applications, at least one application in the active node is closed, and a shutdown flag is set for the at least one application, and then at least one corresponding application in the standby node is enabled.
[0110] Specifically, after the storage address in the configuration file of any application is switched from shared storage to local storage, when the application status of any application returns to normal, for other applications using shared storage, it can be detected whether the storage resources corresponding to the other applications in the shared storage are available. Specifically, the corresponding storage resources in the shared storage are determined according to the storage address in the configuration file of the other application. If they are unavailable, switch from shared storage to local storage. After using the local storage, if the application status of the other application is abnormal, close at least one application in the active node and enable at least one corresponding application in the standby node.
[0111] In addition, if storage resources corresponding to other applications in the shared storage are available, the other applications can continue to use the shared storage.
[0112] It should be noted that for multiple applications using shared storage, when the shared storage fails, the storage resources corresponding to some applications may be unavailable, or the storage resources corresponding to all applications may be unavailable. For example, when some hard disks of the storage device where the shared storage is located are damaged, some storage resources may be unavailable, and when the storage device has a network failure, all storage resources may be unavailable. Therefore, when the active node detects that the shared storage has failed, it can determine which applications' storage resources are unavailable due to the failure, and change these applications to use the corresponding storage resources in the local storage.
[0113] In an embodiment of the present application, after any abnormal application is switched from shared storage to local storage, if the application status returns to normal, it is possible to continue to detect whether the storage resources corresponding to other applications in the shared storage are available. If they are also unavailable, other applications are also switched from shared storage to local storage, thereby reducing the risk of failure caused by shared storage anomalies.
[0114] Combine the following Figure 4A and Figure 4B , an overall implementation process of the dual-machine hot standby method in the dual-machine cluster of an embodiment of the present application is exemplarily described.
[0115] like Figure 4A and Figure 4B As shown, the overall process of the dual-machine hot standby method in the dual-machine cluster includes the following S41-S57:
[0116] S41. Read a list of applications that do not use shared storage in active nodes.
[0117] S42: Determine whether there are any unprocessed applications. If yes, execute S43; if no, execute S47.
[0118] S43. Determine whether the application status of the current application is normal. If yes, return to S42; if no, execute S44.
[0119] S44. Restart and repair the current application.
[0120] S45. Determine whether the application status of the current application is normal. If yes, return to S42; if no, execute S46.
[0121] S46. Close all applications in the active node, create a shutdown mark, and enable the standby node.
[0122] S47: Read a list of applications using shared storage in the active node.
[0123] S48, determine whether there are any unprocessed applications, if not, execute S49, if yes, end.
[0124] S49: Determine whether the application status of the current application is normal, if yes, return to S48, if no, execute S50.
[0125] S50, determine whether the shared storage is normal, if yes, execute S57, if not, execute S52. Here, when the shared storage is abnormal, all applications using the shared storage will use local storage instead.
[0126] S51. Read a list of applications using shared storage.
[0127] S52: Determine whether all applications using the shared storage have completed switching. If not, execute S53. If not, end.
[0128] Here, it is determined whether all applications using the shared storage should be changed to use the local storage.
[0129] S53. The application currently using the shared storage is changed to use the local storage.
[0130] S54: Determine whether the application status of the current application is normal, if yes, return to S52, if no, execute S57.
[0131] S55. Restart and repair the current application.
[0132] S56: Determine whether the application status of the current application is normal, if yes, return to S48, if no, execute S57.
[0133] S57. Close all applications in the active node, create a shutdown flag, and enable the standby node.
[0134] Based on the same inventive concept, an embodiment of the present application also provides a dual-machine hot standby device in a dual-machine cluster. The principle of solving the problem by the device is similar to the method of the above embodiment. Therefore, the implementation of the device can refer to the implementation of the above method, and the repeated parts will not be repeated.
[0135] like Figure 5 As shown, a dual-machine hot standby device 500 in a dual-machine cluster is provided in an embodiment of the present application. The dual-machine cluster includes an active node and a standby node, and the device includes:
[0136] A detection module 501 is used to detect the application status of at least one application in the active node in sequence;
[0137] The judgment module 502 is used to detect whether the storage resources corresponding to any application in the shared storage are available when the application state of any application is abnormal and any application uses the shared storage; wherein the shared storage is the storage accessed by the active node and the standby node together;
[0138] The switching module 503 is used to switch the storage address in the configuration file of any application from the first storage location in the shared storage to the corresponding second storage location in the local storage of the active node if the storage state of the shared storage is abnormal; wherein the local storage is synchronized with the storage resources in the shared storage;
[0139] The transfer module 504 is used to close at least one application in the active node and enable at least one corresponding application in the standby node if the application status of any application is still abnormal after using the local storage.
[0140] In some embodiments, the apparatus further comprises a first repair module, configured to:
[0141] When the application status of any application is abnormal and any application does not use shared storage, restart and repair any application;
[0142] The second transfer module is used to shut down at least one application in the active node and enable at least one corresponding application in the standby node when the restart repair fails.
[0143] In some embodiments, the apparatus further comprises a second repair module, configured to:
[0144] If the storage resources of any application in the shared storage are available, restart and repair any application;
[0145] When the restart repair fails, at least one application in the active node is shut down, and at least one corresponding application in the standby node is enabled.
[0146] In some embodiments, the apparatus further comprises a third repair module, configured to:
[0147] When the application state of any application returns to normal, determining whether there are other applications using the shared storage among the multiple applications;
[0148] If so, when it is detected that the storage resource corresponding to the other application in the shared storage is unavailable, the storage address in the configuration file of the other application is switched from the third storage location in the shared storage to the corresponding fourth storage location in the local storage;
[0149] When it is detected that the application status of the other application is abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
[0150] In some embodiments, the determination module is further configured to:
[0151] When the existence of an application process of any application is detected, if it is determined that the application process is in a non-service state, it is determined that an application state of any application is abnormal; or
[0152] When it is detected that the application process of any application does not exist, it is determined whether any application has a shutdown mark. If there is no shutdown mark, it is determined that the application state of any application is abnormal; wherein the shutdown mark indicates that when the application process does not exist, the application state of any application is normal.
[0153] In some embodiments, the detection module is further configured to:
[0154] Dividing the plurality of applications into a first application set using shared storage and a second application set not using shared storage;
[0155] The application state of at least one first application in the first application set is detected in sequence, and when it is determined that the application state of the at least one first application is normal, the application state of at least one second application in the second application set is detected in sequence.
[0156] In some embodiments, the apparatus further comprises a synchronization module for:
[0157] Back up storage resources in shared storage to local storage;
[0158] Detect changes in shared storage resources in real time and synchronize the detected changes to local storage.
[0159] Based on the same inventive concept, the embodiment of the present application provides an execution device, which can realize the dual-machine hot standby function in the dual-machine cluster discussed above, please refer to Figure 6 , the device includes a memory 601 and a processor 602.
[0160] The memory 601 is used to store program instructions;
[0161] The processor 602 is used to call the program instructions stored in the memory and execute the dual-machine hot standby method in the dual-machine cluster according to the obtained program.
[0162] In the embodiment of the present application, the processor 602 may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0163] Memory 601, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. Memory 601 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic storage, disk, optical disk, etc. Memory 601 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 601 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0164] Since the principle of solving the problem by the above electronic device is similar to the dual-machine hot standby method in a dual-machine cluster, the implementation of the above electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0165] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, and a computer program product includes: a computer program code, when the computer program code is executed on a computer, the computer executes any of the dual-machine hot standby methods in a dual-machine cluster discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the dual-machine hot standby method in a dual-machine cluster, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0166] Based on the same inventive concept, the embodiment of the present application further provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the dual-machine hot standby methods in a dual-machine cluster as discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the dual-machine hot standby method in a dual-machine cluster, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0167] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0168] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0169] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0170] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of user-operated steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0171] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A dual-machine hot standby method in a dual-machine cluster, characterized in that: The dual-machine cluster includes an active node and a standby node, and the method includes: sequentially detecting an application state of at least one application in the active node; When an application state of any of the applications is abnormal and any of the applications uses shared storage, detecting whether storage resources corresponding to any of the applications in the shared storage are available; wherein the shared storage is a storage that is accessed jointly by the active node and the standby node; If it is not available, the storage address in the configuration file of any of the applications is switched from the first storage location in the shared storage to the corresponding second storage location in the local storage of the active node; wherein the local storage is synchronized with the storage resources in the shared storage; After using the local storage, if the application status of any of the applications is still abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
2. The method according to claim 1, characterized in that After sequentially detecting the application status of at least one application in the active node, the method further includes: When an application state of any of the applications is abnormal and any of the applications does not use the shared storage, restart and repair any of the applications; When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
3. The method according to claim 1, characterized in that After detecting whether the storage resource corresponding to any of the applications in the shared storage is available, the method further includes: If the storage resources of any of the applications in the shared storage are available, restart and repair any of the applications; When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
4. The method according to claim 1, characterized in that: After using the local storage, the method further includes: When the application state of any of the applications returns to normal, determining whether there are other applications among the multiple applications that use the shared storage; If so, when it is detected that the storage resource corresponding to the other application in the shared storage is unavailable, the storage address in the configuration file of the other application is switched from the third storage location in the shared storage to the corresponding fourth storage location in the local storage; When it is detected that the application status of the other application is abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
5. The method according to any one of claims 1 to 4, characterized in that: Determining that an application state of any of the applications is abnormal includes: When detecting that an application process of any of the applications exists, if it is determined that the application process is in a non-service state, then determining that an application state of any of the applications is abnormal; or When it is detected that the application process of any of the applications does not exist, it is determined whether any of the applications has a shutdown mark. If the shutdown mark does not exist, it is determined that the application state of any of the applications is abnormal; wherein the shutdown mark indicates that when the application process does not exist, the application state of any of the applications is normal.
6. The method according to any one of claims 1 to 4, characterized in that: The sequentially detecting the application status of at least one application in the active node includes: dividing the plurality of applications into a first application set that uses the shared storage and a second application set that does not use the shared storage; The application state of at least one first application in the first application set is detected in sequence, and when it is determined that the application state of at least one first application is normal, the application state of at least one second application in the second application set is detected in sequence.
7. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Backing up the storage resources in the shared storage to the local storage; The changed storage resources in the shared storage are detected in real time, and the detected changed storage resources are synchronized to the local storage.
8. A dual-machine hot standby device in a dual-machine cluster, characterized in that: The dual-machine cluster includes an active node and a standby node, and the device includes: A detection module, used to detect the application status of at least one application in the active node in sequence; A judgment module, used for detecting whether the storage resources corresponding to any of the applications in the shared storage are available when an application state of any of the applications is abnormal and any of the applications uses shared storage; wherein the shared storage is a storage commonly accessed by the active node and the standby node; A switching module, configured to switch the storage address in the configuration file of any of the applications from the first storage location in the shared storage to the corresponding second storage location in the local storage of the active node if the storage resources of any of the applications in the shared storage are unavailable; wherein the local storage is synchronized with the storage resources in the shared storage; A transfer module is used to close at least one of the applications in the active node and enable at least one corresponding application in the standby node if the application status of any of the applications is still abnormal after using the local storage.
9. The device according to claim 8, characterized in that The device also includes a first repair module, which is used to: When an application state of any of the applications is abnormal and any of the applications does not use the shared storage, restart and repair any of the applications; When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
10. The device according to claim 8, characterized in that The device also includes a second repair module, which is used to: If the storage resources of any of the applications in the shared storage are available, restart and repair any of the applications; When the restart repair fails, at least one of the applications in the active node is shut down, and at least one corresponding application in the standby node is enabled.
11. The device according to claim 8, characterized in that The device also includes a third repair module, which is used to: When the application state of any of the applications returns to normal, determining whether there are other applications among the multiple applications that use the shared storage; If so, when it is detected that the storage resource corresponding to the other application in the shared storage is unavailable, the storage address in the configuration file of the other application is switched from the third storage location in the shared storage to the corresponding fourth storage location in the local storage; When it is detected that the application status of the other application is abnormal, at least one of the applications in the active node is closed, and at least one corresponding application in the standby node is enabled.
12. The device according to any one of claims 8 to 11, characterized in that: The judging module is also used for: When detecting that an application process of any of the applications exists, if it is determined that the application process is in a non-service state, determining that an application state of any of the applications is abnormal; or When it is detected that the application process of any of the applications does not exist, it is determined whether any of the applications has a shutdown mark. If the shutdown mark does not exist, it is determined that the application state of any of the applications is abnormal; wherein the shutdown mark indicates that when the application process does not exist, the application state of any of the applications is normal.
13. The device according to any one of claims 8 to 11, characterized in that: The detection module is also used for: dividing the plurality of applications into a first application set that uses the shared storage and a second application set that does not use the shared storage; The application state of at least one first application in the first application set is detected in sequence, and when it is determined that the application state of at least one first application is normal, the application state of at least one second application in the second application set is detected in sequence.
14. The device according to any one of claims 8 to 11, characterized in that: The device also includes a synchronization module, which is used to: Backing up the storage resources in the shared storage to the local storage; The changed storage resources in the shared storage are detected in real time, and the detected changed storage resources are synchronized to the local storage.
15. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of claims 1-7 according to the obtained program instructions.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 7.
17. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Server cluster system and method for implementation of high availability of server cluster system
CN109194515A
System and method for controlling access to shared storage device
US20110179231A1