CN115801555A - Main/standby switching method and device based on preemption delay and electronic equipment - Google Patents

Main/standby switching method and device based on preemption delay and electronic equipment Download PDF

Info

Publication number
CN115801555A
CN115801555A CN202310014993.7A CN202310014993A CN115801555A CN 115801555 A CN115801555 A CN 115801555A CN 202310014993 A CN202310014993 A CN 202310014993A CN 115801555 A CN115801555 A CN 115801555A
Authority
CN
China
Prior art keywords
equipment
vrrp
notification message
time
group
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.)
Granted
Application number
CN202310014993.7A
Other languages
Chinese (zh)
Other versions
CN115801555B (en
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.)
BEIJING ZHONGKE WANGWEI INFORMATION TECHNOLOGY CO LTD
Original Assignee
BEIJING ZHONGKE WANGWEI INFORMATION TECHNOLOGY 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 BEIJING ZHONGKE WANGWEI INFORMATION TECHNOLOGY CO LTD filed Critical BEIJING ZHONGKE WANGWEI INFORMATION TECHNOLOGY CO LTD
Priority to CN202310014993.7A priority Critical patent/CN115801555B/en
Publication of CN115801555A publication Critical patent/CN115801555A/en
Application granted granted Critical
Publication of CN115801555B publication Critical patent/CN115801555B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a main/standby switching method, a device and electronic equipment based on preemption delay, which relate to the technical field of network communication, and the method comprises the following steps: the method comprises the steps that first equipment continuously monitors whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises the condition that the VRRP notification message is not monitored or the condition that the VRRP notification message sent by second equipment is monitored; determining that the first equipment is the main equipment in the VRRP group based on a monitoring result obtained at a first moment, and switching to the main equipment in the VRRP group at a second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group. The method and the system avoid frequent switching of the main equipment caused by unstable main wall state, avoid flow oscillation and waste of system resources, and increase reliability and adaptability to network environment.

Description

