Dual-computer hot standby switching method and device, dual-computer hot standby service system and medium
By collecting server parameters of the dual-machine hot standby system in real time through the monitoring terminal, determining split-brain and calculating role weights, the abnormal issues caused by HA disconnection in the dual-machine hot standby system were resolved, enabling rapid role switching and improved system stability.
Patent Information
- Application Number
- CN202410965352.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-15
AI Technical Summary
In a dual-machine hot standby system, when the HA hot standby communication line is disconnected, the two machines compete for host resources, causing abnormalities in the hot standby dual-machine application.
By collecting server address and performance parameters in real time through the monitoring terminal, it can determine whether a split-brain phenomenon has occurred, calculate the server's role weight based on the performance parameters, determine the target role, and send it to the server to switch to the corresponding target role, including using virtual IP technology and master-slave negotiation mechanism.
It effectively solves the problem of abnormal hot standby dual-machine application, realizes millisecond-level fast switching of hot standby dual machines, and improves the reliability and availability of CAN_BUS-network access terminal.
Smart Images

Figure CN118784397A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of redundant communication technology, and in particular to a dual-machine hot standby switching method, device, dual-machine hot standby service system and medium. Background Art
[0002] CAN bus is a controller area network communication protocol, which has the characteristics of high reliability, strong real-time performance, and long transmission distance, and is widely used in automobiles, industrial automation, aerospace, medical and other fields. As an extended application device of CAN bus, CAN server plays an important role in various fields.
[0003] In industrial production, CAN devices are needed to control industrial production processes and monitor production environment parameters. If an abnormality occurs during the operation of the CAN device, production will be suspended, resulting in losses.
[0004] In order to avoid the above situation, the solution commonly adopted in the industry is to achieve communication redundancy by setting up a dual-machine hot standby device.
[0005] However, in the actual application of hot standby dual machines, when the HA (High Availability) hot standby communication line is disconnected, both machines consider themselves to be the host and compete for host resources, resulting in abnormal application of hot standby dual machines. Summary of the invention
[0006] In view of this, the embodiments of the present application provide a dual-machine hot standby switching method, device, dual-machine hot standby service system and medium, which can effectively solve the problem of abnormal hot standby dual-machine application, etc.
[0007] In a first aspect, an embodiment of the present application provides a dual-machine hot standby switching method, which is applied to a monitoring end of a dual-machine hot standby device, wherein the dual-machine hot standby device includes at least two servers; the method includes:
[0008] Receiving server parameters sent by each server; wherein the server parameters include address parameters and performance parameters;
[0009] Determining whether a split-brain phenomenon occurs in the dual-machine hot standby device according to the address parameter;
[0010] When the split-brain phenomenon is confirmed to occur, determining the role weight of each server according to the corresponding performance parameter;
[0011] The target role of the corresponding server is determined according to the role weight of each server respectively, and the target role is sent to the corresponding server so that the corresponding server switches to the corresponding target role; wherein the target role is a master or a slave.
[0012] In some embodiments, the address parameters include an IP address and a MAC address;
[0013] The determining whether a brain split occurs in the dual-machine hot standby device according to the address parameter includes:
[0014] Compare the IP address and the MAC address of each server respectively;
[0015] If the IP addresses of the servers are the same, and the MAC addresses of the servers are the same, it is determined that the split-brain phenomenon occurs in the dual-machine hot standby device.
[0016] In some embodiments, the performance parameters include CPU usage and memory occupancy;
[0017] Determining the role weight of each server according to the corresponding performance parameter includes:
[0018] If the CPU usage rate is greater than the first percentage and less than the second percentage, a negative incentive of a first score is given to the corresponding server;
[0019] If the CPU usage rate is greater than or equal to the second percentage, a negative incentive of a second score is given to the corresponding server;
[0020] If the memory usage rate is greater than the third percentage and less than the fourth percentage, a negative incentive of a first score is given to the corresponding server;
[0021] If the memory occupancy rate is greater than or equal to the fourth percentage, a negative incentive of a second score is given to the corresponding server;
[0022] The cumulative value of the negative incentives of each server is counted, and the corresponding role weight is determined according to the cumulative value of each server.
[0023] In some embodiments, the performance parameters also include the number of abnormal CAN communication frames and the boot time;
[0024] Before counting the cumulative value of the negative incentives of each server and determining the corresponding role weight according to the cumulative value of each server, the method further includes:
[0025] Comparing the boot time of each server, and giving a negative incentive of the first score to the server corresponding to the smallest boot time;
[0026] The number of abnormal CAN communication frames of each server is compared, and a negative incentive of the first score is given to the server corresponding to the largest number of abnormal CAN communication frames.
[0027] In some embodiments, determining the target role of the corresponding server according to the role weight of each server specifically includes:
[0028] Compare the role weights of the servers, determine the server corresponding to the smallest role weight as the master, and determine the server corresponding to the second smallest role weight as the slave;
[0029] If the role weights of the servers are equal, the power-on time in the performance parameters of the servers is compared, and the server corresponding to the largest power-on time is determined as the master, and the server corresponding to the second smallest power-on time is determined as the slave.
[0030] In some embodiments, each server includes: a data sending pin, a data receiving pin, a digital quantity input pin, and a digital quantity output pin;
[0031] The method further comprises:
[0032] If all servers are started at the same time, the MAC addresses of each server are compared. The server corresponding to the smallest MAC address is the master, otherwise it is determined to be a slave.
[0033] In some embodiments, the method further comprises:
[0034] If no handshake response is received between the servers within the first preset response time, the current host receives the restart command sent by the current slave through the digital output pin through the digital input pin, and the current host restarts according to the restart command. After the restart is completed, the master-slave negotiation is completed through the master-slave negotiation mechanism, and the role of the next slave is switched; at the same time, the current slave generates a virtual IP address using virtual IP technology to provide services for external network devices as the next host.
[0035] In a second aspect, an embodiment of the present application provides a dual-machine hot standby switching device, comprising:
[0036] A parameter receiving module, used to receive server parameters sent by each server; wherein the server parameters include address parameters and performance parameters;
[0037] A split-brain phenomenon detection module, used to determine whether a split-brain phenomenon occurs in the dual-machine hot standby device according to the address parameters;
[0038] A role weight calculation module, used to determine the role weight of each server according to the corresponding performance parameter when the split-brain phenomenon is confirmed to occur;
[0039] The target role determination module is used to determine the target role of the corresponding server according to the role weight of each server, and send the target role to the corresponding server so that the corresponding server switches to the corresponding target role; wherein the target role is a master or a slave.
[0040] In a third aspect, an embodiment of the present application provides a dual-machine hot standby service system, comprising: a first server, a second server and a monitoring terminal; the first server and the second server constitute a dual-machine hot standby device;
[0041] The first server and the second server are both used to send their own server parameters;
[0042] The monitoring end is used to implement a dual-machine hot standby switching method provided according to the first aspect of the present application;
[0043] The first server and the second server are both used to receive the target role sent by the monitoring terminal and switch to the corresponding target role.
[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program. When the computer program is executed on a processor, it implements a dual-machine hot standby switching method provided in the first aspect of the present application.
[0045] The embodiments of the present application have the following beneficial effects:
[0046] The present application determines whether a brain split occurs in the dual-machine hot standby device according to the address parameters; when the brain split is confirmed to occur, the role weight of each server is determined according to the corresponding performance parameters; the target role of the corresponding server is determined according to the role weight of each server, and the target role is sent to the corresponding server for the corresponding server to switch to the corresponding target role. In other words, the present application collects the operation logs (server parameters) of the dual machines in real time through the monitoring end, determines whether there is a situation of simultaneously occupying virtual IP addresses in the dual machines, and then calculates the role weight of each server, and finally forces one of the hosts to switch to a slave machine through UDP broadcast according to the role weight, so that the present application can effectively solve the problem of abnormal application of hot standby dual machines, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0048] Figure 1A structural block diagram of a dual-machine hot standby service system according to an embodiment of the present application is shown;
[0049] Figure 2 A framework / application scenario diagram of a dual-machine hot standby device according to an embodiment of the present application is shown;
[0050] Figure 3 A flow chart of a dual-machine hot standby switching method according to an embodiment of the present application is shown;
[0051] Figure 4 A flow chart showing a method for determining a split-brain phenomenon in a dual-machine hot standby switching method according to an embodiment of the present application is shown;
[0052] Figure 5 A flowchart showing a method for calculating role weights in a dual-machine hot standby switching method according to an embodiment of the present application is provided;
[0053] Figure 6 A structural schematic diagram of a dual-machine hot standby switching device according to an embodiment of the present application is shown.
[0054] Description of main component symbols:
[0055] 100 - first server; 200 - second server; 300 - monitoring terminal; 610 - parameter receiving module; 620 - split-brain phenomenon detection module; 630 - role weight calculation module; 640 - target role determination module. DETAILED DESCRIPTION
[0056] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0057] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0058] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0059] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0060] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0061] The dual-machine hot standby device includes a master and a slave. When there is no operational failure between the master and the slave, but the HA connection is disconnected, the slave receives the heartbeat of the master for a timeout, and the slave will think that the current master has failed, so the current slave will switch to the next master, causing a dual-master brain split, resulting in abnormal hot standby dual-machine application. Therefore, the present application proposes a dual-machine hot standby switching method, device, dual-machine hot standby service system and medium, which can effectively solve the problem of abnormal hot standby dual-machine application, etc.
[0062] This application provides a dual-machine hot standby service system, such as Figure 1 As shown, the system includes a first server 100 , a second server 200 and a monitoring terminal 300 .
[0063] The first server 100 and the second server 200 form a dual-machine hot standby device, and the first server 100 and the second server 200 are both CAN servers. Therefore, in the embodiment of the present application, the first server 100 is also called the first CAN server, and the second server 200 is also called the second CAN server. Figure 2As shown, it includes two CAN servers (CANServer (Master) and CANServer (Slave). Both CAN servers are connected to CAN devices (CAN Device) via a CAN bus (CAN BUS). The two CAN servers are connected via a HA (High Availability) hot standby communication line (HA Cable).
[0064] The first server 100 and the second server 200 are both used to send their own server parameters.
[0065] The monitoring terminal 300 is used to implement a dual-machine hot standby switching method according to an embodiment of the present application.
[0066] The first server 100 and the second server 200 are both used to receive the target role sent by the monitoring terminal 300 and switch to the corresponding target role.
[0067] Furthermore, the first server 100 and the second server 200 both include: TX (Transmit data pin), RX (Receive data pin), GND, DI (Digital Input pin) and DO (Digital Output pin). Among them, TX / RX are negotiation pins, mainly used for master-slave negotiation, and also used as master-slave heartbeat lines. DI / DO are control output / input pins, used for hardware reset of downtime equipment. GND is the ground wire.
[0068] The present application is particularly applicable to the field of automobile computer control systems and embedded industrial control local area network technology, wherein the first server 100 and the second server 200 are both CAN servers. In addition to preventing the occurrence of the dual-machine brain split problem, the dual-machine deployment method of the CAN server of the present application can achieve millisecond-level fast switching of hot standby dual machines when a single CAN server fails, greatly improving the reliability and availability of the CAN_BUS-network access terminal.
[0069] The dual-machine hot standby switching method is described below in conjunction with some specific embodiments.
[0070] Figure 3 A flow chart of a dual-machine hot standby switching method according to an embodiment of the present application is shown. Exemplarily, a monitoring terminal 300 applied to a dual-machine hot standby device is used to monitor the dual-machine hot standby device. The dual-machine hot standby device includes at least two servers, and the dual-machine hot standby switching method includes the following steps:
[0071] S100, receiving server parameters sent by each server; wherein the server parameters include address parameters and performance parameters.
[0072] The monitoring terminal 300 regularly collects the operation logs of each server in the dual-machine hot standby device, analyzes the operation status of each server, and records the server parameters of the current master and slave machines.
[0073] Each server sends its own role (host or slave) and operation logs such as server parameters to the monitoring terminal 300 at regular intervals through Ethernet broadcasting.
[0074] S200, determining whether a split-brain phenomenon occurs in the dual-machine hot standby device according to the address parameters.
[0075] Furthermore, the address parameters include an IP address and a MAC address. Each server sends its own IP address and MAC address to the monitoring terminal 300.
[0076] It can be understood that in step S200, the determination of whether a brain split occurs in the dual-machine hot standby device is performed based on the address parameter. Figure 4 As shown, including:
[0077] S210, respectively compare the IP address and the MAC address of each server. For example, the dual-machine hot standby device includes a first server 100 and a second server 200. Compare the IP address of the first server 100 with the IP address of the second server 200, and compare the MAC address of the first server 100 with the MAC address of the second server 200.
[0078] S220: If the IP addresses of the servers are the same and the MAC addresses of the servers are the same, it is determined that the split-brain phenomenon occurs in the dual-machine hot standby device. For example, if the IP address of the first server 100 is the same as the IP address of the second server 200, and the MAC address of the first server 100 is the same as the MAC address of the second server 200, it is confirmed that the split-brain phenomenon occurs in the dual-machine hot standby device.
[0079] S300, when the occurrence of the brain split phenomenon is confirmed, the role weight of each server is determined according to the corresponding performance parameters. Further, the performance parameters include CPU usage and memory occupancy. Each server sends its own role (host or slave), IP address, MAC address, CPU usage, memory occupancy, boot time and other operation logs to the monitoring terminal 300 in a regular manner through Ethernet broadcasting. The corresponding role weight is determined according to the performance parameters of each server.
[0080] In step S300, the role weight of each server is determined according to the corresponding performance parameter, such as Figure 5 As shown, including:
[0081] S310, if the CPU usage rate is greater than the first percentage and less than the second percentage, a negative incentive of the first score is given to the corresponding server. For example, the first percentage is 70%, the second percentage is 90%, and the first score is 1 point, which is not limited in this application. For example, if the CPU usage rate of the first server 100 is greater than the first percentage and less than the second percentage, a negative incentive of the first score is given to the first server. If the CPU usage rate of the second server 200 is less than the first percentage, no negative incentive is given to the second server.
[0082] S320: If the CPU usage rate is greater than or equal to the second percentage, a negative incentive of a second score is given to the corresponding server. For example, the second score is 4 points, which is not limited in this application.
[0083] S330: If the memory usage rate is greater than the third percentage and less than the fourth percentage, a negative incentive of a first score is given to the corresponding server.
[0084] S340: If the memory occupancy rate is greater than or equal to the fourth percentage, a negative incentive of a second score is given to the corresponding server.
[0085] S370, counting the cumulative value of the negative incentives of each server, and determining the corresponding role weight according to the cumulative value of each server.
[0086] Furthermore, the performance parameters also include the number of abnormal CAN communication frames and the boot time.
[0087] Before counting the cumulative value of negative incentives of each server and determining the corresponding role weight according to the cumulative value of each server, Figure 5 As shown, it also includes:
[0088] S350, comparing the power-on time of each server, and giving a negative incentive of the first score to the server corresponding to the smallest power-on time.
[0089] S360, comparing the number of abnormal CAN communication frames of each server, and giving a negative incentive of the first score to the server corresponding to the largest number of abnormal CAN communication frames.
[0090] Exemplarily, the following judgment conditions are used to score each CAN server:
[0091] a) If the CPU usage rate is >70% and less than 90%, 1 point will be deducted;
[0092] b) If the CPU usage is greater than 90%, 4 points;
[0093] c) If the memory usage is greater than 70% and less than 90%, 1 point will be deducted;
[0094] d) If the memory usage is greater than 90%, 4 points will be deducted;
[0095] e) If the boot time of the first server 100 is longer than that of the second server 200, 1 point will be deducted from the second server 200; similarly, if the boot time of the second server 200 is longer than that of the first server 100, 1 point will be deducted from the first server 100.
[0096] f) If the CAN abnormal frame statistics of the first server 100 are greater than those of the second server 200, 1 point will be deducted from the first server 100; similarly, if the CAN abnormal frame statistics of the second server 200 are greater than those of the first server 100, 1 point will be deducted from the second server 200.
[0097] g) Calculate the final total number of deductions for the first server 100 and the second server 200 respectively, and the total number of deductions is the role weight.
[0098] S400, determine the target role of the corresponding server according to the role weight of each server, and send the target role to the corresponding server, so that the corresponding server can switch to the corresponding target role. Wherein, the target role is a master or a slave. When the occurrence of the brain split phenomenon is confirmed, the monitoring terminal 300 immediately runs the brain split termination process, that is, determines the target role of the corresponding server according to the role weight of each server.
[0099] Further, determining the target role of the corresponding server according to the role weight of each server specifically includes:
[0100] S410, compare the role weights of the servers, determine that the server corresponding to the smallest role weight is the master, and determine that the server corresponding to the second smallest role weight is the slave. If the dual-machine hot standby device includes a first server 100 and a second server 200, if the role weight of the first server 100 is the smallest, that is, the deduction is the least, then the first server 100 is the master, and the second server 200 is the slave.
[0101] S420, if the role weights of the servers are equal, then the boot time in the performance parameters of the servers is compared, and the server corresponding to the longest boot time is determined as the master, and the server corresponding to the second smallest boot time is determined as the slave. For example, if the first server 100 has the longest boot time, the first server 100 is the master.
[0102] In step S400, the corresponding server switches to the corresponding target role, including:
[0103] If the target role of the first server 100 is a host, the first server 100 obtains its own current role; if the current role is a slave, the first server 100 generates a virtual IP address using virtual IP technology, and the first server 100 provides services for external network devices, and sends a restart command to the second server 200 in the dual-machine hot standby device. Virtual IP technology is implemented by relying on the ARP mechanism. ARP, or the Address Resolution Protocol, is part of the TCP / IP protocol stack. The core idea of ARP is that, in a local area network, before communicating with the other device, the MAC address (physical address) corresponding to the other device's IP is first queried in the network, and then the communication within the local area network is completed through the MAC address. By binding multiple IP addresses to one MAC address, two IPs for one network card can be achieved, that is, virtual IP technology.
[0104] If the target role of the first server 100 is a host, the first server 100 receives the restart command of the second server 200 and restarts according to the restart command.
[0105] Furthermore, each server includes: a data sending pin, a data receiving pin, a digital quantity input pin and a digital quantity output pin.
[0106] In one embodiment, the method further comprises:
[0107] If all servers are started at the same time, the MAC addresses of each server are compared, and the server corresponding to the smallest MAC address is the master, otherwise it is determined to be a slave. Exemplarily, the first server 100 and the second server 200 are started at the same time, and after the system is running, a master-slave negotiation will be performed, and the smaller MAC address has a higher priority. If the MAC of the first server 100 is smaller than that of the second server 200, the first server 100 will switch to the master and inform the second server 200, and the second server 200 will switch to the slave.
[0108] If the startup time of the first server 100 is earlier than the startup time of the second server 200, the first server 100 is determined to be the master and the second server 200 is the slave; if the startup time of the first server 100 is later than the startup time of the second server 200, the first server 100 is determined to be the slave and the second server 200 is the master. Specifically, the first server 100 is started first and the second server 200 is started later. After the system of the first server 100 is running, a master-slave negotiation will be performed. However, since the second server 200 is slow to start and has not yet entered the negotiation stage, the response to the negotiation request of the first server 100 will time out, and the first server 100 will switch to the master. When the system of the second server 200 is running and the master-slave negotiation is performed, the first server 100 will inform the second server 200 that it is already the master, and the second server 200 will switch to the slave.
[0109] Furthermore, the method further comprises:
[0110] If no handshake response is received between the servers within the first preset response time, the current host receives the restart command sent by the current slave through the digital output pin through the digital input pin, and the current host restarts according to the restart command. After the restart is completed, the master-slave negotiation is completed through the master-slave negotiation mechanism, and the role of the next slave is switched; at the same time, the current slave generates a virtual IP address using virtual IP technology to provide services for external network devices as the next host.
[0111] Specifically, after the dual-machine device is started, the master-slave negotiation is performed and the master and the standby are distinguished, the slave sends a heartbeat request frame to the master at a regular interval. After the host receives the heartbeat request frame, it immediately sends a heartbeat response frame. The slave receives the response frame, which proves that the host is alive.
[0112] If the slave sends a heartbeat request frame to the master and the master is down, the slave cannot receive a response frame from the master, which means the master is down. At this time, the slave will switch to the master and control the master to reset.
[0113] The CAN server that switches to the host role provides an IP address for external access by generating a VIP (virtual IP address). That is, when the CAN server switches from a slave to a host, it performs a hardware reset on the previous host, seizes the VIP, and updates the mac address table of the external network device by sending a free ARP. The new host continues to use the VIP to provide a unified IP access address to the outside world.
[0114] The dual-machine deployment method of the CAN server of the present application can realize millisecond-level fast switching of the hot standby dual machines when a single CAN server fails, greatly improving the reliability and availability of the CAN_BUS-network access terminal.
[0115] This application collects the operation logs and ARP of the two machines in real time through the monitoring terminal 300, determines whether there is a situation of simultaneous VIP preemption in the two machines, then scores and calculates the role weight of the CAN server, and finally forces one of the hosts to switch to a slave machine through UDP broadcast according to the role weight.
[0116] This application can realize host crash recovery. When the host crashes and the slave switches to the host, the previous host can be reset through the DO signal output pin.
[0117] Figure 6 A schematic diagram of the structure of a dual-machine hot standby switching device according to an embodiment of the present application is shown. Exemplarily, the dual-machine hot standby switching device includes: a parameter receiving module 610, a split-brain phenomenon detection module 620, a role weight calculation module 630 and a target role determination module 640.
[0118] The parameter receiving module 610 is used to receive the server parameters sent by each server; wherein the server parameters include address parameters and performance parameters;
[0119] A split-brain phenomenon detection module 620, used to determine whether a split-brain phenomenon occurs in the dual-machine hot standby device according to the address parameters;
[0120] A role weight calculation module 630 is used to determine the role weight of each server according to the corresponding performance parameter when the split-brain phenomenon is confirmed to occur;
[0121] The target role determination module 640 is used to determine the target role of the corresponding server according to the role weight of each server, and send the target role to the corresponding server so that the corresponding server switches to the corresponding target role; wherein the target role is a master or a slave.
[0122] It can be understood that the device of this embodiment corresponds to the dual-machine hot standby switching method of the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0123] The present application also provides a terminal device, which exemplarily includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the terminal device to execute the functions of each module in the above-mentioned dual-machine hot standby switching method or the above-mentioned dual-machine hot standby switching device. Preferably, the terminal device is a monitoring terminal 300.
[0124] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0125] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0126] The present application also provides a computer-readable storage medium for storing the computer program used in the above-mentioned terminal device. For example, the computer-readable storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0127] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0128] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0129] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0130] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A dual-machine hot standby switching method, characterized in that: The method is applied to a monitoring end of a dual-machine hot standby device, wherein the dual-machine hot standby device includes at least two servers; and the method includes: Receiving server parameters sent by each server; wherein the server parameters include address parameters and performance parameters; Determining whether a split-brain phenomenon occurs in the dual-machine hot standby device according to the address parameter; When the split-brain phenomenon is confirmed to occur, determining the role weight of each server according to the corresponding performance parameter; The target role of the corresponding server is determined according to the role weight of each server respectively, and the target role is sent to the corresponding server so that the corresponding server switches to the corresponding target role; wherein the target role is a master or a slave.
2. The dual-machine hot standby switching method according to claim 1, characterized in that: The address parameters include IP address and MAC address; The determining whether a brain split occurs in the dual-machine hot standby device according to the address parameter includes: Compare the IP address and the MAC address of each server respectively; If the IP addresses of the servers are the same, and the MAC addresses of the servers are the same, it is determined that the split-brain phenomenon occurs in the dual-machine hot standby device.
3. The dual-machine hot standby switching method according to claim 1, characterized in that: The performance parameters include CPU usage and memory occupancy; Determining the role weight of each server according to the corresponding performance parameter includes: If the CPU usage rate is greater than the first percentage and less than the second percentage, a negative incentive of a first score is given to the corresponding server; If the CPU usage rate is greater than or equal to the second percentage, a negative incentive of a second score is given to the corresponding server; If the memory usage rate is greater than the third percentage and less than the fourth percentage, a negative incentive of a first score is given to the corresponding server; If the memory occupancy rate is greater than or equal to the fourth percentage, a negative incentive of a second score is given to the corresponding server; The cumulative value of the negative incentives of each server is counted, and the corresponding role weight is determined according to the cumulative value of each server.
4. The dual-machine hot standby switching method according to claim 3 is characterized in that: The performance parameters also include the number of abnormal CAN communication frames and the boot time; Before counting the cumulative value of the negative incentives of each server and determining the corresponding role weight according to the cumulative value of each server, the method further includes: Comparing the boot time of each server, and giving a negative incentive of the first score to the server corresponding to the smallest boot time; The number of abnormal CAN communication frames of each server is compared, and a negative incentive of the first score is given to the server corresponding to the largest number of abnormal CAN communication frames.
5. The dual-machine hot standby switching method according to claim 1, characterized in that: Determining the target role of the corresponding server according to the role weight of each server specifically includes: Compare the role weights of the servers, determine the server corresponding to the smallest role weight as the master, and determine the server corresponding to the second smallest role weight as the slave; If the role weights of the servers are equal, the power-on time in the performance parameters of the servers is compared, and the server corresponding to the largest power-on time is determined as the master, and the server corresponding to the second smallest power-on time is determined as the slave.
6. The dual-machine hot standby switching method according to any one of claims 1 to 5, characterized in that: Each server includes: a data sending pin, a data receiving pin, a digital quantity input pin and a digital quantity output pin; The method further comprises: If all servers are started at the same time, the MAC addresses of each server are compared. The server corresponding to the smallest MAC address is the master, otherwise it is determined to be a slave.
7. The dual-machine hot standby switching method according to claim 6, characterized in that: The method further comprises: If no handshake response is received between the servers within the first preset response time, the current host receives the restart command sent by the current slave through the digital output pin through the digital input pin, and the current host restarts according to the restart command. After the restart is completed, the master-slave negotiation is completed through the master-slave negotiation mechanism, and the role of the next slave is switched; at the same time, the current slave generates a virtual IP address using virtual IP technology to provide services for external network devices as the next host.
8. A dual-machine hot standby switching device, characterized in that: include: A parameter receiving module, used to receive server parameters sent by each server; wherein the server parameters include address parameters and performance parameters; A split-brain phenomenon detection module, used to determine whether a split-brain phenomenon occurs in the dual-machine hot standby device according to the address parameters; A role weight calculation module, used to determine the role weight of each server according to the corresponding performance parameter when the split-brain phenomenon is confirmed to occur; The target role determination module is used to determine the target role of the corresponding server according to the role weight of each server, and send the target role to the corresponding server so that the corresponding server switches to the corresponding target role; wherein the target role is a master or a slave.
9. A dual-machine hot standby service system, characterized in that: include: A first server, a second server and a monitoring terminal; the first server and the second server constitute a dual-machine hot standby device; The first server and the second server are both used to send their own server parameters; The monitoring end is used to implement the dual-machine hot standby switching method according to any one of claims 1 to 7; The first server and the second server are both used to receive the target role sent by the monitoring terminal and switch to the corresponding target role.
10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed on a processor, implements the dual-machine hot standby switching method according to any one of claims 1-7.
Citation Information
Cited By
Main and standby system switching method, device and system
CN119781276A
