Dual-computer high availability implementation method, device, equipment and medium

The Keepalived service tool automatically manages the status of dual-machine cluster nodes, solving high availability and stability issues caused by insufficient hardware resources, improving operation and maintenance efficiency, and ensuring system stability and reliability.

CN116684244BActive Publication Date: 2025-10-10SHENZHEN WEIZHONG TAXATION INFORMATION SERVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310709732.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-15
Publication Date
2025-10-10
Estimated Expiration
2043-06-15

AI Technical Summary

Technical Problem

High availability and stability issues in a dual-machine cluster due to insufficient hardware resources, especially when a service node fails, resource utilization is reduced and the available nodes have too many tasks to handle and cannot meet high concurrency requirements.

Method used

Through the Keepalived service tool, the current node status of the local service node is obtained, and the corresponding preset scripts are automatically selected and executed, including scripts for the master node status, backup node status, and Keepalived service hang status, and corresponding configurations and operations are performed, such as stopping the loopback address, adding or clearing virtual server rules, and suppressing ARP broadcasts.

Benefits of technology

It improves the operation and maintenance efficiency of the dual-machine cluster, ensures high availability and stability, avoids system crashes and data loss, reduces operation and maintenance costs, simplifies the operation and maintenance process, and shortens fault recovery time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116684244B_ABST
    Figure CN116684244B_ABST
Patent Text Reader

Abstract

The application discloses a dual-computer high-availability implementation method and device, equipment and a medium, relates to the technical field of computers, and is applied to a Keepalived service tool of any service node in a dual-computer cluster, and comprises the following steps: acquiring a current node state of a local service node; determining a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts comprise a first preset script corresponding to a node state being a master node state, a second preset script corresponding to the node state being a backup node state, and a third preset script corresponding to the node state being a Keepalived service hanging state; and executing the current script. When the node state is the master node state, the backup node state and the Keepalived service hanging state respectively, the corresponding current script is automatically executed, so that the operation and maintenance of the local service node is implemented, and the high availability and stability of the dual-computer cluster can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for implementing dual-machine high availability. Background Art

[0002] Insufficient server hardware resources due to insufficient budget or incorrect project planning in the early stages. That is, a dual-machine cluster contains two service nodes. When one of the service nodes fails, only one service node is available. As a result, resource utilization is significantly reduced, and the service node in the available state needs to face an excessive number of requests and too many processing tasks, which cannot meet the high concurrency requirements of the production environment.

[0003] In summary, how to ensure high availability and stability of a dual-machine cluster is an issue to be solved in this field. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a method, apparatus, device, and medium for implementing dual-machine high availability, which can ensure high availability and stability of a dual-machine cluster. The specific solution is as follows:

[0005] In a first aspect, the present application discloses a method for implementing dual-machine high availability, which is applied to a Keepalived service tool of any service node in a dual-machine cluster, including:

[0006] Get the current node status of the local service node;

[0007] Determine a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state;

[0008] Executes the current script.

[0009] Optionally, before obtaining the current node status of the local service node, the method further includes:

[0010] Install the Keepalived service tool on each service node in the dual-machine cluster, and configure the corresponding global definition block, vrrp instance definition block, and virtual service setting block.

[0011] Optionally, executing the current script includes:

[0012] If the current node state is the master node state, executing the first preset script;

[0013] Accordingly, executing the first preset script includes:

[0014] Detecting whether a corresponding loopback address exists in the local service node;

[0015] If it exists, stop the loopback address and add a preset Linux virtual server rule to the local service node.

[0016] Optionally, executing the current script includes:

[0017] If the current node state is the backup node state, executing the second preset script;

[0018] Accordingly, executing the second preset script includes:

[0019] Clean up the preset Linux virtual server rules;

[0020] Detect whether the corresponding loopback address exists in the local service node; if not, add the loopback address to the local service node and suppress address resolution protocol broadcast.

[0021] Optionally, after suppressing the address resolution protocol broadcast, the method further includes:

[0022] Detecting whether the preset Linux virtual server rule exists in the local service node;

[0023] If so, the preset Linux virtual server rules are cleaned up again.

[0024] Optionally, executing the current script includes:

[0025] If the current node status is that the Keepalived service is down, execute the third preset script;

[0026] Accordingly, executing the third preset script includes:

[0027] Detecting whether a corresponding loopback address exists in the local service node;

[0028] If not, add the loopback address to the local service node.

[0029] Optionally, after adding the loopback address to the local service node, the method further includes:

[0030] Suppress Address Resolution Protocol broadcasts.

[0031] In a second aspect, the present application provides a dual-machine high-availability implementation device, which is applied to a Keepalived service tool of any service node in a dual-machine cluster, including:

[0032] Node status acquisition module, used to obtain the current node status of the local service node;

[0033] A script determination module is used to determine a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state;

[0034] The script execution module is used to execute the current script.

[0035] In a third aspect, the present application discloses an electronic device, comprising:

[0036] Memory, used to store computer programs;

[0037] The processor is used to execute the computer program to implement the steps of the aforementioned dual-machine high availability implementation method.

[0038] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned dual-machine high availability implementation method are implemented.

[0039] The beneficial effects of the present application are as follows: the present application is applied to the Keepalived service tool of any service node in a dual-machine cluster, including: obtaining the current node status of the local service node; determining the current script corresponding to the current node status from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node status being the master node status, a second preset script corresponding to the node status being the backup node status, and a third preset script corresponding to the node status being the Keepalived service down state; and executing the current script. It can be seen that the present application automatically determines the current script corresponding to the current node status when service resources are scarce, that is, when the node status is the master node status, the backup node status, and the Keepalived service down state, the corresponding current script is automatically executed to realize the operation and maintenance of the local service node, improve the operation and maintenance efficiency, and thereby ensure the high availability and stability of the dual-machine cluster. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.

[0041] Figure 1 This is a flow chart of a dual-machine high availability implementation method disclosed in this application;

[0042] Figure 2 This is a specific script execution diagram disclosed in this application;

[0043] Figure 3 This is a flow chart of a specific dual-machine high availability implementation method disclosed in this application;

[0044] Figure 4 This is a flow chart of a specific dual-machine high availability implementation method disclosed in this application;

[0045] Figure 5 This is a flow chart of a specific dual-machine high availability implementation method disclosed in this application;

[0046] Figure 6 This is a schematic diagram of the structure of a dual-machine high-availability implementation device disclosed in this application;

[0047] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0049] Insufficient server hardware resources due to insufficient budget or incorrect project planning in the early stages. That is, a dual-machine cluster contains two service nodes. When one of the service nodes fails, only one service node is available. As a result, resource utilization is significantly reduced, and the service node in the available state needs to face an excessive number of requests and too many processing tasks, which cannot meet the high concurrency requirements of the production environment.

[0050] To this end, this application provides a dual-machine high-availability implementation solution that can ensure the high availability and stability of the dual-machine cluster.

[0051] See also Figure 1As shown, the embodiment of the present application discloses a method for implementing dual-machine high availability, which is applied to the Keepalived service tool of any service node in a dual-machine cluster, including:

[0052] Step S11: Acquire the current node status of the local service node.

[0053] In this embodiment, before obtaining the current node status of the local service node, the method further includes: installing the Keepalived service tool on each service node in the dual-machine cluster and configuring the corresponding global definition block, VRRP instance definition block, and virtual service setting block. The Keepalived service tool needs to be installed and configured in each service node in advance. It is understandable that during installation and configuration, the node status of the service node is either the primary node status or the backup node status, that is, the service node is the primary node or the backup node.

[0054] When on the master node, the Keepalived configuration is as follows:

[0055]

[0056]

[0057]

[0058] When on the backup node, the Keepalived configuration is as follows: global_defs{

[0059] router_id NodeB

[0060] }

[0061] vrrp_instance web{

[0062] state BACKUP interface ens33

[0063] virtual_router_id 51

[0064] priority 170

[0065] virtual_ipaddress{ 192.168.203.140

[0067] }

[0068] notify_backup" / usr / local / src / notify_node.sh b"

[0069] notify_master" / usr / local / src / notify_node.sh m"

[0070] notify_stop" / usr / local / src / notify_node.sh s"

[0071] }

[0072] virtual_server 192.168.203.140 80{

[0073] delay_loop 6

[0074] lvs_sched wrr

[0075] lvs_method DR

[0076] protocol TCP real_server 192.168.203.130 80{

[0077] weight 3

[0078] TCP_CHECK{

[0079] connect_ip 192.168.203.130

[0080] connect_port 80

[0081] }

[0082] }

[0083] real_server 192.168.203.131 80{

[0084] weight 3

[0085] TCP_CHECK{

[0086] connect_ip 192.168.203.131

[0087] connect_port 80

[0088] }

[0089] }

[0090] }

[0091] It should be noted that the configuration of Keepalived includes the global define block, the vrrp instance definition block, and the virtual service setting block. Among them, the global define block contains the LVS (Linux Virtual Server) load balancer identifier, the vrrp instance definition block needs to set the master and slave types, virtual routing identifier (master and slave are consistent), and VIP address (Virtual IP address). The virtual service setting block contains the ib_algo scheduling algorithm and the ib_kind four forwarding modes; the master and slave configuration files are different in three places: the load balancer identifier router_id is different, the instance state state is different, and the priority is different.

[0092] Before obtaining the current node status of the local service node, you also need to create a first preset script notify_master corresponding to the node status as the master node, a second preset script notify_backup corresponding to the node status as the backup node, and a third preset script notify_stop corresponding to the node status as the Keepalived service hang state, so that the subsequent Keepalived service tool can automatically determine and execute the corresponding scripts.

[0093] Step S12: Determine a current script corresponding to the current node state from multiple preset scripts; wherein, the multiple preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state.

[0094] It is understandable that the current node state is any of the master node state, backup node state, and Keepalived service hang state, so it is necessary to filter out the corresponding current script from multiple preset scripts according to the current node state.

[0095] Step S13: Execute the current script.

[0096] In this embodiment, for example Figure 2 A specific script execution diagram is shown. If the current node status is the master node status, the first preset script is executed; if the current node status is the backup node status, the second preset script is executed; if the current node status is the Keepalived service down status, the third preset script is executed.

[0097] The beneficial effects of the present application are as follows: the present application is applied to the Keepalived service tool of any service node in a dual-machine cluster, including: obtaining the current node status of the local service node; determining the current script corresponding to the current node status from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node status being the master node status, a second preset script corresponding to the node status being the backup node status, and a third preset script corresponding to the node status being the Keepalived service down state; and executing the current script. It can be seen that the present application automatically determines the current script corresponding to the current node status when service resources are scarce, that is, when the node status is the master node status, the backup node status, and the Keepalived service down state, the corresponding current script is automatically executed to achieve operation and maintenance of the local service node, improve operation and maintenance efficiency, and thereby ensure the high availability and stability of the dual-machine cluster.

[0098] See also Figure 3 As shown, the embodiment of the present application discloses a specific dual-machine high availability implementation method, which is applied to the Keepalived service tool of any service node in a dual-machine cluster, including:

[0099] Step S21: Acquire the current node status of the local service node.

[0100] Step S22: Determine a current script corresponding to the current node state from multiple preset scripts; wherein the multiple preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state.

[0101] Step S23: If the current node state is the master node state, execute the first preset script.

[0102] In this embodiment, the execution of the first preset script includes: detecting whether a corresponding loopback address exists in the local service node; if so, stopping the loopback address and adding a preset Linux virtual server rule to the local service node. If a corresponding loopback address lo:0 exists in the local service node, the loopback address lo:0 is stopped because when the node state is master, the VIP address already exists in the local service node. The loopback address lo:0 and the VIP are the same, which will cause a conflict, so the loopback address lo:0 must be stopped; adding LVS rules (preset Linux virtual server rules) can cluster both backend applications, otherwise only the scheduling itself can be done.

[0103] It can be seen that this application ensures that the system can run stably even when resources are scarce by applying dual-machine clusters and high-availability technology, that is, it improves the stability of the dual-machine cluster, avoids problems such as system crashes or data loss due to insufficient resources, reduces operation and maintenance costs, simplifies operation and maintenance processes, shortens the system's fault recovery time, and thus improves operation and maintenance efficiency and benefits.

[0104] See also Figure 4 As shown, the embodiment of the present application discloses a specific dual-machine high availability implementation method, which is applied to the Keepalived service tool of any service node in a dual-machine cluster, including:

[0105] Step S31: Acquire the current node status of the local service node.

[0106] Step S32: Determine a current script corresponding to the current node state from multiple preset scripts; wherein the multiple preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state.

[0107] Step S33: If the current node status is the backup node status, execute the second preset script.

[0108] In this embodiment, executing the second preset script includes: clearing the preset Linux virtual server rules; detecting whether the corresponding loopback address exists in the local service node; if not, adding the loopback address to the local service node and suppressing address resolution protocol broadcast. The execution process of the second preset script is as follows:

[0109] 1) Automatically clean up LVS rules: When the master uses the round-robin algorithm, it forwards approximately 50% of packets from the master to the backup. Due to the LVS configuration rules, the backup will then perform load balancing on these packets and send them back to the master, creating a vicious cycle. Over time, not only will the backup server be unable to process connections properly, but it may also crash. Therefore, it is necessary to clean up the LVS rules.

[0110] 2) Detect and add the lo:0 loopback address: Because the DR (Direct Routing) mode forwards data packets through the MAC address rewriting mechanism, the client sends a request to the load balancer (Keepalived). The client's IP is called the source IP, abbreviated as CIP, and the target IP is the load balancer's IP, abbreviated as VIP. When the client request reaches the load balancer, it will determine that the target IP of the data packet is the local VIP, re-encapsulate the data packet, modify the source MAC address to the MAC address of the load balancer, and modify the target MAC address to the MAC address of the back-end application. The source IP address and the target IP address remain unchanged, and then the data packet is sent to the back-end application. The back-end application server determines that the MAC address of the request message is its own MAC address and receives this message. The response data packet re-encapsulates the message (source IP address is VIP, target IP is CIP), and transmits the response message directly to the client through the lo:0 loopback address;

[0111] 3) Suppressing ARP (Address Resolution Protocol) broadcasts: When Keepalived uses DR mode for load balancing, it uses VIP addresses for load balancing. Each network interface has a unique MAC address that identifies it. When a device needs to send data to an IP address, it first searches its local ARP cache for the MAC address corresponding to that IP address. If the MAC address is found, the data is sent directly. If not, it sends an ARP broadcast request for the MAC address corresponding to the IP address. Other devices respond to this ARP broadcast request and send their own MAC address to the requesting device. This establishes a mapping between the MAC address and the IP address, allowing the devices to send data. When using Keepalived for load balancing, if every node sends an ARP broadcast request for the MAC address of the VIP address, it will cause conflicts in the network, as a VIP address can only be used by one node. To avoid these conflicts, ARP broadcast requests are suppressed when a node becomes a standby node to prevent other devices from responding to the ARP broadcast request. This ensures that the VIP address is only used by the primary load balancing node, ensuring network operation and security.

[0112] In this embodiment, after suppressing the address resolution protocol broadcast, the method further includes: detecting whether the preset Linux virtual server rule exists in the local service node; if so, clearing the preset Linux virtual server rule again. Furthermore, to ensure that the LVS rules of Keepalived are completely cleared after a shutdown and restart, the LVS rules need to be cleared again.

[0113] It can be seen that when service resources are scarce, the corresponding preset scripts are automatically executed to improve operation and maintenance efficiency. By solving the timeout problem of scheduling backend nodes, the system's response speed and data processing efficiency are guaranteed, which to a certain extent improves the availability of the dual-machine cluster and meets users' needs for system stability and reliability.

[0114] See also Figure 5 As shown, the embodiment of the present application discloses a specific dual-machine high availability implementation method, which is applied to the Keepalived service tool of any service node in a dual-machine cluster, including:

[0115] Step S41: Acquire the current node status of the local service node.

[0116] Step S42: Determine a current script corresponding to the current node state from multiple preset scripts; wherein the multiple preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state.

[0117] Step S43: If the current node state is the Keepalived service down state, execute the third preset script.

[0118] In this embodiment, executing the third preset script includes: detecting whether a corresponding loopback address exists in the local service node; if not, adding the loopback address to the local service node. When the Keepalived service of the service node is down, the third preset script (notify_stop script) will detect and add the lo:0 loopback address. When the Keepalived service is down or abnormal, the application response message needs to be directly transmitted to the client through the lo:0 loopback address, so the lo:0 loopback address needs to be added.

[0119] In this embodiment, after adding the loopback address to the local service node, the method further includes: suppressing address resolution protocol broadcast. In order to avoid causing network conflicts, address resolution protocol broadcast may also be suppressed.

[0120] It can be seen that this application uses preset scripts and Keepalived notification mechanism to automatically solve the scheduling timeout problem, reduce the need for manual intervention, improve work efficiency and benefits, simplify the operation and maintenance process, shorten the system's fault recovery time, and thus improve operation and maintenance efficiency.

[0121] See also Figure 6As shown, the embodiment of the present application discloses a dual-machine high availability implementation device, which is applied to the Keepalived service tool of any service node in a dual-machine cluster, including:

[0122] The node status acquisition module 11 is used to obtain the current node status of the local service node;

[0123] The script determination module 12 is configured to determine a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state;

[0124] The script execution module 13 is used to execute the current script.

[0125] The beneficial effects of the present application are as follows: the present application is applied to the Keepalived service tool of any service node in a dual-machine cluster, including: obtaining the current node status of the local service node; determining the current script corresponding to the current node status from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node status being the master node status, a second preset script corresponding to the node status being the backup node status, and a third preset script corresponding to the node status being the Keepalived service down state; and executing the current script. It can be seen that the present application automatically determines the current script corresponding to the current node status when service resources are scarce, that is, when the node status is the master node status, the backup node status, and the Keepalived service down state, the corresponding current script is automatically executed to realize the operation and maintenance of the local service node, improve the operation and maintenance efficiency, and thereby ensure the high availability and stability of the dual-machine cluster.

[0126] Furthermore, an embodiment of the present application also provides an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.

[0127] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the following steps:

[0128] Get the current node status of the local service node;

[0129] Determine a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state;

[0130] Executes the current script.

[0131] In some specific implementations, the processor may implement the following steps by executing the computer program stored in the memory:

[0132] Install the Keepalived service tool on each service node in the dual-machine cluster, and configure the corresponding global definition block, vrrp instance definition block, and virtual service setting block.

[0133] In some specific implementations, the processor may implement the following steps by executing the computer program stored in the memory:

[0134] If the current node state is the master node state, executing the first preset script;

[0135] Accordingly, executing the first preset script includes:

[0136] Detecting whether a corresponding loopback address exists in the local service node;

[0137] If it exists, stop the loopback address and add a preset Linux virtual server rule to the local service node.

[0138] In some specific implementations, the processor may implement the following steps by executing the computer program stored in the memory:

[0139] If the current node state is the backup node state, executing the second preset script;

[0140] Accordingly, executing the second preset script includes:

[0141] Clean up the preset Linux virtual server rules;

[0142] Detect whether the corresponding loopback address exists in the local service node; if not, add the loopback address to the local service node and suppress address resolution protocol broadcast.

[0143] In some specific implementations, the processor may implement the following steps by executing the computer program stored in the memory:

[0144] Detecting whether the preset Linux virtual server rule exists in the local service node;

[0145] If so, the preset Linux virtual server rules are cleaned up again.

