[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN117240694A - Method, device and system for switching active and standby hot standby based on keepaled - Google Patents

Method, device and system for switching active and standby hot standby based on keepaled Download PDF

Info

Publication number
CN117240694A
CN117240694A CN202311446833.6A CN202311446833A CN117240694A CN 117240694 A CN117240694 A CN 117240694A CN 202311446833 A CN202311446833 A CN 202311446833A CN 117240694 A CN117240694 A CN 117240694A
Authority
CN
China
Prior art keywords
node
dual
hot standby
server cluster
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311446833.6A
Other languages
Chinese (zh)
Inventor
田子涛
严洪力
张常华
余吉昌
李明杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Baolun Electronics Co ltd
Original Assignee
Guangdong Baolun Electronics Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Baolun Electronics Co ltd filed Critical Guangdong Baolun Electronics Co ltd
Priority to CN202311446833.6A priority Critical patent/CN117240694A/en
Publication of CN117240694A publication Critical patent/CN117240694A/en
Pending legal-status Critical Current

Links

Landscapes

  • Hardware Redundancy (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The application discloses a method, a device and a system for switching a dual-machine hot standby master and slave based on keepalive, wherein the method comprises the following steps: according to the vrrp protocol, determining a first node with the highest priority in the server cluster as a master node, so that the first node starts vip; controlling a main node at each moment in a server cluster to be in a non-preemptive state through each keepalive dual-machine hot standby component; when the first node fails, the priority of the first node is reduced, and a second node with the highest priority is determined to be a main node according to a vrrp protocol, so that vip drifts to the second node; and when the second node fails, the priority of the second node is reduced, the second node is enabled to close vip, and a third node with the highest priority is determined to be a main node according to the vrrp protocol, so that vip drifts to the third node. The application provides a method, a device and a system for switching a dual-machine hot standby master and a dual-machine hot standby based on keepalive, which solve the problem of low utilization rate of nodes when the master and standby are switched for a plurality of times by improving or reducing the priority of the nodes.

Description

Method, device and system for switching active and standby hot standby based on keepaled
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method, an apparatus, and a system for dual-standby active/standby switching based on keepalive.
Background
In the current market, for the dual-machine hot standby condition, particularly in the lightweight dual-machine hot standby project requirement, keepalive is mainly used for realizing main standby switching, ensuring normal access of applications, and compared with projects such as heatbean, the keepalive dual-machine hot standby component is favored by virtue of the lightweight dual-machine hot standby component. The keep dual-machine hot standby component mainly realizes the main standby switching through two mechanisms of a vrrp protocol and a health status checker. The prior art lacks logic for automatically recovering or improving the priority of the nodes, so that when the primary and secondary switching is performed for a plurality of times, for the nodes which have failed and are recovered, the primary and secondary switching work is exited, so that the utilization rate of the nodes is low, resources cannot be reasonably managed and controlled, and resource waste is caused.
Disclosure of Invention
The application provides a method, a device and a system for switching a dual-machine hot standby main and standby based on keepalive, which are used for solving the problem that the utilization rate of nodes is low when the main and standby are switched for a plurality of times in the prior art.
In order to solve the above problems, the present application provides a method for switching between a dual hot standby mode and a main standby mode based on keepalive, comprising:
according to a vrrp protocol, determining a first node with highest priority in a server cluster as a master node, so that the first node starts vip; each server in the server cluster is provided with a keep-alive dual-machine hot standby component, and each keep-alive dual-machine hot standby component correspondingly controls one node;
controlling a main node at each moment in the server cluster to be in a non-preemptive state through each keep-alive dual-machine hot standby component;
when the first node fails, the priority of the first node is reduced through the keep alive dual-machine hot standby component, and a second node with the highest priority in the server cluster is determined to be a main node according to the vrrp protocol, so that the vip drifts to the second node;
and when the second node fails, reducing the priority of the second node through the keep dual hot standby component, enabling the second node to close the vip, and determining a third node with the highest priority in the server cluster as a main node according to the vrrp protocol so as to enable the vip to drift to the third node.
According to the application, the main node is in a non-preemptive state, so that resources such as vip of other main nodes can be prevented from being preempted after the main node becomes a standby node; when a first node or a second node serving as a main node fails, the priority of the node is reduced to enable the node to give up resources such as vip and the like, and the main node is redetermined according to the priority based on reassignment logic, so that equal use opportunities of all standby nodes at the moment are given, including re-use opportunities of the nodes with reduced priority are given, and each server can perform more frequent main-standby switching; when the second node fails, the priority of the second node needs to be reduced and then the main node is determined again, but the first node is still in a non-preemptive state because the main node is made at this time, so that by closing vip of the second node, an allocation mechanism under the vrrp protocol can be triggered, the first node also has the opportunity of competing for the main node equally, the main node falls onto the node with high priority again, and the utilization rate of the node is improved. Compared with the prior art, the method and the device have the advantages that the priority of the nodes is improved or reduced through the logic of node multiplexing, and the opportunity of equally competing master nodes is given to all the standby nodes, so that the problem of low utilization rate of the nodes when the master-standby switching is performed for many times can be solved.
Preferably, after determining the second node with the highest priority in the server cluster as the master node, so that the vip drifts to the second node, the method further includes:
and when the second node is the main node, if the first node is determined to be detected by a health check mechanism, increasing the priority of the first node, so that the first node is restored to the original priority.
According to the preferred scheme, the first node is detected through the health checking mechanism to judge whether the first node eliminates the fault or not, so that the first node is restored to the original priority, the first node which has exited the dual-computer hot standby operation can be added to the alternative row of the main node again, and further efficient recycling of the server node is realized.
Preferably, determining a third node with the highest priority in the server cluster as a master node, so that the vip automatically drifts to the third node, specifically:
if the first node is determined to be restored to the original priority, determining the first node with the highest priority in the server cluster as a main node according to the vrrp protocol, so that the vip automatically drifts to the first node;
if the first node is determined not to be restored to the original priority, the third node with the highest priority in the server cluster is re-determined as a main node according to the vrrp protocol, so that the vip automatically drifts to the third node; and when the priorities of the nodes in the server cluster are compared again, if a plurality of nodes with the same highest priority are determined to appear, the ip addresses of the nodes are compared, and a third node with the largest ip address is used as a main node.
The preferred scheme aims at the situation that the main node needs to be redetermined when the main node fails for the second time. Since the failed master node is the second node at this time, when the master node is redetermined, two cases are considered, one is that the first node has recovered the working capacity, and since the priority of the first node after recovering the priority is in the highest state in the server cluster, the first node is redetermined as the master node; the other is that the first node does not restore the working capacity, and the third node with the highest priority in the server cluster needs to be determined again as the master node, so that the first node can be reused by fully considering different conditions, and the utilization rate of the nodes is improved.
As a preferred solution, according to the vrrp protocol, the second node with the highest priority in the server cluster is determined as the master node, which specifically includes:
comparing the priority of each node in the server cluster according to the vrrp protocol, and taking a second node with the highest priority in the server cluster as a master node;
and when comparing the priorities of the nodes in the server cluster, if a plurality of nodes with the same highest priority appear, comparing the ip addresses of the nodes, and taking the second node with the largest ip address as a main node.
According to the optimal scheme, the problem that when a plurality of nodes with the same highest priority appear, the master node is difficult to select is solved by comparing the sizes of the ip addresses, the phenomenon of blocking in the process of selecting the nodes with the highest priority is prevented, and the selecting process is smoothly carried out.
Preferably, before determining, according to the vrrp protocol, a first node with the highest priority in the server cluster as a master node, so that the first node starts vip, the method further includes:
deploying the keep dual hot standby components in two or more server clusters, and closing iptables service and selinux service of each server in the server clusters; the time of each node in each keepalive dual-machine hot standby component is kept synchronous, and mutual communication is carried out between the nodes through the host names of the servers in a key authentication mode;
checking and confirming that each node can normally use a preset broadcast heartbeat packet, and enabling a keep dual-machine hot standby component of each server in the server cluster to normally operate; and setting the startup self-starting of each keep-alive dual-machine hot standby component, and restarting each server.
According to the method and the device, the setting in each server is adjusted by deploying the keep-alive dual-machine hot standby component in the server cluster, so that the keep-alive dual-machine hot standby component can be guaranteed to normally run in each server, and preparation work is made for subsequent main and standby node switching.
As a preferred solution, checking and confirming that each node can normally use a preset broadcast heartbeat packet, specifically:
and switching each node to become a master node in turn, and when each node becomes the master node in turn, removing nodes which cannot transmit and receive the broadcast heartbeat packet in each node by checking the/etc/log/syslog log file of the current master node.
According to the preferred scheme, whether each node can normally use the broadcast heartbeat packet or not is determined by enabling each node to be a master node, the broadcast heartbeat packet can be used for detecting whether connection is normal or not, various network faults can be avoided, stability and reliability of network communication are guaranteed, and the nodes which cannot send and receive the broadcast heartbeat packet in each node are removed, so that normal operation of each node can be guaranteed.
The application also provides a double-machine hot standby main-standby switching device based on the high-availability component, which comprises the following components: the device comprises a debugging module, a control module, a first switching module and a second switching module;
the debugging module is used for determining a first node with highest priority in the server cluster as a main node according to a vrrp protocol so as to enable the first node to start vip; each server in the server cluster is provided with a keep-alive dual-machine hot standby component, and each keep-alive dual-machine hot standby component correspondingly controls one node;
the control module is used for controlling the master node at each moment in the server cluster to be in a non-preemptive state through each keep-alive dual-machine hot standby component;
the first switching module is configured to reduce, when the first node fails, the priority of the first node through the keep dual hot standby component, and determine, according to the vrrp protocol, a second node with a highest priority in the server cluster as a master node, so that the vip drifts to the second node;
and the second switching module is used for reducing the priority of the second node through the keep dual-machine hot standby component when the second node fails, enabling the second node to close the vip, and determining a third node with the highest priority in the server cluster as a main node according to the vrrp protocol so as to enable the vip to drift to the third node.
Preferably, the debug module further includes:
the first adjusting unit is used for deploying the keep dual-engine hot standby component in two or more server clusters and closing the iptables service and the selinux service of each server in the server clusters; the time of each node in each keepalive dual-machine hot standby component is kept synchronous, and mutual communication is carried out between the nodes through the host names of the servers in a key authentication mode;
the method is also used for checking and confirming that each node can normally use a preset broadcast heartbeat packet, and the keep dual-machine hot standby component of each server in the server cluster can normally operate; setting the startup self-starting of each keep-alive dual-machine hot standby component, and restarting each server;
and the second adjusting unit is used for switching each node to be a master node in turn, and when each node is a master node in turn, deleting the nodes which cannot transmit and receive the broadcast heartbeat packet in each node by checking the per-etc/log/syslog log file of the current master node.
Preferably, the first switching module further includes:
the first determining unit of the master node is used for comparing the priority of each node in the server cluster according to the vrrp protocol, and taking the second node with the highest priority in the server cluster as the master node;
the server cluster is also used for comparing the priorities of the nodes in the server cluster, if a plurality of nodes with the same highest priority are determined to appear, the ip addresses of the nodes are compared, and a second node with the largest ip address is used as a main node;
and the node first recovery unit is used for increasing the priority of the first node if the first node is determined to be detected by the health check mechanism when the second node is the master node, so that the first node is recovered to the original priority.
As a preferred solution, the second switching module specifically includes:
if the first node is determined to be restored to the original priority, determining the first node with the highest priority in the server cluster as a main node according to the vrrp protocol, so that the vip automatically drifts to the first node;
if the first node is determined not to be restored to the original priority, the third node with the highest priority in the server cluster is re-determined as a main node according to the vrrp protocol, so that the vip automatically drifts to the third node; and when the priorities of the nodes in the server cluster are compared again, if a plurality of nodes with the same highest priority are determined to appear, the ip addresses of the nodes are compared, and a third node with the largest ip address is used as a main node.
The application also provides a dual-machine hot standby main and standby switching system based on keepalive, which comprises the following steps: switching device, server cluster device and computer hardware structure device;
the computer hardware structure device controls the switching device, and executes the dual-machine hot standby master-slave switching method based on keepalive on the server cluster device.
Drawings
Fig. 1 is a schematic flow chart of a dual-machine hot standby master-slave switching method based on keepalive provided by the embodiment of the application;
fig. 2 is a flowchart of a dual-hot-standby active-standby switching process based on keepalive provided by an embodiment of the present application;
fig. 3 is a schematic structural diagram of a dual-hot standby master-slave switching device based on keepalive according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a dual-hot-standby master-slave switching system based on keepalive according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the description of the present application, it should be understood that the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", or a third "may explicitly or implicitly include one or more such feature. In the description of the application, unless otherwise indicated, the meaning of "a number" is two or more.
The foregoing is a preferred embodiment of the present application and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present application and are intended to be comprehended within the scope of the present application.
Referring to fig. 1, an embodiment of the present application provides a keep-based dual hot standby active/standby switching method, which includes steps S1 to S4, and further includes steps S10, S10 and S1 to S4 before step S1, specifically as follows:
s10, preprocessing the server cluster.
In the embodiment of the present application, S10 includes: S0.1-S0.5:
s0.1, deploying keep dual hot standby components in two or more server clusters, and closing iptables service and selinux service of each server in the server clusters; and using a network time server to keep the time of each node in each keep-alive dual-machine hot standby component synchronous.
S0.2, performing mutual communication between nodes through host names of the servers in a key authentication mode; the name setting of the node is consistent with the resolved hostnames in the hosts file (i.e. the hostnames are obtained by using the AIS framework essential item and using the uname-n, and the obtained hostnames are the same as the resolved hostnames).
S0.3, checking and confirming that the primary server and the standby server can communicate, for example, using a ping command to link the standby node at the primary node to test whether the primary node can be connected;
checking and confirming that each node can normally use a preset broadcast heartbeat packet, namely: switching each node to be a master node in turn, and when each node is a master node in turn, removing nodes which cannot transmit and receive broadcast heartbeat packets in each node by checking the current/etc/log/syslog log file of the master node;
checking and confirming that daemons of the keep dual-machine hot standby components of all servers in the server cluster can normally run, realizing the daemons by using the daemon components (the daemon components can be directly installed by using apt-get install or yum install commands in a networking environment so as to realize the daemons), and judging whether the daemons of the keep dual-machine hot standby components can be normally used or not by executing daemon command return contents in command lines.
S0.4, setting the startup self-starting of each keep-alive dual-machine hot standby component, for example, in a ubuntu system, the startup self-starting of the keep-alive dual-machine hot standby component can be realized by using systemctl enable keepalived command.
S0.5, restarting each server.
According to the embodiment, the setting in each server is adjusted by deploying the keep-alive dual-machine hot standby component in the server cluster, so that the keep-alive dual-machine hot standby component can be ensured to normally run in each server, and preparation work is made for subsequent main and standby node switching; the method comprises the steps of determining whether each node can normally use a broadcast heartbeat packet or not by enabling each node to be a master node, wherein the broadcast heartbeat packet can be used for detecting whether connection is normal or not, various network faults can be avoided, stability and reliability of network communication are guaranteed, and the nodes which cannot send and receive the broadcast heartbeat packet in each node are removed, so that the nodes can be guaranteed to normally operate.
S1, determining a first node with the highest priority in a server cluster as a master node according to a vrrp protocol, so that the first node starts vip; each server in the server cluster is provided with a keep-alive dual-machine hot standby component, and each keep-alive dual-machine hot standby component correspondingly controls one node.
It should be noted that vip refers to virtual ip, and is mainly used for performing network address translation, and has network fault tolerance and mobility. vrrp protocol, collectively: virtual Router Redundancy Protocol, chinese name: the virtual route redundancy protocol, vrrp protocol can solve the single point failure problem of static route.
S2, controlling a main node at each moment in the server cluster to be in a non-preemptive state through each keep-alive dual-machine hot standby component.
The non-preemptive state is that after the node with high priority is added to the alternative line of the master node after the failure recovery, resources such as vip being used on the current master node (the node with low priority) are not preempted.
According to the embodiment, the master node is set to be in the non-preemptive state, so that the task of the current master node is not destroyed, the threat of preempting resources by the node from the past master node is avoided, and the current task is ensured to be smoothly carried out.
And S3, when the first node fails, reducing the priority of the first node through a keep dual hot standby component, and determining a second node with the highest priority in the server cluster as a main node according to a vrrp protocol so as to enable vip to drift to the second node.
In the embodiment of the present application, S3 includes: S3.1-S3.3:
and S3.1, when the health status checker monitors that the first node fails, the priority of the first node is reduced through the keep-alive dual-machine hot standby component.
The node failure conditions include: the memory of the server is full and the cache assembly in the application is down.
It should be noted that a Health Checker (Health Checker) is a component in keep alive for monitoring whether a server node is operating normally, and periodically performs Health check on a configured server node to find a fault in time, and decides whether to switch to a standby node according to a check result.
S3.2, comparing the priorities of all nodes in the server cluster according to a vrrp protocol, and taking a second node with the highest priority in the server cluster as a main node so as to enable vip to drift to the second node;
when comparing the priorities of the nodes in the server cluster, if a plurality of nodes with the same highest priority are determined to appear, the second node with the largest ip address is used as the master node by comparing the ip addresses of the plurality of nodes.
The method solves the problem that when a plurality of nodes with the same highest priority appear, the master node is difficult to select by comparing the sizes of the ip addresses, and prevents the phenomenon of blocking in the process of selecting the nodes with the highest priority, so that the selecting process is smoothly performed.
And S3.3, when the second node is the main node, if the first node is determined to be detected by the health checking mechanism, increasing the priority of the first node, and enabling the first node to be restored to the original priority.
The condition that the node detects through the health check mechanism, such as: the server starts the script for automatically cleaning the memory, the application resumes normal access, the node can be used normally, the health check mechanism is used for detecting the node, and the node passes the detection smoothly.
In the embodiment, the first node is detected through the health checking mechanism to judge whether the first node eliminates the fault, so that the first node is restored to the original priority, the first node which has exited the dual-standby operation can be added to the alternative row of the main node again, and further the efficient recycling of the server node is realized.
And S4, when the second node fails, the priority of the second node is reduced through the keep dual hot standby component, so that the second node closes vip, and a third node with the highest priority in the server cluster is determined to be a main node according to the vrrp protocol, so that vip drifts to the third node.
In the embodiment of the present application, S4 includes: S4.1-S4.2:
and S4.1, when the health status checker monitors that the second node fails, the priority of the second node is reduced through the keep-alive dual-machine hot standby component, so that the second node closes vip.
S4.2, if the first node is determined to be restored to the original priority, determining the first node with the highest priority in the server cluster as a master node according to the vrrp protocol, so that vip automatically drifts to the first node;
if the first node is determined not to be restored to the original priority, a third node with the highest priority in the server cluster is re-determined as a main node according to the vrrp protocol, so that vip automatically drifts to the third node; when the priority of each node in the server cluster is compared again, if a plurality of nodes with the same highest priority are determined to appear, the ip addresses of the nodes are compared, and a third node with the largest ip address is used as a main node.
The embodiment aims at the situation that the main node needs to be redetermined when the main node fails for the second time; since the failed master node is the second node at this time, when the master node is redetermined, two cases are considered, one is that the first node has recovered the working capacity, and since the priority of the first node after recovering the priority is in the highest state in the server cluster, the first node is redetermined as the master node; the other is that the first node does not restore the working capacity, and the third node with the highest priority in the server cluster needs to be determined again as the master node, so that the first node can be reused by fully considering different conditions, and the utilization rate of the nodes is improved.
Referring to fig. 2, in order to apply the embodiment of the present application, a dual-active-standby switching flowchart is provided, which specifically includes:
after the server cluster is started, determining the node with the highest priority as a main node through a vrrp protocol, then monitoring the main node in real time through a health status checker, enabling the main node at each moment to be in a non-preemptive state, and then activating vip on the main node to provide application access;
simulating that the first fault occurs on the current main node, reducing the priority of the current main node to enable the current main node to be lower than the standby node (the standby node with the second priority) after the health status checker monitors the fault, then determining the main node from a plurality of standby nodes by the vrrp protocol again according to the priority, enabling vip to drift to the main node, and monitoring the main node through the health status checker to enable the main node to provide application access;
after the first fault node is simulated to be repaired, the node is detected by a health state detector, and after the detection, the priority of the node is increased to restore the node to the original state;
simulating that a second fault occurs on a current main node, monitoring the fault by a health state checker, reducing the priority of the main node and closing vip, determining the main node from a plurality of standby nodes according to the priority again according to a vrrp protocol (if the first fault node has repaired the fault and returns to the original priority, the main node at that time is the repaired first fault node, if the first fault node does not repair the fault, the node with the highest priority needs to be selected from a server cluster again as the main node), drifting vip to the main node, and monitoring the main node by the health state checker to enable the main node to provide application access;
it should be noted that, in the primary-standby switching process, a network time server is used to keep the time of each node synchronous so as to ensure the timeliness of the primary-standby node switching; each node avoids information leakage caused by the fact that a plurality of servers use the same password in a disordered manner through ssh mutual trust communication based on a key authentication mode; a broadcast heartbeat packet is used to maintain a connection between each server and each node.
In general, embodiments of the present application have the following beneficial effects:
according to the embodiment, the setting in each server is adjusted by deploying the keep-alive dual-machine hot standby component in the server cluster, so that the keep-alive dual-machine hot standby component can be ensured to normally run in each server, and preparation work is made for subsequent main and standby node switching; by enabling the master node to be in a non-preemptive state, resources such as vip of other master nodes can be prevented from being preempted after the master node becomes a standby node; the problem that when a plurality of nodes with the same highest priority appear, a master node is difficult to select is solved by comparing the ip address, so that the selection process of a new master node is smoothly carried out; when the second node fails, the priority of the second node needs to be reduced and then the main node is determined again, but the first node is still in a non-preemptive state because the main node is done at the moment, so that an allocation mechanism under the vrrp protocol can be triggered by closing vip of the second node, the first node also has the opportunity of competing for the main node equally, meanwhile, whether the first node at the moment has recovered the working capacity is fully considered, the main node falls onto the first node or a new node with high priority again, and the utilization rate of the node is improved.
Referring to fig. 3, an embodiment of the present application provides a keep-alive-based dual-active-standby switching device, including: the device comprises a debugging module 10, a control module 20, a first switching module 30 and a second switching module 40;
the debugging module 10 is configured to determine, according to a vrrp protocol, a first node with a highest priority in the server cluster as a master node, so that the first node starts vip; each server in the server cluster is provided with a keep-alive dual-machine hot standby component, and each keep-alive dual-machine hot standby component correspondingly controls one node;
the control module 20 is configured to control, through each keep-alive dual-machine hot standby component, a master node at each moment in the server cluster to be in a non-preemptive state;
the first switching module 30 is configured to reduce the priority of the first node through the keep dual hot standby component when the first node fails, and determine, according to the vrrp protocol, a second node with the highest priority in the server cluster as a master node, so as to enable vip to drift to the second node;
and the second switching module 40 is configured to reduce the priority of the second node through the keep dual hot standby component when the second node fails, so that the second node closes vip, and determine a third node with the highest priority in the server cluster as a master node according to the vrrp protocol, so that the vip drifts to the third node.
In one embodiment, debug module 10 further comprises:
the first adjusting unit is used for deploying keep dual hot standby components in two or more server clusters and closing iptables service and selinux service of each server in the server clusters; the time of each node in each keepalive dual-machine hot standby component is kept synchronous, and the nodes are mutually communicated through the host names of the servers based on a key authentication mode;
the system is also used for checking and confirming that each node can normally use a preset broadcast heartbeat packet, and the keep dual-machine hot standby component of each server in the server cluster can normally operate; setting each keepalive dual-machine hot standby component to start up and restart each server;
and the second adjusting unit is used for switching each node to be a master node in turn, and removing nodes which cannot transmit and receive the broadcast heartbeat packet from each node by checking the/etc/log/syslog log file of the current master node when each node is the master node in turn.
In one embodiment, the first switching module 30 further includes:
the first determining unit of the master node is used for comparing the priorities of all nodes in the server cluster according to the vrrp protocol, and taking the second node with the highest priority in the server cluster as the master node;
the server cluster is also used for comparing the priorities of the nodes in the server cluster, if a plurality of nodes with the same highest priority appear, the ip addresses of the nodes are compared, and a second node with the largest ip address is used as a main node;
and the node first recovery unit is used for increasing the priority of the first node if the first node is determined to be detected by the health check mechanism when the second node is the master node, so that the first node is recovered to the original priority.
In one embodiment, the second switching module 40 is further configured to:
if the first node is determined to be restored to the original priority, determining the first node with the highest priority in the server cluster as a main node according to the vrrp protocol, so that vip automatically drifts to the first node;
if the first node is determined not to be restored to the original priority, a third node with the highest priority in the server cluster is re-determined as a main node according to the vrrp protocol, so that vip automatically drifts to the third node; when the priority of each node in the server cluster is compared again, if a plurality of nodes with the same highest priority are determined to appear, the ip addresses of the nodes are compared, and a third node with the largest ip address is used as a main node.
The device can prevent the main node from preempting resources such as vip of other main nodes after becoming the standby node by enabling the main node to be in a non-preemptive state; when a first node or a second node serving as a main node fails, the priority of the node is reduced to enable the node to give up resources such as vip and the like, and the main node is redetermined according to the priority based on reassignment logic, so that equal use opportunities of all standby nodes at the moment are given, including re-use opportunities of the nodes with reduced priority are given, and each server can perform more frequent main-standby switching; when the second node fails, the priority of the second node needs to be reduced and then the main node is determined again, but the first node is still in a non-preemptive state because the main node is made at this time, so that by closing vip of the second node, an allocation mechanism under the vrrp protocol can be triggered, the first node also has the opportunity of competing for the main node equally, the main node falls onto the node with high priority again, and the utilization rate of the node is improved.
Referring to fig. 4, an embodiment of the present application provides a keep-alive-based dual-active-standby switching system, including: switching means 101, server cluster means 201 and computer hardware configuration means 301;
the computer hardware configuration device 301 controls the switching device 101 to execute a keep-alive-based dual-active-standby switching method on the server cluster device 201 as described above.
Correspondingly, the embodiment of the application also provides a computer readable storage medium, which comprises a stored computer program, wherein the equipment where the computer readable storage medium is located is controlled to execute the method for switching the active and the standby of the double computers based on keepaled when the computer program runs;
the method for switching the dual hot standby based on keep can be stored in a computer readable storage medium if the method is realized in the form of a software functional unit and used as an independent product. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, and the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
The foregoing is a preferred embodiment of the present application and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present application and are intended to be comprehended within the scope of the present application.

Claims (9)

1. The method for switching the active and standby of the dual-computer hot standby based on the keepaled is characterized by comprising the following steps of:
according to a vrrp protocol, determining a first node with highest priority in a server cluster as a master node, so that the first node starts vip; each server in the server cluster is provided with a keep-alive dual-machine hot standby component, and each keep-alive dual-machine hot standby component correspondingly controls one node;
controlling a main node at each moment in the server cluster to be in a non-preemptive state through each keep-alive dual-machine hot standby component;
when the first node fails, the priority of the first node is reduced through the keep alive dual-machine hot standby component, and a second node with the highest priority in the server cluster is determined to be a main node according to the vrrp protocol, so that the vip drifts to the second node;
and when the second node fails, reducing the priority of the second node through the keep dual hot standby component, enabling the second node to close the vip, and determining a third node with the highest priority in the server cluster as a main node according to the vrrp protocol so as to enable the vip to drift to the third node.
2. The method for switching between active and standby dual hot standby according to claim 1, wherein after determining a second node with a highest priority in the server cluster as a master node, so as to drift the vip to the second node, the method further comprises:
and when the second node is the main node, if the first node is determined to be detected by a health check mechanism, increasing the priority of the first node, so that the first node is restored to the original priority.
3. The method for switching between active and standby dual hot standby according to claim 2, wherein determining a third node with the highest priority in the server cluster as a master node, so that the vip automatically drifts to the third node is specifically as follows:
if the first node is determined to be restored to the original priority, determining the first node with the highest priority in the server cluster as a main node according to the vrrp protocol, so that the vip automatically drifts to the first node;
if the first node is determined not to be restored to the original priority, the third node with the highest priority in the server cluster is re-determined as a main node according to the vrrp protocol, so that the vip automatically drifts to the third node; and when the priorities of the nodes in the server cluster are compared again, if a plurality of nodes with the same highest priority are determined to appear, the ip addresses of the nodes are compared, and a third node with the largest ip address is used as a main node.
4. The method for switching between active and standby dual hot standby according to claim 1, wherein the determining, according to the vrrp protocol, the second node with the highest priority in the server cluster as the master node specifically comprises:
comparing the priority of each node in the server cluster according to the vrrp protocol, and taking a second node with the highest priority in the server cluster as a master node;
and when comparing the priorities of the nodes in the server cluster, if a plurality of nodes with the same highest priority appear, comparing the ip addresses of the nodes, and taking the second node with the largest ip address as a main node.
5. The method for switching between active and standby hot standby according to claim 1, wherein before determining a first node with a highest priority in a server cluster as a master node according to vrrp protocol to enable the first node to start vip, the method further comprises:
deploying the keep dual hot standby components in two or more server clusters, and closing iptables service and selinux service of each server in the server clusters; the time of each node in each keepalive dual-machine hot standby component is kept synchronous, and mutual communication is carried out between the nodes through the host names of the servers in a key authentication mode;
checking and confirming that each node can normally use a preset broadcast heartbeat packet, and enabling a keep dual-machine hot standby component of each server in the server cluster to normally operate; and setting the startup self-starting of each keep-alive dual-machine hot standby component, and restarting each server.
6. The method for switching between active and standby of dual-standby based on keepalive as claimed in claim 5, wherein checking and confirming that each node can normally use a preset broadcast heartbeat packet comprises:
and switching each node to become a master node in turn, and when each node becomes the master node in turn, removing nodes which cannot transmit and receive the broadcast heartbeat packet in each node by checking the/etc/log/syslog log file of the current master node.
7. The utility model provides a double-machine hot standby master spare auto-change over device based on keepalive which characterized in that includes: the device comprises a debugging module, a control module, a first switching module and a second switching module;
the debugging module is used for determining a first node with highest priority in the server cluster as a main node according to a vrrp protocol so as to enable the first node to start vip; each server in the server cluster is provided with a keep-alive dual-machine hot standby component, and each keep-alive dual-machine hot standby component correspondingly controls one node;
the control module is used for controlling the master node at each moment in the server cluster to be in a non-preemptive state through each keep-alive dual-machine hot standby component;
the first switching module is configured to reduce, when the first node fails, the priority of the first node through the keep dual hot standby component, and determine, according to the vrrp protocol, a second node with a highest priority in the server cluster as a master node, so that the vip drifts to the second node;
and the second switching module is used for reducing the priority of the second node through the keep dual-machine hot standby component when the second node fails, enabling the second node to close the vip, and determining a third node with the highest priority in the server cluster as a main node according to the vrrp protocol so as to enable the vip to drift to the third node.
8. The dual hot standby master/slave switching device based on keepalive according to claim 7, wherein the debug module further comprises:
the first adjusting unit is used for deploying the keep dual-engine hot standby component in two or more server clusters and closing the iptables service and the selinux service of each server in the server clusters; the time of each node in each keepalive dual-machine hot standby component is kept synchronous, and mutual communication is carried out between the nodes through the host names of the servers in a key authentication mode;
the method is also used for checking and confirming that each node can normally use a preset broadcast heartbeat packet, and the keep dual-machine hot standby component of each server in the server cluster can normally operate; setting the startup self-starting of each keep-alive dual-machine hot standby component, and restarting each server;
and the second adjusting unit is used for switching each node to be a master node in turn, and when each node is a master node in turn, deleting the nodes which cannot transmit and receive the broadcast heartbeat packet in each node by checking the per-etc/log/syslog log file of the current master node.
9. The utility model provides a two machine hot standby master standby switching system based on keepalive which characterized in that includes: switching device, server cluster device and computer hardware structure device;
the computer hardware structure device controls the switching device to execute a keep-alive-based dual-computer hot standby switching method according to any one of claims 1 to 6 on the server cluster device.
CN202311446833.6A 2023-11-01 2023-11-01 Method, device and system for switching active and standby hot standby based on keepaled Pending CN117240694A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311446833.6A CN117240694A (en) 2023-11-01 2023-11-01 Method, device and system for switching active and standby hot standby based on keepaled

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311446833.6A CN117240694A (en) 2023-11-01 2023-11-01 Method, device and system for switching active and standby hot standby based on keepaled

Publications (1)

Publication Number Publication Date
CN117240694A true CN117240694A (en) 2023-12-15

Family

ID=89096868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311446833.6A Pending CN117240694A (en) 2023-11-01 2023-11-01 Method, device and system for switching active and standby hot standby based on keepaled

Country Status (1)

Country Link
CN (1) CN117240694A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117785568A (en) * 2024-02-27 2024-03-29 广东保伦电子股份有限公司 Dual-master dual-machine hot standby method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110912780A (en) * 2019-12-13 2020-03-24 无锡华云数据技术服务有限公司 High-availability cluster detection method, system and controlled terminal
CN114035997A (en) * 2021-11-18 2022-02-11 重庆富民银行股份有限公司 High-availability fault switching method based on MGR
CN115640171A (en) * 2022-11-09 2023-01-24 北京航天自动控制研究所 Database dual-node hot standby method and system without arbitration node
CN116319274A (en) * 2023-02-21 2023-06-23 杭州红岭通信息科技有限公司 Method for realizing hot standby of distributed system capable of acquiring current main node

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110912780A (en) * 2019-12-13 2020-03-24 无锡华云数据技术服务有限公司 High-availability cluster detection method, system and controlled terminal
CN114035997A (en) * 2021-11-18 2022-02-11 重庆富民银行股份有限公司 High-availability fault switching method based on MGR
CN115640171A (en) * 2022-11-09 2023-01-24 北京航天自动控制研究所 Database dual-node hot standby method and system without arbitration node
CN116319274A (en) * 2023-02-21 2023-06-23 杭州红岭通信息科技有限公司 Method for realizing hot standby of distributed system capable of acquiring current main node

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117785568A (en) * 2024-02-27 2024-03-29 广东保伦电子股份有限公司 Dual-master dual-machine hot standby method and device

Similar Documents

Publication Publication Date Title
Han et al. On the resiliency of virtual network functions
US8402305B1 (en) Method and system for providing high availability to computer applications
Reiser et al. Hypervisor-based efficient proactive recovery
US8943489B1 (en) High availability in-service software upgrade using virtual machine instances in dual computing appliances
EP3210367B1 (en) System and method for disaster recovery of cloud applications
CN112511326B (en) Switching method, device, equipment and storage medium
CN114116912A (en) Method for realizing high availability of database based on Keepalived
CN111835685B (en) Method and server for monitoring running state of Nginx network isolation space
CN117240694A (en) Method, device and system for switching active and standby hot standby based on keepaled
CN116319274A (en) Method for realizing hot standby of distributed system capable of acquiring current main node
US11418382B2 (en) Method of cooperative active-standby failover between logical routers based on health of attached services
JP5285045B2 (en) Failure recovery method, server and program in virtual environment
JP5285044B2 (en) Cluster system recovery method, server, and program
Caesar et al. Building bug-tolerant routers with virtualization
CN112187523A (en) Network high-availability implementation method and super-convergence system
CN115190040B (en) High-availability realization method and device for virtual machine
CN114915545B (en) Application scheduling deployment management method based on DHCP network cluster
CN102388569B (en) Method and system for shifting between main and standby management software
CN115549751A (en) Remote sensing satellite ground station monitoring system and method
AT&T
Kitamura et al. Development of a Server Management System Incorporating a Peer-to-Peer Method for Constructing a High-availability Server System
CN111835544B (en) Monitoring method and system of virtual router based on user mode protocol stack
CN117785568B (en) Dual-master dual-machine hot standby method and device
CN107783855B (en) Fault self-healing control device and method for virtual network element
CN112804077B (en) Data protection method, controller, control plane device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination