Method and system for HA switching
By establishing a dual-link heartbeat detection between the host and the standby machine and adopting an exponential backoff strategy, the problem of HA switching misjudgment risk in network abnormalities in the prior art is solved, which significantly improves the reliability of system failure detection and service switching, and reduces the occurrence of 'schizon' phenomenon.
Patent Information
- Application Number
- CN202411760404.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-04-08
AI Technical Summary
The existing redundant server HA module detection mechanism cannot accurately determine the node status when network abnormalities are not available, which poses a risk of misjudgment, resulting in a split brain phenomenon, which in turn causes data corruption and loss.
Establish two links between the host and the standby machine and pass heartbeat detection. If the standby machine does not receive the host's heartbeat response, adjust the preset interval time and try heartbeat detection again. Through the exponential backoff strategy, enhance the detection robustness and reduce the risk of misjudgment.
It significantly improves the reliability of system failure detection and service switching, reduces the risk of HA switching misjudgment in network abnormalities, reduces the occurrence of "split brain" phenomenon, and thus reduces the risk of data corruption and resource seizure.
Smart Images

Figure CN119788498A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of power grid dispatching automation redundant server HA, and relates to a method and system for HA switching. Background Art
[0002] The power grid dispatching automation system is the key to ensure the safe, stable and efficient operation of the power system. The system contains multiple functional modules, such as servers and workstations, and must have extremely high reliability and stability. To achieve this goal, HA (High Availability) cluster technology is widely used in redundant servers in the dispatching automation system to minimize service interruption time. HA cluster technology can respond quickly to hardware or software failures and reduce potential losses through automatic fault detection and service switching.
[0003] The existing redundant server HA module detection mechanism only relies on heartbeat information for detection. When the network is abnormal, the HA switching mechanism based on heartbeat information cannot accurately judge the node status when the heartbeat is lost, and there is a risk of misjudgment. If the standby machine does not receive the heartbeat signal from the host within the set time, the host is judged to be faulty, resulting in a "brain split" phenomenon, which in turn causes data corruption and loss.
[0004] Prior art document 1 (CN109495312A) discloses a method and system for implementing a high-availability cluster based on an arbitration disk and dual links, the method comprising: when an abnormality is detected in the first heartbeat network, determining the state of the second heartbeat network; when the second heartbeat network is determined to be abnormal based on the state of the second heartbeat network, determining the state of the storage network; wherein the storage network is a network corresponding to a storage server, and is used to characterize the state of a node server; and controlling the node server to perform master-slave switching based on the state of the storage network.
[0005] Prior art document 2 (CN111651291A) discloses a method, system, and computer storage medium for preventing brain split in a shared storage cluster. The present invention deploys a heartbeat detection module in the shared storage cluster node and an anti-brain split module in the shared storage device. The heartbeat detection module is used to detect the heartbeat fault server node in the shared storage cluster, and then determine whether the current main server node is faulty through the anti-brain split module. If the current main server node is faulty, it is promptly switched to the backup server node as the new main server node.
[0006] However, the existing technical file 1 and the existing technical file 2 may cause resource preemption, affecting the high availability of the cluster; and during the master-slave switching process, multi-point writing may occur, resulting in data inconsistency. Summary of the invention
[0007] In order to solve the deficiencies in the prior art, the present invention provides a method and system for HA switching, which can reduce the risk of misjudgment of HA switching when the network is abnormal in the prior art and reduce the brain split phenomenon.
[0008] The present invention adopts the following technical solution.
[0009] A first aspect of the present invention provides a method for HA switching, comprising the following contents:
[0010] Establish two links between the master and slave, and perform heartbeat detection on the two links respectively;
[0011] If the standby machine does not receive a heartbeat response from the host within the preset time, it adjusts the preset interval and tries the heartbeat detection again. When the heartbeat detection fails continuously for a preset number of times and the last detection interval reaches the preset upper limit, the host is judged to be unavailable.
[0012] When the host status is determined to be unavailable on both links, the standby server is switched and the standby server starts the HA service.
[0013] Optionally, the preset interval time is determined in real time according to the number of retries.
[0014] Optionally, the preset interval time is adjusted according to network delay and / or host load data.
[0015] Optionally, when the network delay increases beyond a preset delay threshold and / or the host load data exceeds a preset load threshold, the preset interval time is increased.
[0016] Optionally, starting the HA service includes taking over the shared storage resources. Before the standby machine starts the HA service to take over the shared storage resources, the method further includes:
[0017] Monitor whether the host has mounted shared storage resources, and determine whether to take over the shared storage resources based on the monitoring results.
[0018] Optionally, the shared storage resource includes a VIP resource and a disk resource. Monitoring whether the host mounts the shared storage resource and determining whether to take over the shared storage resource according to the monitoring result include:
[0019] Monitor whether the host has mounted VIP resources;
[0020] If the monitoring result shows that the host has mounted the VIP resource, the backup machine will not take over the VIP resource actively;
[0021] If the monitoring result shows that the host has not mounted the VIP resource, the standby machine mounts the VIP resource and detects whether the mounting is successful. If unsuccessful, the standby machine does not actively take over the VIP resource. If successful, the disk resource is detected and it is determined whether to mount and take over the disk resource based on the detection result.
[0022] Optionally, detecting the disk resource and determining whether to mount the disk resource according to the detection result includes:
[0023] Check whether the disk resource is mounted;
[0024] If the detection result is not mounted, the standby machine mounts the disk resource; otherwise, check the connectivity between the heartbeat address and the business address;
[0025] When the standby machine is connected to the heartbeat address or business address, determine whether the host machine has mounted disk resources. If not, the standby machine mounts the disk resources. Otherwise, check whether the host HA service is online.
[0026] If the host HA service is not online, stop the host HA service, uninstall the disk resources and VIP resources, and mount the resources on the standby machine; if the host HA service is online, stop the standby HA service and start it;
[0027] When the standby machine is disconnected from the heartbeat address or business address, the standby machine mounts the disk resources.
[0028] Optionally, the method further comprises:
[0029] The host or the standby machine performs a write operation on the shared storage resource based on a preset write mechanism, where the preset write mechanism is that one host or one standby machine performs a write operation on the shared storage resource at a time.
[0030] Optionally, the preset writing mechanism includes a serialized writing mechanism, and the serialized writing mechanism is that the master or backup machine with the smallest serial number has the writing permission.
[0031] A second aspect of the present invention provides a system for HA switching, the system comprising:
[0032] Establish a link and heartbeat detection module, which is used to establish two links between the master and the backup machine, and perform heartbeat detection on the two links respectively;
[0033] A judgment module is used to adjust the preset interval time and retry the heartbeat detection if the standby machine does not receive the heartbeat response sent by the host within the preset time. If the heartbeat detection fails continuously for a preset number of times and the last detection interval time reaches a preset upper limit, the host state is judged to be unavailable;
[0034] The switching module is used to switch the standby machine when the host state is judged to be unavailable on both links, and the standby machine starts the HA service.
[0035] Optionally, the system further includes: a monitoring module, configured to monitor whether the host mounts the shared storage resource, and determine whether to take over the shared storage resource according to the monitoring result.
[0036] Optionally, the system further includes: a write operation control module, which is used for the host or the backup machine to perform a write operation on the shared storage resource based on a preset write mechanism, and the preset write mechanism is that one host or one backup machine performs a write operation on the shared storage resource at a time.
[0037] A third aspect of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned method for HA switching when loaded into the processor.
[0038] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for HA switching is implemented.
[0039] Compared with the prior art, the beneficial effects of the present invention include at least:
[0040] 1. The present invention enhances the robustness of detection through the dual-link and exponential backoff strategy of heartbeat monitoring, reduces the risk of HA switching misjudgment when the network is abnormal, and can significantly improve the reliability of system fault detection and service switching.
[0041] 2. The present invention realizes real-time and accurate grasp of cluster status through status monitoring mechanism, resource detection and management, including detection and management of VIP resources and disk resources, to prevent the occurrence of brain split caused by incorrect resource startup, thereby reducing the risk of data damage caused by network anomalies or operations, and reducing the occurrence of resource preemption.
[0042] 3. The present invention can effectively prevent the risk of simultaneous writing at multiple points through the serialization mechanism of write control in the storage layer, improve data integrity, improve the stability of key service operation in the scheduling automation system, and reduce operation and maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0044] Figure 1 It is a schematic diagram of an implementation environment of a method for HA switching provided by an embodiment of the present invention;
[0045] Figure 2 is a flow chart of a method for HA switching provided by an embodiment of the present invention;
[0046] Figure 3 It is a schematic diagram of dual-link heartbeat detection provided by an embodiment of the present invention;
[0047] Figure 4 It is a schematic diagram of VIP resources and heartbeat information provided by an embodiment of the present invention;
[0048] Figure 5 It is a schematic diagram of a VIP resource detection process provided by an embodiment of the present invention;
[0049] Figure 6 It is a schematic diagram of a disk resource detection and management flow chart provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The embodiments described in this application are only part of the embodiments of the present invention, not all of them. Based on the spirit of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the scope of protection of the present invention.
[0051] The embodiments of the present invention are applied to Figure 1 The system environment shown. Combined with Figure 1 As shown, the database cluster runs in HA master-slave mode, and the servers determine each other's status through heartbeat information. The heartbeat information is transmitted over the network, and the servers are connected to the FC-SAN (Fiber Channel-Storage Area Network) storage network and the disk array through optical fiber.
[0052] The system includes a primary server and a backup server (hereinafter referred to as the host and backup). The primary server handles all business requests, and the backup server is on standby and does not handle actual business loads. Both the primary and backup servers are usually connected to shared storage devices, which can share data and ensure data consistency, but at any given time, shared storage can usually only be mounted by one server. During the primary-backup switching process, the backup server takes over the shared storage resources to ensure that it can access and run the data required by the business system. The backup server regularly checks the health status of the primary server. Once a failure of the primary server is detected, the backup server will automatically take over the work of the primary server and become the new primary server.
[0053] "Split brain" refers to a distributed system in which the system is split into two or more independent parts due to network problems or other reasons. Each part mistakenly believes that it is the only active part of the system, causing multiple nodes to take over shared resources at the same time, causing data conflicts and corruption.
[0054] Combination Figure 2 As shown, Embodiment 1 of the present invention provides a method for HA switching, including the following contents:
[0055] S1. Establish two links between the master and the slave, and perform heartbeat detection on the two links respectively.
[0056] S2. If the standby machine does not receive a heartbeat response from the host within a preset time, it adjusts the preset interval time and retries the heartbeat detection. When the heartbeat detection fails continuously for a preset number of times and the last detection interval time reaches a preset upper limit, the host status is determined to be unavailable.
[0057] Optionally, the preset interval time is determined in real time according to the number of retries.
[0058] For example, the preset interval time is equal to twice the previous preset interval time, and the preset upper limit value is equal to 8 times the first preset interval time.
[0059] Combination Figure 3 As shown, a fixed time interval t0 for sending heartbeats and a heartbeat monitoring timeout period T are set. If a response is received, normal operation continues; if no heartbeat response is received within T, a retry is performed according to the exponential backoff strategy. The specific implementation steps are as follows:
[0060] When the first heartbeat fails, retry once immediately; if it fails continuously, implement an exponential backoff strategy. After each failure, the retry interval increases to twice the previous one, that is, according to t0, 2t0, 4t0... In combination with the performance of the device and the changes in the system load, set the maximum number of retries to 3 to 5 times, stop retrying after exceeding the number of retries, and set the upper limit of the retry interval to avoid too long a retry interval. If the heartbeat detection is successful, reset the retry interval to the initial value. If the heartbeat detection fails continuously for the maximum number of times set, and the last detection interval reaches the upper limit, the host status is determined to be unavailable.
[0061] According to statistics, "brain split" in HA clusters is mostly caused by the interruption of heartbeat links, which leads to misjudgment of node heartbeat information. This embodiment uses dual-link heartbeat detection. Even if one link fails, the other link can still ensure the transmission of heartbeat information, thereby enhancing the robustness of heartbeat detection. By dynamically adjusting the retry interval, the reliability of heartbeat monitoring can be improved, thereby reducing false switching caused by network fluctuations, thereby reducing the occurrence of brain split phenomenon, and further improving the reliability and robustness of HA switching.
[0062] Optionally, the preset interval time is adjusted according to network delay and / or host load data.
[0063] Specifically, set up cron tasks to regularly collect network delay and host load data, detect network delay through ping test, and obtain CPU usage through top command. Set thresholds for network delay and host load, and trigger adjustments to the heartbeat interval and timeout when the thresholds are exceeded. For example, when network delay increases or host load exceeds 90%, increase the heartbeat interval to 2t0 and reduce the timeout.
[0064] S3. When the host status is determined to be unavailable on both links, the standby machine is switched and the standby machine starts the HA service.
[0065] Combination Figure 5 As shown, starting the HA service includes taking over the shared storage resources. Before the standby machine starts the HA service to take over the shared storage resources, the method further includes:
[0066] S4: Monitor whether the host has mounted shared storage resources, and determine whether to take over the shared storage resources based on the monitoring results. Shared storage resources include VIP resources and disk resources. S4 includes:
[0067] S41. Monitor whether the host has mounted VIP resources. If the monitoring result shows that the host has mounted VIP resources, the standby machine does not actively take over the VIP resources. If the monitoring result shows that the host has not mounted VIP resources, the standby machine mounts the VIP resources and checks whether the mounting is successful. If not, the standby machine does not actively take over the VIP resources. If successful, proceed to S42.
[0068] Specifically, the HA service startup process includes operations such as mounting related resources and starting database services. When VIP (Virtual IP Adress) resources or disk resources fail to mount, the database service cannot perform data read and write operations. In the existing switching mechanism, there is a lack of detection and management of the mounting status of VIP resources and disk resources. After the heartbeat information is lost, the nodes in the cluster all think that they are the master node and mount resources such as disks at the same time, resulting in a brain split. Therefore, by increasing the detection and management of VIP resources and disk resources, the "brain split" phenomenon caused by multiple nodes mounting resources at the same time when the network is abnormal or the host fails can be avoided, ensuring resource consistency and system stability.
[0069] VIP is an IP address that is not directly associated with any physical hardware interface. When a host fails, the IP address and related services are automatically transferred to the backup machine, and the client accesses the service through the same IP address, thus ensuring the continuity of the service. VIP is a key technology for achieving HA high availability.
[0070] VIP resources and heartbeat information diagram as follows Figure 4 As shown in the figure, eth0 is a service port that provides data and other services to users through VIP service resources; eth1 is a heartbeat network port that transmits heartbeat information. In the existing HA management mechanism, VIP resource detection is not performed when the HA service is started. When a "brain split" occurs, the redundant servers may mount VIP resources at the same time.
[0071] The present invention prevents redundant servers from mounting VIP resources at the same time by increasing the management of VIP resources. When the standby machine starts the HA process and attempts to mount the VIP resources, it first detects whether the VIP resources exist through the ping command. If the standby machine detects that the VIP business resources exist, it will not take over the VIP resources actively. This prevents the standby machine from misjudging the host failure and performing unnecessary master-slave switching when the host has a heartbeat network anomaly.
[0072] S42: Detect the disk resources and determine whether to take over the disk resources based on the detection results.
[0073] Combination Figure 6 As shown, S42 specifically includes:
[0074] S421, determine whether the disk resource is mounted, if the determination result is that it is not mounted, the standby machine mounts the disk resource, otherwise execute S422.
[0075] Specifically, by checking the mount flag (needs_recovery) mapped from the disk array to the file system, it is determined whether the disk resource has been mounted. If the disk is not mounted, HA will mount the disk. If the disk has been mounted, further judgment is required because the mount flag has not been refreshed after the fiber link is disconnected.
[0076] S422, check the connectivity of the heartbeat address and the business address. When the standby machine is connected to the heartbeat address or the business address, determine whether the host machine mounts the disk resource. If not, the standby machine mounts the disk resource. If so, execute S423.
[0077] S423, check whether the host HA service is online. If not, stop the host HA service, uninstall the host disk resources and VIP resources, and mount the disk resources on the standby machine. If it is online, stop the HA service startup on the standby machine.
[0078] Specifically, check the connectivity of the heartbeat address and the business address, log in to the host through the SSH link to query the actual mounting status of the disk (that is, the mount status of the disk), check whether the host HA process is online, and determine whether the disk is manually mounted.
[0079] If the host HA process is online and the business is running normally, the standby HA will actively stop resource takeover and terminate the HA service startup of the standby; if the host HA process is not online, the standby HA will actively unload the host's disk resources. After successful unloading, remount the resources on the standby. If it cannot be unloaded normally, the resources will not be mounted.
[0080] S424: When the standby machine is disconnected from the heartbeat address or the business address, the standby machine mounts the disk resources.
[0081] Specifically, when the heartbeat address and business address are both unreachable, the disk mount status can be detected through the disk array fiber link, but the actual mount status of the disk cannot be queried through the SSH link to log in to the host, and the disk resources are not taken over by default. Set the configuration item standalone yes / no, and the user can define whether to allow the disk resource to be mounted in abnormal situations, and strike a balance between high availability and security.
[0082] The present invention prevents redundant servers from mounting disk resources and writing data at the same time, thereby damaging the database, by increasing disk resource detection and management.
[0083] Optionally, the method further comprises:
[0084] S5. The host or the standby machine performs a write operation on the shared storage resource based on a write mechanism, wherein the write mechanism is that one host or one standby machine performs a write operation on the shared storage resource at a time.
[0085] Optionally, the writing mechanism includes a serialized writing mechanism, wherein the serialized writing mechanism allows a node with a minimum serial number to have writing permission.
[0086] The existing storage layer's strategy for preventing multiple nodes from writing at the same time is implemented by listening to the port when the database is started. When the database is started, if the port at the configured address is checked to be in the listening state, it is considered that the database is being used and the currently started database is terminated. This mechanism relies on network connections to check whether other nodes are using the database. When the network connection is interrupted, this check cannot be performed, and thus the occurrence of double writing cannot be prevented.
[0087] This embodiment implements anti-multi-node simultaneous writing in the storage layer through a serialized write mechanism. At any time, only one node can write to the shared storage. When a node wants to write data, it needs to obtain write permission, which is implemented in the form of a lock. Other nodes that want to write must wait for the lock to be released. The specific implementation principle is as follows: When a node needs to obtain a lock, a temporary sequential node is created, which contains a globally unique serial number. The node with the smallest serial number obtains the lock and can write to the shared storage. If the sequential node created by the node is not the smallest, it will register a listener on a node with a serial number that is 1 less than its own and wait. When the node holding the lock completes the write operation, it deletes its own sequential node, releases the lock and notifies the waiting node, which rechecks and tries to obtain the lock. The cycle continues in sequence. When an exception such as a node crash occurs, causing the session to time out, the temporary node is automatically deleted and the lock is released.
[0088] The above process enables nodes in the HA cluster to access shared storage resources (usually disk arrays) synchronously, preventing multiple nodes from writing damaged database files at the same time.
[0089] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0090] Embodiment 2 of the present invention provides a system for HA switching, which runs the method for HA switching as described in Embodiment 1, and the system includes: a link establishment and heartbeat detection module, a judgment module and a switching module. Among them, the link establishment and heartbeat detection module is used to establish two links between the host and the standby machine, and perform heartbeat detection on the two links respectively. The judgment module is used to adjust the preset interval time to retry the heartbeat detection if the standby machine does not receive the heartbeat response sent by the host within the preset time, and judge the host state as unavailable when the heartbeat detection fails continuously for a preset number of times and the last detection interval time reaches the preset upper limit value. The switching module is used to switch the standby machine when the host state is judged to be unavailable on both links, and the standby machine starts the HA service.
[0091] Optionally, the system further includes: a monitoring module, configured to monitor whether the host mounts the shared storage resource, and determine whether to take over the shared storage resource according to the monitoring result.
[0092] Optionally, the system further includes: a write operation control module, which is used for the host or the backup machine to perform a write operation on the shared storage resource based on a preset write mechanism, and the preset write mechanism is that one host or one backup machine performs a write operation on the shared storage resource at a time.
[0093] Embodiment 3 of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method for HA switching described in embodiment 1 when loaded into the processor.
[0094] Embodiment 4 of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for HA switching according to embodiment 1 is implemented.
[0095] Embodiment 5 of the present invention provides a verification embodiment of a method for HA switching.
[0096] The historical server database cluster of the scheduling automation laboratory adopts the active-standby HA operation mode. The specific configuration is shown in Table 1.
[0097] Table 1
[0098] name HNCS-HIS1 HNCS-HIS2 Memory 256G 16 cores CPU 256G 16 cores harddisk 4TB 4TB Database version V7.6.0.161 V7.6.0.161 Operating system version Kylin 3.2 Kylin 3.2
[0099] The disk array uses the MS3000G2-AF-24D of Hongshan Technology, with a memory of 16T. Before the test, the two historical servers were running normally, hncs-his1 was the host, and hncs-his2 was the backup (hereinafter referred to as his1 and his2). Check the running status of the HA service, VIP and disk resources are mounted on his1, and the database service runs on his1. To ensure that the test will not cause damage to the database, back up the database file and replace the database service file.
[0100] Based on the existing HA, a failover test is carried out. The resource mounting and HA status under various abnormal conditions are shown in Table 2.
[0101] Table 2
[0102]
[0103] Through testing, it was found that when the firewall of the existing HA is turned on and the heartbeat line / business line / disk array link is disconnected, the redundant servers cannot detect each other's status, the servers mount VIP resources or disk resources at the same time, the database services are started at the same time, and both servers in HA are in the host state, there is a risk of damaging the database files; when the disk array is manually mounted, the mounting status of the disk resources cannot be detected, and the servers mount the disk resources at the same time.
[0104] The method for HA switching provided in Example 1 of the present invention was used for testing, and the test results are shown in Table 3.
[0105] Table 3
[0106]
[0107] By comparing the test records in Table 2 and Table 3, it can be seen that in the five abnormal situations 1 to 5, the node status in HA can be effectively monitored, and the VIP resources and disk resources are not mounted at the same time, and the database service is not started at the same time.
[0108] The test results show that redundant servers can effectively monitor node status and ensure reliable switching of resources, thus improving the stability and reliability of the system.
[0109] Embodiment 1, 2, 3, or 4 of the present invention is deployed in the WAMS (Web Application Management System) history server of the Provincial Dispatching Area III. After testing and actual operation, it is found that the improvement measures not only optimize the heartbeat monitoring, but also have the functions of resource detection and management, reducing the risk of false switching. At the same time, the serialized write mechanism of the storage layer improves the security and reliability of the database, ensuring the stable operation of key services in the system.
[0110] Compared with the prior art, the beneficial effects of the present invention include at least:
[0111] 1. The present invention enhances the robustness of detection through the dual-link and exponential backoff strategy of heartbeat monitoring, reduces the risk of HA switching misjudgment when the network is abnormal, and can significantly improve the reliability of system fault detection and service switching.
[0112] 2. The present invention realizes real-time and accurate grasp of cluster status through status monitoring mechanism, resource detection and management, including detection and management of VIP resources and disk resources, to prevent the occurrence of brain split caused by incorrect resource startup, thereby reducing the risk of data damage caused by network anomalies or operations, and reducing the occurrence of resource preemption.
[0113] 3. The present invention can effectively prevent the risk of simultaneous writing at multiple points through the serialization mechanism of write control in the storage layer, improve data integrity, improve the stability of key service operation in the scheduling automation system, and reduce operation and maintenance costs.
[0114] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0115] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0116] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0117] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for HA switching, characterized in that: Includes the following: Establish two links between the master and slave, and perform heartbeat detection on the two links respectively; If the standby machine does not receive a heartbeat response from the host within the preset time, it adjusts the preset interval and tries the heartbeat detection again. When the heartbeat detection fails continuously for a preset number of times and the last detection interval reaches the preset upper limit, the host is judged to be unavailable. When the host status is determined to be unavailable on both links, the standby server is switched and the standby server starts the HA service.
2. The method for HA switching according to claim 1, characterized in that: The preset interval time is determined in real time based on the number of retries.
3. The method for HA switching according to claim 2, characterized in that: The preset interval is adjusted based on network latency and / or host load data.
4. The method for HA switching according to claim 3, characterized in that: When the network delay increases beyond a preset delay threshold and / or the host load data exceeds a preset load threshold, the preset interval time is increased.
5. The method for HA switching according to any one of claims 1 to 4, characterized in that: Starting the HA service includes taking over the shared storage resources. Before the standby machine starts the HA service to take over the shared storage resources, the method further includes: Monitor whether the host has mounted shared storage resources, and determine whether to take over the shared storage resources based on the monitoring results.
6. The method for HA switching according to claim 5, characterized in that: Shared storage resources include VIP resources and disk resources. Monitoring is performed to determine whether the host has mounted shared storage resources. The following are used to determine whether to take over shared storage resources based on the monitoring results: Monitor whether the host has mounted VIP resources; If the monitoring result shows that the host has mounted the VIP resource, the backup machine will not take over the VIP resource actively; If the monitoring result shows that the host has not mounted the VIP resource, the standby machine mounts the VIP resource and detects whether the mounting is successful. If unsuccessful, the standby machine does not actively take over the VIP resource. If successful, the disk resource is detected and it is determined whether to mount and take over the disk resource based on the detection result.
7. The method for HA switching according to claim 6, characterized in that: Detect disk resources and determine whether to mount and take over disk resources based on the monitoring results, including: Check whether the disk resource is mounted; If the detection result is not mounted, the standby machine mounts the disk resource; otherwise, check the connectivity between the heartbeat address and the business address; When the standby machine is connected to the heartbeat address or business address, determine whether the host machine has mounted disk resources. If not, the standby machine mounts the disk resources. Otherwise, check whether the host HA service is online. If the host HA service is not online, stop the host HA service, uninstall the disk resources and VIP resources, and mount the resources on the standby machine; if the host HA service is online, stop the standby HA service and start it; When the standby machine is disconnected from the heartbeat address or business address, the standby machine mounts the disk resources.
8. The method for HA switching according to any one of claims 1 to 4, characterized in that: The method further comprises: The host or the standby machine performs a write operation on the shared storage resource based on a preset write mechanism, where the preset write mechanism is that one host or one standby machine performs a write operation on the shared storage resource at a time.
9. The method for HA switching according to claim 8, characterized in that: The preset writing mechanism includes a serialized writing mechanism, wherein the master or backup machine having the smallest serial number has the writing permission.
10. A system for HA switching using the method for HA switching according to any one of claims 1 to 9, characterized in that: The system comprises: Establish a link and heartbeat detection module, which is used to establish two links between the master and the backup machine, and perform heartbeat detection on the two links respectively; A judgment module is used to adjust the preset interval time to retry the heartbeat detection if the standby machine does not receive the heartbeat response sent by the host within the preset time, and judge the host status as unavailable when the heartbeat detection fails continuously for a preset number of times and the last detection interval reaches a preset upper limit; The switching module is used to switch the standby machine when the host state is judged to be unavailable on both links, and the standby machine starts the HA service.
11. The system for HA switching according to claim 10, characterized in that: The system further comprises: The monitoring module is used to monitor whether the host mounts the shared storage resources and determine whether to take over the shared storage resources based on the monitoring results.
12. The system for HA switching according to claim 11, characterized in that: The system further comprises: The write operation control module is used for the host or the standby machine to perform a write operation on the shared storage resource based on a preset write mechanism. The preset write mechanism is that one host or one standby machine performs a write operation on the shared storage resource at a time.
13. An electronic device, comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is configured to operate according to the instruction to execute the steps of the method for HA switching according to any one of claims 1-9.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for HA switching according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Method and system for implementing high availability cluster based on quorum disk and dual link
CN109495312A
Method and system for preventing split brain of shared storage cluster and computer storage medium
CN111651291A