[0146] In some specific implementations, the processor may implement the following steps by executing the computer program stored in the memory:

[0147] If the current node status is that the Keepalived service is down, execute the third preset script;

[0148] Accordingly, executing the third preset script includes:

[0149] Detecting whether a corresponding loopback address exists in the local service node;

[0150] If not, add the loopback address to the local service node.

[0151] In some specific embodiments, the processor may further include the following steps by executing the computer program stored in the memory:

[0152] Suppress Address Resolution Protocol broadcasts.

[0153] In this embodiment, the power supply 23 is used to provide operating voltage for various hardware devices on the electronic device; the communication interface 24 can create a data transmission channel between the electronic device and external devices. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0154] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0155] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.

[0156] Among them, the operating system 221 is used to manage and control the various hardware devices and computer programs 222 on the electronic device to enable the processor 21 to calculate and process the massive data 223 in the memory 22. It can be Windows, Unix, Linux, etc. In addition to including computer programs that can be used to implement the dual-machine high-availability implementation method performed by the electronic device disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks. In addition to including data transmitted by external devices received by the electronic device, the data 223 can also include data collected by its own input and output interface 25.

[0157] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the method steps performed in the dual-machine high availability implementation process disclosed in any of the aforementioned embodiments are implemented.

[0158] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0159] The above is a detailed introduction to the dual-machine high availability implementation method, device, equipment and medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A method for implementing dual-machine high availability, characterized in that: Keepalived service tools applied to any service node in a dual-machine cluster include: Get the current node status of the local service node; Determine a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state; Executes the current script.

2. The method for realizing dual-machine high availability according to claim 1, characterized in that: Before obtaining the current node status of the local service node, the method further includes: Install the Keepalived service tool on each service node in the dual-machine cluster, and configure the corresponding global definition block, vrrp instance definition block, and virtual service setting block.

3. The method for realizing dual-machine high availability according to claim 1, characterized in that: The executing the current script includes: If the current node state is the master node state, executing the first preset script; Accordingly, executing the first preset script includes: Detecting whether a corresponding loopback address exists in the local service node; If it exists, stop the loopback address and add a preset Linux virtual server rule to the local service node.

4. The method for realizing dual-machine high availability according to claim 1, wherein: The executing the current script includes: If the current node state is the backup node state, executing the second preset script; Accordingly, executing the second preset script includes: Clean up the preset Linux virtual server rules; Detect whether the corresponding loopback address exists in the local service node; if not, add the loopback address to the local service node and suppress address resolution protocol broadcast.

5. The method for realizing dual-machine high availability according to claim 4, characterized in that: After suppressing the address resolution protocol broadcast, the method further includes: Detecting whether the preset Linux virtual server rule exists in the local service node; If so, the preset Linux virtual server rules are cleaned up again.

6. The method for realizing dual-machine high availability according to claim 1, characterized in that: The executing the current script includes: If the current node status is that the Keepalived service is down, execute the third preset script; Accordingly, executing the third preset script includes: Detecting whether a corresponding loopback address exists in the local service node; If not, add the loopback address to the local service node.

7. The method for realizing dual-machine high availability according to claim 6, characterized in that: After adding the loopback address to the local service node, the method further includes: Suppress Address Resolution Protocol broadcasts.

8. A dual-machine high availability implementation device, characterized in that: Keepalived service tools applied to any service node in a dual-machine cluster include: Node status acquisition module, used to obtain the current node status of the local service node; A script determination module is used to determine a current script corresponding to the current node state from a plurality of preset scripts; wherein the plurality of preset scripts include a first preset script corresponding to the node state being the master node state, a second preset script corresponding to the node state being the backup node state, and a third preset script corresponding to the node state being the Keepalived service down state; The script execution module is used to execute the current script.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the steps of the dual-machine high availability implementation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that Used to store computer programs; wherein, when the computer program is executed by a processor, the steps of the dual-machine high availability implementation method as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • RabbitMQ network partition recovery method and system

    CN109286529A

  • SSLVPN high availability method and system

    CN116094903A