Main/standby switching method and device based on preemption delay and electronic equipment
Technical Field
The present invention relates to the field of network communication technologies, and in particular, to a method and an apparatus for active/standby switching based on preemption delay, and an electronic device.
Background
In the related art, in order to avoid interruption of data communication caused by a single point of failure, an HA (high availability) function is provided, and when a node fails, a backup device can take over the work of the node, so that network communication can still normally operate, and the reliability of a network is effectively enhanced. The primary/standby mode is the most common backup mode of HA. The active/standby mode is based on a VRRP (Virtual Router Redundancy Protocol) to complete negotiation of the active/standby state of the firewall. In the VRRP protocol, security gateways in the same VRRP group have two mutually exclusive roles: a Master security gateway (Master) and a Backup security gateway (Backup). The VRRP protocol selects one from the VRRP group as a Master by using a selection strategy, processes flow and provides service for the outside; the other device is used as a backup device, does not process the flow and does not provide services to the outside. Once the main device fails, the backup device switches to an active state to take over the main device to continue processing traffic and providing external services.
The current high-reliability preemption mode is an immediate preemption mode, and in the mode, when the main equipment fails, the original standby machine is selected as a new main machine; if the original host recovers to normal, the host will immediately take the status back. In this mode, the master device responsible for forwarding is always the device with the highest metric value in the VRRP group. Therefore, the user lacks flexibility in configuring the main and standby devices in different network environments, and the following situations cannot be avoided: when the original master device is unstable, for example, the interface state is unstable, frequent state switching may be caused, so that the flow oscillates, and system resources are wasted.
Therefore, how to avoid the traffic oscillation and the waste of system resources caused by frequently switching the master device when the master device is unstable becomes a problem to be solved urgently.
Disclosure of Invention
The invention provides a main/standby switching method and device based on preemption delay and electronic equipment, which are used for solving the problems of flow oscillation and waste of system resources caused by frequently switching main equipment when the main equipment is unstable in the prior art, and improving the reliability and the adaptability to a network environment.
The invention provides a main/standby switching method based on preemption delay, which comprises the following steps:
the method comprises the steps that first equipment continuously monitors whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises the condition that the VRRP notification message is not monitored or the condition that the VRRP notification message sent by second equipment is monitored;
determining that the first equipment is the main equipment in the VRRP group based on a monitoring result obtained at a first moment, and switching to the main equipment in the VRRP group at a second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
According to the active/standby switching method based on preemption delay provided by the present invention, the determining that the first device is the master device in the VRRP group based on the monitoring result obtained at the first time includes at least one of the following:
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is higher than the priority indicated by the VRRP notification message of the second equipment, determining that the first equipment is a main equipment in a VRRP group;
under the condition that the monitoring result includes that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is equal to the priority indicated by the VRRP notification message of the second equipment and the node ID value of the first equipment is higher than the node ID value indicated by the VRRP notification message of the second equipment, determining that the first equipment is a main equipment in a VRRP group;
when the second device is the master device in the VRRP group at the third moment and the monitoring result includes that the VRRP notification message sent by the second device is not monitored, determining that the first device is the master device in the VRRP group; the third time is earlier than the first time.
According to the active/standby switching method based on preemption delay provided by the present invention, before the first device continuously monitors whether a virtual route redundancy protocol VRRP advertisement message exists, the method further comprises:
the first device joins the VRRP group.
The method further comprises the following steps:
and under the condition that the first equipment does not monitor a VRRP notification message after joining the VRRP group, the first equipment is switched to be the main equipment in the VRRP group.
According to the master/slave switching method based on preemption delay provided by the present invention, after the first device joins the VRRP group, the method further comprises:
the first device requests configuration synchronization and state information synchronization from other devices in the VRRP group.
According to the master/slave switching method based on preemption delay provided by the invention, after the master device in the VRRP group is switched, the method further comprises the following steps:
and sending the VRRP notification message of the first equipment to the standby equipment in the VRRP group.
According to the master-slave switching method based on preemption delay, the method also comprises at least one of the following steps:
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is lower than the priority indicated by the VRRP notification message of the second equipment, determining that the second equipment is a master equipment in a VRRP group;
and under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is equal to the priority indicated by the VRRP notification message of the second equipment and the node ID value of the first equipment is lower than the node ID value indicated by the VRRP notification message of the second equipment, determining that the second equipment is the main equipment in the VRRP group.
The invention also provides a master-slave switching device based on preemption delay, which comprises:
the monitoring module is used for continuously monitoring whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises that the VRRP notification message is not monitored or the VRRP notification message sent by the second equipment is monitored;
the switching module is used for determining that the first equipment is the main equipment in the VRRP group based on the monitoring result obtained at the first moment and switching to the main equipment in the VRRP group at the second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor realizes the active-standby switching method based on the preemption delay when executing the program.
The present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for active/standby switching based on preemption delay.
The invention also provides a computer program product, which comprises a computer program, and the computer program realizes the active/standby switching method based on the preemption delay when being executed by a processor.
According to the master-slave switching method and device based on the preemption delay and the electronic equipment, whether VRRP messages sent by other equipment exist is continuously monitored through the first equipment, if VRRP messages sent by the second equipment exist, master-slave election is carried out, under the condition that the first equipment is determined to be the master equipment through election, the master equipment is not immediately switched, and switching is carried out after the preset delay time length, so that frequent switching of the master equipment caused by unstable master wall state is avoided, flow oscillation and waste of system resources are avoided, and reliability and adaptability to network environment are improved.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a master/slave switching method based on preemption delay according to the present invention;
fig. 2 is a master/slave mode topology diagram of the master/slave switching method based on preemption delay according to the present invention;
fig. 3 is a second schematic flowchart of the active/standby switching method based on preemption delay according to the present invention;
fig. 4 is a schematic structural diagram of a master/slave switching device based on preemption delay according to the present invention;
fig. 5 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
Fig. 1 is a schematic flowchart of a master/slave switching method based on preemption delay according to the present invention, and as shown in fig. 1, the method includes the following steps:
step 100, a first device continuously monitors whether a Virtual Routing Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises that the VRRP notification message is not monitored or that a VRRP notification message sent by a second device is monitored;
optionally, the first device may be a security gateway in a VRRP group.
Optionally, the first device may continuously monitor the VRRP advertisement packet, or monitor once every 1s, or monitor once every 2s, which is not limited in the present invention.
Optionally, the listening result of the first device may be any one of the following two cases:
1. the first equipment does not monitor the VRRP notification message in the time;
2. the first equipment monitors 1 VRRP notification message in the time;
optionally, the first device does not monitor the VRRP notification message, which may be that the VRRP group to which the first device belongs does not have other devices, or that other devices are failed, or that other devices are in other states incapable of sending the VRRP group.
Optionally, the sending of the VRRP notification message by the second device may be continuous sending or periodic sending, and the sending frequency may be 1 time every 1s, 1 time every 2s, or 1 time every 3s, which is not limited in this invention.
Optionally, the VRRP advertisement message monitored by the first device may be sent by other devices in the same VRRP group as the first device.
Optionally, the VRRP advertisement message monitored by the first device may be sent from a master device in a VRRP group where the first device is located.
Optionally, the VRRP advertisement message carries a priority and a node ID value, and after monitoring the VRRP advertisement message, the first device may obtain the priority and the node ID value of the source device of the advertisement message.
Step 110, determining that the first device is a master device in a VRRP group based on a monitoring result obtained at a first moment, and switching to the master device in the VRRP group at a second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
Optionally, the first device may continue to listen to the VRRP advertisement message during the delay time period after the master election determines that the first device may serve as a master device of the VRRP group,
any of the following 3 cases may be used:
1. if the preset delay time is shorter than the sending period of the VRRP notification message, the first device does not monitor the VRRP notification message before the second time, namely after the first device is determined to be the main device in the VRRP group at the first time, the first device is switched to the main device at the second time;
2. if the preset delay time is equal to the sending period of the VRRP notification message, the first equipment monitors the VRRP notification message at the first moment and the second moment, and only if the first equipment is determined to be the main equipment in the VRRP group at the first moment and the second moment, the first equipment is switched into the main equipment at the second moment;
3. if the preset delay time is longer than the sending period of the VRRP notification message, the first device monitors the VRRP notification message for 2 times or more before the second time, namely, the primary-secondary election is carried out for 2 times or more, and only if the first device is determined to be the main device in the VRRP group during each primary-secondary election, the first device is switched into the main device at the second time.
Optionally, the preset delay time duration range may be 0 to 20s, or 0 to 40s, or 0 to 60s, which is not limited in the present invention; if the preset delay time is set to 0s, monitoring a VRRP notification message at the first time, and under the condition that the monitoring result is the VRRP notification message sent by the second equipment, if the first equipment is determined to be the main equipment in the VRRP group based on the monitoring result, immediately switching the first equipment to be the main equipment in the VRRP group.
Optionally, if the first device monitors the VRRP notification packet during the delay time period after the master/slave election determines that the first device may serve as the master device of the VRRP group, the monitoring result is the VRRP notification packet sent by the second device, and the second device is determined to be the master device in the VRRP group based on the monitoring result, the second device may be in a failure state at the first time because the second device is the original master device, and recovers a normal state after the first time, or the second device may not be added to the VRRP group in which the first device is located at the first time, and is added after the first time.
Optionally, if the first device monitors the VRRP notification packet during the delay time period after the master/slave election determines that the first device may serve as the master device of the VRRP group, the monitoring result is the VRRP notification packet sent by the second device, and the second device is determined to be the master device in the VRRP group based on the monitoring result, the first device is not switched to the master device in the VRRP group at the second time.
Optionally, the first device continuously monitors whether a VRRP notification message exists, and when the VRRP notification message sent by the second device exists and it is determined that the first device is a master device in the VRRP group based on the monitoring result, the first device is switched to the master device after a preset delay time.
The master-slave switching method based on the preemption delay provided by the invention continuously monitors whether VRRP messages sent by other equipment exist through the first equipment, if the VRRP messages sent by the second equipment exist in the monitoring result, the master-slave election is carried out, and under the condition that the first equipment is determined to be the master equipment by the election, the master equipment is not immediately switched, but is switched after the preset delay time, so that the frequent switching of the master equipment caused by the unstable state of a master wall can be avoided, the flow oscillation and the waste of system resources are avoided, and the reliability and the adaptability to the network environment are increased.
Optionally, in the active/standby switching method based on preemption delay, determining that the first device is a master device in a VRRP group based on a monitoring result obtained at the first time includes at least one of:
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is higher than the priority indicated by the VRRP notification message of the second equipment, determining that the first equipment is a main equipment in a VRRP group;
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is equal to the priority indicated by the VRRP notification message of the second equipment and the node ID value of the first equipment is higher than the node ID value indicated by the VRRP notification message of the second equipment, determining that the first equipment is a master equipment in a VRRP group;
when the second device is the master device in the VRRP group at the third moment and the monitoring result includes that the VRRP notification message sent by the second device is not monitored, determining that the first device is the master device in the VRRP group; the third time is earlier than the first time.
Optionally, the priority may be configured in advance, or configured by the user based on the requirement, or adjusted by the user in real time based on the requirement, and the configuration range may be 1 to 100, may also be 1 to 200, and may also be 1 to 254, which is not limited by the present invention.
Optionally, the first device does not monitor the VRRP notification message sent by the second device may be due to the second device failing or being in another state where the notification message cannot be sent out.
Optionally, the first device monitors the VRRP notification packet, and after the monitoring result is the VRRP notification packet sent by the second device, the first device may perform master/slave election, and may elect a device with higher priority level in the first device and the second device as a master device; when the priorities of the first device and the second device are the same, the device with the large node ID value can be elected as the master device.
Optionally, the determining that the first device is a master device of the VRRP group may be any one of the following three cases:
1. the priority of the first device is greater than the priority of the second device;
2. the priority of the first device is equal to the priority of the second device, and the node ID value of the first device is larger than the node ID value of the second device;
3. the first device does not listen to the VRRP advertisement message.
Optionally, the priority indicated or carried by the VRRP advertisement packet of the second device may be the priority of the second device.
Optionally, the node ID value indicated or carried by the VRRP advertisement packet of the second device may be the node ID value of the second device.
Optionally, if the first device monitors the VRRP advertisement during the delay time after the master-slave election determines that the first device may serve as the master device of the VRRP group, and the monitoring result is the VRRP advertisement message sent by the second device, and the priority of the first device is lower than the priority indicated by the VRRP advertisement message of the second device, the first device is not switched to the master device in the VRRP group at the second time, and the second device still serves as the master device in the VRRP group.
Optionally, if the first device monitors the VRRP notification packet during the delay time period after the master/slave election determines that the first device may serve as the master device of the VRRP group, and the monitoring result is the VRRP notification packet sent by the second device, the priority of the first device is equal to the priority indicated by the VRRP notification packet of the second device, and the node ID value of the first device is greater than the node ID value indicated by the VRRP notification packet of the second device, the first device is not switched to the master device in the VRRP group at the second time, and the second device still serves as the master device in the VRRP group.
Optionally, in a delay duration after the first device determines that the first device may serve as a master device of the VRRP group, if the priority of the first device is higher than that of the second device, the first device may be switched to the master device in the VRRP group at the second time.
Optionally, during the delay time duration after the master/slave election determines that the first device may serve as the master device of the VRRP group, the priority of the first device is the same as the priority of the second device, and the node ID value of the first device is higher than the node ID value of the second device, the first device may be switched to the master device in the VRRP group at the second time.
Optionally, if the first device monitors the VRRP notification packet during the delay time after the master/slave election determines that the first device may serve as the master device of the VRRP group, and the monitoring result is the VRRP notification packet sent by the second device, the priority of the second device is equal to the priority of the first device, and the node ID value of the second device is greater than the node ID value of the first device, the first device is not switched to the master device in the VRRP group at the second time.
Optionally, when the master/slave election is performed, the election method is that the priority of the device is compared with the node ID value, the device with the higher priority is used as the master device, and the device with the higher node ID value is used as the master device when the priorities are the same; and under the condition that the second equipment is the master equipment, when the first equipment does not monitor the VRRP notification message sent by the second equipment, switching the first equipment into the master equipment after the preset delay time.
The invention provides a main/standby switching method based on preemption delay, which determines main equipment by comparing the priorities of different equipment and node ID values, so that the equipment with higher priority or the same priority and higher node ID value can be used as the main equipment; when two devices in the same VRRP group cannot monitor the VRRP notification message sent by the main device or confirm that the priority of the main device is smaller than the priority of the device, or the priority of the main device is the same as that of the device and the node ID value of the main device is smaller than that of the device, after the preset delay time is prolonged, the standby device is switched to the main device, if the standby device monitors the VRRP notification message sent by the main device during the preset delay time and the priority of the main device is still greater than that of the standby device, or the priority of the main device is the same as that of the standby device and the node ID value of the main device is greater than that of the standby device, the original switching task is cancelled, the main and standby states are kept unchanged, the main device bearing the forwarding task can be ensured to be always the device with the highest metric value in the VRRP group, the working efficiency is improved, and frequent switching of the main device caused by the unstable main wall state is avoided, thereby avoiding flow oscillation and waste of system resources, and increasing reliability and adaptability to network environment.
Optionally, before the first device continuously monitors whether a virtual routing redundancy protocol VRRP notification packet exists, the method for active/standby switching based on preemption delay further includes:
the first device joins the VRRP group.
The method further comprises the following steps:
and under the condition that the first equipment does not monitor a VRRP notification message after joining the VRRP group, the first equipment is switched to be the main equipment in the VRRP group.
Optionally, after joining the VRRP group, the first device starts to continuously monitor whether a VRRP advertisement message exists.
Optionally, the first device does not monitor the VRRP advertisement packet at the first time, which may be any one of the following two cases:
1. the VRRP group does not have other devices except the first device;
2. and other equipment of the VRRP group fails or is in other states incapable of sending the VRRP notification message.
Optionally, after the first device joins the VRRP group, the first device listens to other member devices of the same VRRP group at a specified interval period. And if the first equipment does not receive any VRRP notification message from other equipment, the first equipment is actively switched into the master equipment.
The master-slave switching method based on the preemption delay provided by the invention starts to continuously monitor the VRRP notification message sent by other equipment in the same group after the first equipment joins the VRRP group, and switches the first equipment into the master equipment of the VRRP group if the VRRP notification message is not monitored, thereby ensuring that one VRRP group has one master equipment to work.
Optionally, after the first device joins the VRRP group, the method for switching between the master device and the slave device based on preemption delay further includes:
the first device requests configuration synchronization and state information synchronization from other devices in the VRRP group.
Optionally, after the first device joins the VRRP group, request configuration synchronization and state information synchronization may be performed, and after synchronization is completed, master/slave election may be performed.
The master-slave switching method based on the preemption delay, which is provided by the invention, carries out configuration synchronization and state information synchronization after the first equipment is added into the VRRP group for the first time, thereby avoiding the network communication abnormity possibly caused by different roles of the equipment in all VRRP backup groups.
Optionally, after the active/standby switching method based on preemption delay is switched to the master device in the VRRP group, the method further includes:
and sending the VRRP notification message of the first equipment to the standby equipment in the VRRP group.
Optionally, after the first device is switched to the master device in the VRRP group, the VRRP notification message may be sent to the second device.
Optionally, the second device may switch to the standby device after receiving the VRRP notification message. Optionally, the master device may periodically notify its own VRRP notification packet to the standby device, where the VRRP notification packet carries the priority and the node ID value.
Optionally, the priority indicated or carried by the VRRP advertisement packet of the first device may be the priority of the first device.
Optionally, the node ID value indicated or carried by the VRRP advertisement packet of the first device may be the node ID value of the first device.
The invention provides a master-slave switching method based on preemption delay, which can periodically notify a VRRP notification message of a first device to a spare device after the first device is switched to the master device, and when the priority of the spare device is higher than the priority of the first device or the priority of the spare device is equal to the priority of the first device and the node ID value of the spare device is higher than the node ID value of the first device, the spare device is switched to the master device after the preset delay time length, and the first device is switched to the spare device, thereby ensuring that the master device bearing a forwarding task is always the device with the highest metric value in a VRRP group, and improving the working efficiency.
Optionally, the active/standby switching method based on preemption delay further includes at least one of the following:
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is lower than the priority indicated by the VRRP notification message of the second equipment, determining that the second equipment is a master equipment in a VRRP group;
and under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is equal to the priority indicated by the VRRP notification message of the second equipment and the node ID value of the first equipment is lower than the node ID value indicated by the VRRP notification message of the second equipment, determining that the second equipment is the main equipment in the VRRP group.
Optionally, if the priority of the first device is lower than the priority of the second device, the second device is switched to the master device after a preset delay time, and the first device continuously monitors the VRRP notification packet of the master device.
Optionally, if the priority of the first device is equal to the priority of the second device and the node ID value of the first device is smaller than the node ID value of the second device, the second device is switched to the master device after a preset delay time, and the first device continuously monitors the VRRP advertisement packet of the master device.
The master-slave switching method based on preemption delay provided by the invention takes the equipment with the highest priority or the highest node ID value with the same priority as the master equipment by continuously comparing the priority and the node ID value between the equipment, thus ensuring that the master equipment bearing the forwarding task is always the equipment with the highest metric value in the VRRP group and improving the working efficiency.
In an embodiment, fig. 2 is a master/slave mode topology diagram of a master/slave switching method based on preemption delay, which includes:
host computer, switch, equipment A, equipment B, SERVER SERVER.
Ge0/0/3 of the device is used for synchronization of the state information and the configuration information;
ge0/0/1 of the device A is added into the VRRP group 1, the priority is configured to be 100, ge0/0/2 is added into the VRRP group 2, and the priority is configured to be 100;
ge0/0/1 of the device B is added into the VRRP group 1, the priority is configured to be 90, ge0/0/2 is added into the VRRP group 2, and the priority is configured to be 90;
the VRRP protocol uses a selection strategy to select one from the VRRP group as the Master. If the device B starts HA first, the device B becomes a main device because only one device exists in the current network, and the service ports ge0/0/1 and ge0/0/2 periodically send VRRP notification messages; at the moment, the device A starts HA, if the device A finds that the priority of the local machine is higher than that of the opposite end after receiving VRRP message negotiation through a ge0/0/1 port in a VRRP group 1, the device A is preempted to become a main device after the preemption delay time, and sends a VRRP notice to inform the opposite end to switch into a standby device; in the same way, in the VRRP group 2, after the ge0/0/2 port receives the VRRP message and negotiates, the device A elects as the main device.
In an embodiment, fig. 3 is a second flowchart of the active/standby switching method based on preemption delay, which includes:
step 310: the equipment is in a standby equipment state;
step 320: judging whether the equipment receives an announcement message of a certain VRRP master equipment; if yes, go to step 330; if not, go to step 360.
Step 330: analyzing the received VRRP message, and performing master-slave election according to the priority and the node ID value; the synchronization of configuration state information needs to be done when a device first joins a VRRP group.
Step 340: judging whether the priority of the equipment is higher or the priority is the same, and the node ID value is higher, if so, executing step 350; if not, go to step 310.
Step 350: in the preemption mode, the device enters the main device state after a preset delay time.
Step 360: the equipment is switched into a main equipment state, and a VRRP message is periodically sent to the standby equipment; if only one device exists in the current VRRP group, the device automatically becomes a master device; if other devices exist in the VRRP group, the master device is selected and the other devices are informed to be switched to the standby devices.
Step 370: judging whether the master equipment receives the VRRP message, wherein the priority is higher than that of the master equipment or the priority is the same, the node ID value is higher than that of the master equipment, and if so, executing a step 310; if not, continuously receiving the VRRP message.
The following describes the master/slave switching device based on preemption delay according to the present invention, and the master/slave switching device based on preemption delay described below and the master/slave switching method based on preemption delay described above may be referred to in correspondence with each other.
Fig. 4 is a schematic structural diagram of the active/standby switching device based on preemption delay, which includes a monitoring module 410 and a switching module 420.
The monitoring module 410 is configured to continuously monitor whether a Virtual Router Redundancy Protocol (VRRP) advertisement message exists, and obtain a monitoring result, where the monitoring result includes that the VRRP advertisement message is not monitored or that a VRRP advertisement message sent by a second device is monitored;
the switching module 420 is configured to determine that the first device is a master device in a VRRP group based on a monitoring result obtained at a first time, and switch the first device to the master device in the VRRP group at a second time; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
The invention provides a master-slave switching device based on preemption delay, which continuously monitors whether VRRP messages sent by other equipment exist through a monitoring module, carries out master-slave election if VRRP messages sent by second equipment exist, and under the condition that the first equipment is determined to be the master equipment by election, a switching module does not immediately switch the first equipment into the master equipment but switches the first equipment after preset delay time, so that frequent switching of the master equipment caused by unstable master wall state can be avoided, flow oscillation and waste of system resources are avoided, and reliability and adaptability to network environment are increased.
It can be understood that the active/standby switching device based on preemption delay provided by the present invention corresponds to the active/standby switching method based on preemption delay provided by each embodiment described above, and the relevant technical features of the active/standby switching device based on preemption delay provided by the present invention can refer to the relevant technical features of the active/standby switching method based on preemption delay provided by each embodiment described above, and are not described herein again.
Fig. 5 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 5: a processor (processor) 510, a communication Interface (Communications Interface) 520, a memory (memory) 530, and a communication bus 540, wherein the processor 510, the communication Interface 520, and the memory 530 communicate with each other via the communication bus 540. Processor 510 may invoke logic instructions in memory 530 to perform a preemptive-delay-based active-standby switching method comprising: the method comprises the steps that first equipment continuously monitors whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises the condition that the VRRP notification message is not monitored or the condition that the VRRP notification message sent by second equipment is monitored; determining that the first equipment is the main equipment in the VRRP group based on the monitoring result obtained at the first moment, and switching to the main equipment in the VRRP group at the second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
Furthermore, the logic instructions in the memory 530 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, and various media capable of storing program codes.
In another aspect, the present invention further provides a computer program product, where the computer program product includes a computer program, the computer program may be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, a computer is capable of executing the method for active/standby switching based on preemption delay provided by the above methods, where the method includes: the method comprises the steps that first equipment continuously monitors whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises the condition that the VRRP notification message is not monitored or the condition that the VRRP notification message sent by second equipment is monitored; determining that the first equipment is the main equipment in the VRRP group based on a monitoring result obtained at a first moment, and switching to the main equipment in the VRRP group at a second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented to execute a preemption delay-based active-standby switching method provided by the foregoing methods, where the method includes: the method comprises the steps that first equipment continuously monitors whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises the condition that the VRRP notification message is not monitored or the condition that the VRRP notification message sent by second equipment is monitored; determining that the first equipment is the main equipment in the VRRP group based on a monitoring result obtained at a first moment, and switching to the main equipment in the VRRP group at a second moment; the second moment is later than the first moment, the duration between the second moment and the first moment is preset delay duration, and the second equipment and the first equipment work in the same VRRP group.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment may be implemented by software plus a necessary general hardware platform, and may also be implemented by hardware. Based on the understanding, the above technical solutions substantially or otherwise contributing to the prior art may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the various embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (9)

1. A main/standby switching method based on preemption delay is characterized by comprising the following steps:
the method comprises the steps that first equipment continuously monitors whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises the condition that the VRRP notification message is not monitored or the condition that the VRRP notification message sent by second equipment is monitored;
determining that the first equipment is the main equipment in the VRRP group based on a monitoring result obtained at a first moment, and switching to the main equipment in the VRRP group at a second moment; the second moment is later than the first moment, the duration between the second moment and the first moment is preset delay duration, and the second equipment and the first equipment work in the same VRRP group.
2. The active-standby switching method based on preemption delay as claimed in claim 1, wherein the determining that the first device is a master device in a VRRP group based on the monitoring result obtained at the first time comprises at least one of:
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is higher than the priority indicated by the VRRP notification message of the second equipment, determining that the first equipment is a main equipment in a VRRP group;
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is equal to the priority indicated by the VRRP notification message of the second equipment and the node ID value of the first equipment is higher than the node ID value indicated by the VRRP notification message of the second equipment, determining that the first equipment is a master equipment in a VRRP group;
when the second device is the master device in the VRRP group at the third moment and the monitoring result includes that the VRRP notification message sent by the second device is not monitored, determining that the first device is the master device in the VRRP group; the third time is earlier than the first time.
3. The active-standby switching method based on preemption delay of claim 1, wherein before the first device continuously monitors whether a Virtual Routing Redundancy Protocol (VRRP) notification message exists, the method further comprises:
the first device joining the VRRP group;
the method further comprises the following steps:
and under the condition that the first equipment does not monitor a VRRP notification message after joining the VRRP group, the first equipment is switched to be the main equipment in the VRRP group.
4. The method of claim 3, wherein after the first device joins the VRRP group, the method further comprises:
the first device requests configuration synchronization and state information synchronization from other devices in the VRRP group.
5. The method for active-standby switching based on preemption delay as claimed in any one of claims 1-4, wherein after switching to a master device in the VRRP group, the method further comprises:
and sending the VRRP notification message of the first equipment to the standby equipment in the VRRP group.
6. The method for active-standby switching based on preemption delay as claimed in claim 1, further comprising at least one of:
under the condition that the monitoring result comprises that a VRRP notification message sent by second equipment is monitored, if the priority of the first equipment is lower than the priority indicated by the VRRP notification message of the second equipment, determining that the second equipment is a main equipment in a VRRP group;
and under the condition that the monitoring result comprises monitoring a VRRP notification message sent by second equipment, if the priority of the first equipment is equal to the priority indicated by the VRRP notification message of the second equipment and the node ID value of the first equipment is lower than the node ID value indicated by the VRRP notification message of the second equipment, determining that the second equipment is the main equipment in the VRRP group.
7. A master-slave switching device based on preemptive delay is characterized by comprising:
the monitoring module is used for continuously monitoring whether a Virtual Router Redundancy Protocol (VRRP) notification message exists or not to obtain a monitoring result, wherein the monitoring result comprises that the VRRP notification message is not monitored or the VRRP notification message sent by the second equipment is monitored;
the switching module is used for determining that the first equipment is the main equipment in the VRRP group based on the monitoring result obtained at the first moment and switching the first equipment to the main equipment in the VRRP group at the second moment; the second time is later than the first time, the time between the second time and the first time is a preset delay time, and the second equipment and the first equipment work in the same VRRP group.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement the preemptive delay based active-standby switching method according to any one of claims 1 to 6.
9. A non-transitory computer readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the preemptive delay based active/standby switching method according to any one of claims 1 to 6.
CN202310014993.7A 2023-01-06 2023-01-06 Main-standby switching method and device based on preemption delay and electronic equipment Active CN115801555B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310014993.7A CN115801555B (en) 2023-01-06 2023-01-06 Main-standby switching method and device based on preemption delay and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310014993.7A CN115801555B (en) 2023-01-06 2023-01-06 Main-standby switching method and device based on preemption delay and electronic equipment

Publications (2)

Publication Number Publication Date
CN115801555A true CN115801555A (en) 2023-03-14
CN115801555B CN115801555B (en) 2023-04-28

Family

ID=85428640

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310014993.7A Active CN115801555B (en) 2023-01-06 2023-01-06 Main-standby switching method and device based on preemption delay and electronic equipment

Country Status (1)

Country Link
CN (1) CN115801555B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1949767A (en) * 2005-10-11 2007-04-18 华为技术有限公司 Method for switching master-slave back-up route apparatus based on virtual router redundant protocol
CN105939254A (en) * 2016-06-07 2016-09-14 杭州迪普科技有限公司 Method and device for switching state of VRRP (Virtual Router Redundancy Protocol) backup set
CN106375210A (en) * 2016-08-31 2017-02-01 迈普通信技术股份有限公司 Method for realizing VRRP (Virtual Router Redundancy Protocol) downlink load balancing and route devices
WO2018188313A1 (en) * 2017-04-12 2018-10-18 中兴通讯股份有限公司 Method and apparatus for switching services in backup network
CN114221902A (en) * 2021-11-26 2022-03-22 上海弘积信息科技有限公司 Method for switching VRRP master and slave according to specified sequence

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1949767A (en) * 2005-10-11 2007-04-18 华为技术有限公司 Method for switching master-slave back-up route apparatus based on virtual router redundant protocol
CN105939254A (en) * 2016-06-07 2016-09-14 杭州迪普科技有限公司 Method and device for switching state of VRRP (Virtual Router Redundancy Protocol) backup set
CN106375210A (en) * 2016-08-31 2017-02-01 迈普通信技术股份有限公司 Method for realizing VRRP (Virtual Router Redundancy Protocol) downlink load balancing and route devices
WO2018188313A1 (en) * 2017-04-12 2018-10-18 中兴通讯股份有限公司 Method and apparatus for switching services in backup network
CN114221902A (en) * 2021-11-26 2022-03-22 上海弘积信息科技有限公司 Method for switching VRRP master and slave according to specified sequence

Also Published As

Publication number Publication date
CN115801555B (en) 2023-04-28

Similar Documents

Publication Publication Date Title
US7894335B2 (en) Redundant routing capabilities for a network node cluster
CN111698158B (en) Method and device for electing master equipment and machine-readable storage medium
US20060153068A1 (en) Systems and methods providing high availability for distributed systems
JP2006229967A (en) High-speed multicast path switching
US10911295B2 (en) Server apparatus, cluster system, cluster control method and program
CN104869057A (en) OpeFlow switch graceful restart processing method, device and OpeFlow controller
CN101841462B (en) Method, device and system for informing VRRP state information
EP3029883B1 (en) Network protection method and apparatus, next-ring node, and system
CN107911291A (en) VRRP routers switching method, router, VRRP active-standby switch system and storage medium
CN109495345B (en) BFD processing method and network equipment
CN112583708B (en) Connection relation control method and device and electronic equipment
CN110958151B (en) Keep-alive detection method, keep-alive detection device, node, storage medium and communication system
CN103200093A (en) Method and device for improving processing performance of multiple virtual router redundancy protocol (VRRP) back-up sets
US20200099609A1 (en) Method for determining link state, and device
CN111447101A (en) Link detection method and device, computer equipment and storage medium
CN102136947A (en) Method and device for processing link faults
CN105577444A (en) Wireless controller management method and wireless controller
CN111585797A (en) Ethernet link switching method, device, equipment and computer readable storage medium
CN101909006A (en) BFD (Bidirectional Forwarding Detection) message sending and receiving methods as well as device and communication system thereof
CN115801555B (en) Main-standby switching method and device based on preemption delay and electronic equipment
CN101645840B (en) Method, system and routing equipment for retransmitting message
CN113805788B (en) Distributed storage system and exception handling method and related device thereof
CN114585009A (en) UPF dual-computer hot standby switching method and device, electronic equipment and storage medium
JP2001168899A (en) Network system
CN112929266A (en) Method for switching VRRP (virtual router redundancy protocol) main and standby according to SSL (secure socket layer) accelerator card state

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
GR01 Patent grant
GR01 Patent grant