Two-stage dual-network card redundancy method based on Linux system
Through the second-level redundancy method based on bond function, the combination of first-level network card redundancy and manual automatic hosts, the reliability problem of dual-network card redundancy technology in Linux systems is solved when the main and spare lines fail, and the continuity of data transmission and system reliability are achieved, meeting the needs of multi-scenario applications.
Patent Information
- Application Number
- CN202510315519.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-07-18
AI Technical Summary
The single dual network card redundancy technology of the existing Linux system is insufficient in reliability when the main and standby lines fail at the same time. The conventional main and standby autonomous switching strategy cannot meet the needs of multiple scenarios, resulting in network service interruption and insufficient reliability when the main and standby competition.
The first-level network card redundancy based on bond function is adopted. The master and backup machine receive data at the same time but only sends it by the host. Combined with the switching method between the manual host and the automatic host, the secondary redundancy is achieved through heartbeat information monitoring, ensuring that only one network port works effectively at the same time, and a judgment strategy for online duration and device number is designed to solve the competition problem.
It realizes the continuity of data transmission during the main and standby switching process, meets flexible application needs, improves system reliability, and ensures that reliable backup means are provided in the event of emergency failures, with a response time of ms level.
Smart Images

Figure CN120342848A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and particularly to a two-stage dual-network card redundancy method based on the Linux system. Background Art
[0002] With the development of the Internet, the Linux system has received support from software enthusiasts, organizations, and companies around the world. In addition to maintaining a strong development momentum in the server field, it has also made great progress in personal computers and embedded systems. Users can not only intuitively understand the implementation mechanism of this operating system, but also modify and improve Linux according to their own needs to maximize its adaptation to user needs.
[0003] In order to improve the reliability of network connections, generally, network redundancy technologies for servers are adopted. Multiple network cards are configured on each server, and multiple network cards are virtualized into one network card through network redundancy technologies to provide network services. When a certain network card among multiple network cards fails, the normal network card will be promptly used to replace the faulty network card to ensure that the network services of the server are not interrupted.
[0004] However, the reliability of a single dual-network card redundancy technology is insufficient and cannot meet the situation where the primary and standby lines fail simultaneously in special cases. Moreover, the conventional primary and standby automatic switching strategy cannot meet the usage requirements of multiple scenarios, and the reliability is insufficient in the event of primary and standby competition, still resulting in network service interruptions. Summary of the Invention
[0005] The present invention is to solve the problem of network service reliability. It provides a two-stage dual-network card redundancy method based on the Linux system. The first-stage network card redundancy is realized through the bond function; the primary and standby machines receive data through the network interface at the same time, but only the primary machine returns the processed data through the network interface, and the standby machine does not send data through the network. This method is used to realize primary and standby switching, ensuring that there must be an effective network interface working properly at the same moment, realizing the secondary redundancy of the network card, and thus ensuring the continuity of data transmission; in the primary and standby switching, a combination of manual primary machine and automatic primary machine is adopted. The manual primary machine allows users to specify the host device through manual means such as remote or local settings according to actual usage scenarios, usage requirements, local area network deployment, and fault troubleshooting factors during use, which can not only meet flexible application requirements but also provide a reliable backup means in case of emergency faults, improving system reliability. The response time of the manual primary machine is in the order of milliseconds, with strong real-time performance; for the possible situation of manual primary machine competition, the present invention designs a judgment strategy based on online duration and device number to ensure that there is only one primary machine working in the same network system at the same moment.
[0006] The present invention provides a two-stage dual-network card redundancy method based on the Linux system, including the following steps:
[0007] S1. Build a communication system with two - level dual - network - card redundancy. The communication system includes a primary dedicated communication device and a standby dedicated communication device, both of which are equipped with a CPU and two network interfaces. Each network interface is sequentially connected to a switch and a server through the CPU. The CPUs are both loaded with the Linux system. The two network interfaces in the dedicated communication device form the first - level network - card redundancy, and the primary dedicated communication device and the standby dedicated communication device form the second - level network - card redundancy. The method for building the first - level network - card redundancy proceeds to step S2, the method for building the second - level network - card redundancy proceeds to step S3, and the method for switching between the first - level network - card redundancy and the second - level network - card redundancy proceeds to step S4;
[0008] S2. Insert and load the bonding function kernel module in the Linux systems of the two dedicated communication devices and set it to the first primary - standby mode. At the same time, only one network card in each dedicated communication device drives the network interface to function. Only when the currently working network card fails will it switch to the other network card; The dual - network cards externally present the same MAC address and the same IP address; After configuring the physical network cards, configuring the link check time, and writing scripts, the first - level network - card redundancy is built;
[0009] S3. In the local area network, connect the primary dedicated communication device and the standby dedicated communication device to the switch respectively, establish an independent thread for sending heartbeat information, and set the second primary - standby mode that supports manual switching and automatic switching. The primary dedicated communication device and the standby dedicated communication device send and receive heartbeat information to each other through the network interfaces. The heartbeat information includes the dedicated communication device number and the primary - standby status. The second - level network - card redundancy is built;
[0010] S4. The primary dedicated communication device and the standby dedicated communication device each receive data through one network interface at the same time, and only the primary dedicated communication device returns the processed data to the switch through the network interface; When one network interface fails, it switches to the other network interface; The primary dedicated communication device and the standby dedicated communication device send and receive heartbeat information to each other through the network interfaces for heartbeat information monitoring. When three consecutive frames of heartbeat information from other devices are not received, judge the primary - standby identifier of other devices according to the heartbeat information, and perform manual switching or automatic switching to resume external sending and receiving. A two - level dual - network - card redundancy method based on the Linux system is completed.
[0011] In the two - level dual - network - card redundancy method based on the Linux system according to the present invention, as a preferred mode, in step S2, in the first primary - standby mode, after switching to the standby network card due to a failure, the original primary network card remains in the standby state even if it returns to normal, reducing the dual - network - card switching under normal circumstances.
[0012] In the two - level dual - network - card redundancy method based on the Linux system according to the present invention, as a preferred mode, step S2 includes the following steps:
[0013] S21. Build a single dedicated communication device based on a CPU with a Linux system. The CPU supports at least dual network controllers, and dual network ports are led out through the network controllers.
[0014] S22. Implement the bond function based on the Linux operating system. First, insert and load the bonding function kernel module in the Linux system to make the Linux operating system support the bond function and implement the first master-slave mode.
[0015] S23. Configure the physical network cards. The two network cards in the single dedicated communication device are configured identically and externally show the same logical network card name.
[0016] S24. Set the link check time, and the link check time can be adjusted according to the actual usage efficiency requirements.
[0017] S25. Write a script to configure the logical network card bond0 to make the two network cards externally show the same network card, that is, the same MAC address and the same IP address, and the first-level network card redundancy is completed.
[0018] In a preferred embodiment of the two-level dual-network card redundancy method based on the Linux system according to the present invention, in S22, the mode of the first master-slave mode is 1.
[0019] In step S23, when configuring the physical network card, the IP address acquisition method of the network card is static configuration, and the network card type is Ethernet.
[0020] In step S24, the link check time is 10 ms.
[0021] In a preferred embodiment of the two-level dual-network card redundancy method based on the Linux system according to the present invention, step S3 includes the following steps:
[0022] S31. In the local area network, connect the primary dedicated communication device and the standby dedicated communication device to the switch respectively, and connect the switch to the server.
[0023] S32. Based on the Linux operating system, create independent threads with the function of sending heartbeat information on the primary dedicated communication device and the standby dedicated communication device respectively. The heartbeat information includes: device number, primary-standby status, and local heartbeat count; the device numbers of the primary dedicated communication device and the standby dedicated communication device are different, and the primary-standby status includes manual host, manual standby, automatic host, and automatic standby.
[0024] S33. Establish a second primary / standby mode, which supports manual and automatic switching between the primary and standby machines. In the manual switching mode, the dedicated communication device can be forcibly set as the primary or standby machine through local configuration. In the automatic switching mode, the dedicated communication device monitors the network port working status of the other machine through heartbeat information. When the standby machine does not receive the primary machine's heartbeat information for three consecutive frames, it can automatically switch to operate as the primary machine.
[0025] In a preferred embodiment of the two - level dual - network - card redundancy method based on the Linux system of the present invention, in step S31, the server communicates with the dedicated communication device through a single - path gigabit network via a switch, and the dedicated communication device is connected to the switch using a dual - path gigabit network.
[0026] In a preferred embodiment of the two - level dual - network - card redundancy method based on the Linux system of the present invention, step S4 includes the following steps: Receiving and sending data and network port switching enter step S41, and receiving and sending heartbeat information and manual or automatic switching enter step S42;
[0027] S41. The primary dedicated communication device and the standby dedicated communication device simultaneously use the first primary / standby mode and each receive data through a network port. The primary dedicated communication device and the standby dedicated communication device externally present different IP addresses and MAC addresses. After receiving the data, the primary dedicated communication device and the standby dedicated communication device work simultaneously, perform resource sharing and synchronous data processing, but only the primary dedicated communication device returns the processed data to the switch through the network port. When a network port fails and cannot receive or send data, it switches to the other network port;
[0028] S42. The primary dedicated communication device and the standby dedicated communication device send and receive heartbeat information to each other through the network port for heartbeat information monitoring. When the heartbeat information of the other machine is not received for three consecutive frames, the primary / standby identifier of the other machine is judged according to the heartbeat information, and manual or automatic switching is performed to resume external sending and receiving;
[0029] The primary / standby status of manual switching is the manual primary machine and the manual standby machine, and the primary / standby identifiers of automatic switching are the automatic primary machine and the automatic standby machine. The priority of the manual primary machine is higher than that of the automatic primary machine. When the primary / standby statuses of the two dedicated communication devices conflict, automatic switching can also be performed according to the online time and / or device number.
[0030] In a preferred embodiment of the two - level dual - network - card redundancy method based on the Linux system of the present invention, step S42 includes the following steps:
[0031] S421. Receive heartbeat information;
[0032] S422. Determine whether the heartbeat information reception times out for three consecutive frames. If not, proceed to step S424; if so, determine whether the network cable is plugged in. If so, proceed to step S423; if not, switch the local machine to the automatic standby machine and return to step S421.
[0033] S423. Determine whether the network interface is faulty. If so, switch the network interface and return to step S421; if not, switch the local machine to the automatic host and return to step S421.
[0034] S424. Determine the status of the master - standby flag in the heartbeat information received from other machines. If it is the manual host, proceed to step S425; if it is the automatic host, proceed to step S426; if it is the manual standby machine, proceed to step S427; if it is the automatic standby machine, proceed to step S428.
[0035] S425. The other machine is the manual host, switch the local machine to the manual standby machine.
[0036] S426. The other machine is the automatic host, determine the master - standby status of the local machine:
[0037] When the master - standby status of the local machine is the automatic host, first determine whether the online time of the other machine is greater than that of the local machine. If so, switch the local machine to the automatic standby machine and return to step S421; if the online times are the same, then determine whether the device number of the other machine is less than that of the local machine. If so, switch the local machine to the automatic standby machine and then return to step S421; if not, return to step S421.
[0038] When the master - standby status of the local machine is the manual host: return to step S421;
[0039] When the master - standby status of the local machine is the manual standby machine: switch the local machine to the automatic standby machine and return to step S421;
[0040] When the master - standby flag of the local machine is the automatic standby machine: return to step S421;
[0041] S427. The other machine is the manual standby machine, determine the master - standby status of the local machine:
[0042] When the master - standby status of the local machine is the manual standby machine or the automatic standby machine, determine whether the device number of the local machine is less than that of the other machine. If not, go to step S421; if so, switch the local machine to the automatic host and then return to step S421.
[0043] When the master - standby status of the local machine is the manual host or the automatic host: return to step S421;
[0044] S428. The other machine is the automatic standby machine, determine the master - standby status of the local machine:
[0045] When the primary / backup status of the local machine is the automatic backup machine, it is determined whether the device number of the local machine is less than that of other machines. If not, return to step S421; if so, switch the local machine to the automatic primary machine, and then return to step S421;
[0046] When the primary / backup status of the local machine is the manual primary machine, the manual backup machine, or the automatic primary machine, return to step S421.
[0047] The present invention has the following advantages:
[0048] (1) In the present invention, the primary and backup machines simultaneously receive data through the network interface, but only the primary machine returns the processed data through the network interface, and the backup machine does not send data through the network. By using this method to implement the primary / backup switch, it is ensured that there must be a valid network interface working properly at the same moment, realizing the secondary redundancy of the network card, and thus ensuring the continuity of data transmission.
[0049] (2) In the primary / backup switch of the present invention, a combination of the manual primary machine and the automatic primary machine is adopted. When using the manual primary machine, the user can, according to actual usage scenarios, usage requirements, local area network deployment, fault troubleshooting and other factors, specify the primary machine device through manual means such as remote or local settings. This can not only meet flexible application requirements but also provide a reliable backup means in case of emergency failures, improving the system reliability. The response time of the manual primary machine is at the millisecond level, with strong real-time performance.
[0050] (3) In view of the possible situation of manual primary machine competition, the present invention designs a decision strategy based on the online duration and device number to ensure that there is and only one primary machine working in the same network system at the same moment. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is a flowchart of a two-level dual-network card redundancy method based on the Linux system;
[0052] Figure 2 It is a structural schematic diagram of a two-level dual-network card redundancy method based on the Linux system;
[0053] Figure 3 It is a flowchart of step S4 of a two-level dual-network card redundancy method based on the Linux system. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0054] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments.
[0055] Embodiment 1
[0056] As Figure 1As shown in the figure, a two - level dual - network - card redundancy method based on the Linux system. This invention is mainly used in dedicated information processing terminals. Compared with traditional network communication designs, the advantages of this invention mainly include the following aspects:
[0057] (1) It can ensure that communication devices work stably and reliably in the communication system, ensuring that the network functions of the communication system are not lost;
[0058] (2) When a network card fails, it can achieve rapid switching of the network card, ensuring that network data in the communication system can be effectively transmitted;
[0059] (3) Through the two - level dual - network - card redundancy method, the continuity of network data communication in the communication system can be guaranteed to the greatest extent.
[0060] The schematic diagram of the invention principle of the two - level dual - network - card redundancy method of the Linux system is as Figure 2 shown. In the communication system, the server uses a single - path gigabit network to communicate with communication devices through a switch, and the communication devices are connected to the switch using dual - path gigabit networks.
[0061] This invention includes the following steps:
[0062] S1. The first - level dual - network - card redundancy is designed using the dual network cards of the dual - path network within a single communication device. Both of these dual network cards are directly led out by the CPU externally. This CPU is equipped with the Linux system. Through software design, these dual network cards have the following functions:
[0063] (1) The dual network cards appear as 1 MAC address and the same IP address externally;
[0064] (2) Only one network card communicates externally at the same time. When the primary network card works normally, there is no frequent switching between the dual network cards;
[0065] (3) When either of the dual network cards fails, it can quickly switch to the other network card to work.
[0066] (4) When the currently working network card (primary network card) fails and causes a switch between the dual network cards to the standby network card, when the original primary network card returns to normal, the standby network card still remains working, reducing the switching of the dual network cards under normal circumstances.
[0067] The second - level dual - network - card redundancy is designed using the hot - standby redundancy method of the primary and standby machines. The primary and standby machines are connected in the same local area network, and the primary and standby machines interact through heartbeat information to monitor each other's working status, and have the following functions:
[0068] (1) The network interfaces of the primary and standby machines appear as different IP addresses and MAC addresses externally, and only one network interface transmits data externally at the same time;
[0069] (2) The primary and standby machines work simultaneously, sharing resources and synchronizing data processing to maintain strict data processing synchronization. Only the primary machine exchanges data with the outside world at the same time.
[0070] (3) Heartbeat information is monitored between the primary and standby machines. Once the primary machine fails, the standby machine automatically switches to the primary machine, starts working by sending out the network port, and ensures the continuity of data transmission.
[0071] Specific implementation steps:
[0072] S2. Construction of the first-level network card redundancy
[0073] (1) Build a single dedicated communication device based on a CPU with a Linux system. This CPU supports at least dual network controllers, and dual network ports are led out through the network controllers.
[0074] (2) Implement the bond function based on the Linux operating system. First, insert and load the bonding function kernel module in the Linux system to ensure that the Linux operating system supports the bond function. Currently, the dual-network card binding under the Linux operating system supports 7 modes (mode = 0 to mode = 6). This invention adopts the primary-standby mode (mode = 1), that is, at the same moment, only one network card works, and it will only switch to another network card when the currently working network card fails. Compared with other working modes, this mode can improve the link reliability and increase the redundancy ability.
[0075] (3) Configure the physical network card. The elements in the configuration file ifcfg-eth0 are as follows:
[0076] DEVICE=eth0
[0077] BOOTPROTO=static
[0078] DNS1=192.168.100.1
[0079] TYPE=Ethernet
[0080] IPV6INIT=no
[0081] ONBOOT=yes
[0082] USERCTL=no
[0083] IPADDR=192.168.212.109
[0084] NETMASK=255.255.255.0
[0085] GATEWAY = 192.168.100.1
[0086] MASTER = bond0
[0087] SLAVE = yes
[0088] Among them, the specific IP address configuration can be adaptively modified according to the actual network segment requirements. Similarly, to configure the network card eth1 according to the above method, only the network card name needs to be modified.
[0089] (4) Configure the link check time. In the present invention, configure miimon = 10, that is, the link check time is 10 ms, which improves the link switching efficiency and maximally ensures the integrity of data transmission. The link check time can be adjusted according to the actual usage efficiency requirements.
[0090] (5) Write a script to configure the logical network card bond0 and execute the following instructions:
[0091] ifconfig bond0 192.168.212.109 netmask 255.255.255.0 up
[0092] ifenslave bond0 eth0
[0093] ifenslave bond0 eth1
[0094] So far, the construction of the dedicated communication device and the configuration of the system software have been completed. The network cards eth0 and eth1 appear as the same network card externally, realizing the first-level dual-network card redundancy function based on the Linux operating system.
[0095] S3. Second-level network card redundancy construction
[0096] (1) Build the communication system according to the Figure 1 shown schematic principle diagram. The dedicated communication device (main) and the dedicated communication device (backup) are connected to the same switch;
[0097] (2) Send heartbeat information between the main and backup machines through the network interface. Based on the Linux operating system, independent threads are created in the main and backup machines respectively. This thread mainly completes the function of sending heartbeat information. The sent heartbeat information includes the following content:
[0098] typedef struct _HEART_BEAT_INFO
[0099] {
[0100] unsigned short deviceID; / / Device number
[0101] unsigned char status; / / Main and standby status
[0102] unsigned int heartBeatCount; / / Local heartbeat count
[0103] }HEART_BEAT_INFO;
[0104] S4. In the present invention, the main and standby modes of the dedicated communication device support manual switching and automatic switching. In the manual switching mode, the dedicated communication device can be forcibly set as the host or standby machine through local configuration; in the automatic switching mode, the dedicated communication device monitors the network port working status of the other machine through heartbeat information. When the standby machine does not receive the host heartbeat information for 3 consecutive frames, it can automatically switch to the host operation.
[0105] S41. The main dedicated communication device and the standby dedicated communication device simultaneously use the first main and standby mode, each receiving data through a network port. The main dedicated communication device and the standby dedicated communication device externally show different IP addresses and MAC addresses; after the main dedicated communication device and the standby dedicated communication device receive data, they work simultaneously, perform resource sharing and synchronous data processing, but only the main dedicated communication device returns the processed data to the switch through the network port; when a network port fails and cannot receive or send data, it switches to the other network port;
[0106] S42. Design the main and standby machine switching process as Figure 3 shown below:
[0107] The specific process is as follows:
[0108] S421. Receive heartbeat information.
[0109] S422. Judge whether the reception of the heartbeat information times out for three consecutive frames. If it times out, when the network cable is inserted, enter step S423 to judge whether the network port is normal; when the network cable is not inserted, switch to the automatic standby machine and return to step S421; if it does not time out, continue with subsequent processing.
[0110] S423. When the network port is normal, switch to the automatic host; when the network port fails, switch the network port,
[0111] return to step S421;
[0112] S424. Judge the main and standby flag in the received heartbeat information of other machines. If it is the manual host, execute step S425; if it is the automatic host, execute step S426;
[0113] If it is the manual standby machine, execute step S427; if it is the automatic standby machine, execute step S428.
[0114] S425. The other device is the manual main device, and this device is switched to the manual standby device.
[0115] S426. The other device is the automatic main device. Judge the main / standby status of this device:
[0116] 1) This device is the automatic main device: First, judge whether the online time of the other device is greater than that of this device. If so, switch this device to the automatic standby device and return to step S421; if the online times are the same, then judge whether the device number of the other device is less than that of this device. If so, switch this device to the automatic standby device, and then return to step S421; if not, return to step S421.
[0117] 2) This device is the manual main device: Return to step S421.
[0118] 3) This device is the manual standby device: Switch this device to the automatic standby device and return to step S421.
[0119] 4) This device is the automatic standby device: Return to step S421.
[0120] S427. The other device is the manual standby device. Judge the main / standby status of this device:
[0121] 1) This device is the manual standby device or the automatic standby device: Judge whether the device number of this device is less than that of the other device. If not, return to step S421; if so, switch this device to the automatic main device, and then return to step S421.
[0122] 2) This device is the manual main device or the automatic main device: Return to step S421.
[0123] S428. The other device is the automatic standby device. Judge the main / standby status of this device:
[0124] 1) This device is the automatic standby device: Judge whether the device number of this device is less than that of the other device. If not, return to step S421; if so, switch this device to the automatic main device, and then return to step S421.
[0125] 2) This device is the manual main device, the manual standby device or the automatic main device: Return to step S421.
[0126] As described above, it is only the preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution and inventive concept of the present invention, makes equivalent replacements or changes, and should be covered by the protection scope of the present invention.
Claims
1. A two - level dual - network - card redundancy method based on the Linux system, characterized in that: It includes the following steps: S1. Build a communication system with two - level dual - network - card redundancy. The communication system includes a primary dedicated communication device and a standby dedicated communication device, both of which are equipped with a CPU and two network interfaces. Each network interface is sequentially connected to a switch and a server through the CPU. The CPUs are all equipped with the Linux system. The two network interfaces in the dedicated communication device form the first - level network - card redundancy, and the primary dedicated communication device and the standby dedicated communication device form the second - level network - card redundancy. The method for building the first - level network - card redundancy proceeds to step S2, the method for building the second - level network - card redundancy proceeds to step S3, and the method for switching between the first - level network - card redundancy and the second - level network - card redundancy proceeds to step S4; S2. Insert and load the bonding function kernel module in the Linux systems of the two dedicated communication devices and set it to the first primary - standby mode. At the same time, only one network card in each dedicated communication device drives the network interface to function. Only when the currently working network card fails will it switch to another network card; The dual - network cards externally present the same MAC address and the same IP address; After configuring the physical network cards, configuring the link check time, and writing scripts, the construction of the first - level network - card redundancy is completed; S3. In the local area network, connect the primary dedicated communication device and the standby dedicated communication device to the switch respectively, establish an independent thread for sending heartbeat information, and set the second primary - standby mode that supports manual switching and automatic switching. The primary dedicated communication device and the standby dedicated communication device send and receive heartbeat information to each other through the network interfaces. The heartbeat information includes the dedicated communication device number and the primary - standby status. The construction of the second - level network - card redundancy is completed; S4. The primary dedicated communication device and the standby dedicated communication device each receive data through one network interface at the same time. Only the primary dedicated communication device returns the processed data to the switch through the network interface; when one network interface fails, it switches to the other network interface; the primary dedicated communication device and the standby dedicated communication device send and receive heartbeat information to each other through the network interfaces for heartbeat information monitoring. When three consecutive frames of heartbeat information from other devices are not received, judge the primary - standby identifier of other devices according to the heartbeat information, perform manual switching or automatic switching, and resume external sending and receiving. A two - level dual - network - card redundancy method based on the Linux system is completed.
2. The two - level dual - network - card redundancy method based on the Linux system according to claim 1, wherein: In step S2, in the first primary - standby mode, after switching to the standby network card due to a failure, the original primary network card remains in the standby state even if it returns to normal, reducing the switching of the dual - network cards under normal circumstances.
3. A two - level dual - network - card redundancy method based on the Linux system according to claim 1, characterized in that: Step S2 includes the following steps: S21. Build a single dedicated communication device based on the CPU equipped with the Linux system. The CPU supports at least dual - path network controllers, and two network interfaces are led out externally through the network controllers; S22. Implement the bond function based on the Linux operating system. First, insert and load the bonding function kernel module in the Linux system to make the Linux operating system support the bond function and implement the first primary - standby mode; S23. Configure physical network cards. The configurations of the two network cards in a single dedicated communication device are exactly the same, presenting the same logical network card name externally. S24. Set the link check time, which can be adjusted according to the actual usage efficiency requirements. S25. Write a script to configure the logical network card bond0, making the two network cards appear as the same network card externally, that is, the same MAC address and the same IP address. The construction of the first-level network card redundancy is completed.
4. A two - level dual - network - card redundancy method based on the Linux system according to claim 3, characterized in that: S22. The mode of the first master-backup mode is 1. In step S23, when configuring the physical network card, the IP address acquisition method of the network card is static configuration, and the network card type is Ethernet. In step S24, the link check time is 10 ms.
5. A two - level dual - network - card redundancy method based on the Linux system according to claim 1, characterized in that: Step S3 includes the following steps: S31. In the local area network, connect the main dedicated communication device and the backup dedicated communication device to the switch respectively, and connect the switch to the server. S32. Based on the Linux operating system, create independent threads with the function of sending heartbeat information on the main dedicated communication device and the backup dedicated communication device respectively. The heartbeat information includes: device number, master-backup status, and local heartbeat count. The device numbers of the main dedicated communication device and the backup dedicated communication device are different, and the master-backup status includes manual host, manual standby, automatic host, and automatic standby. S33. Establish the second master-backup mode, which supports manual and automatic switching of the master and standby machines. In the manual switching mode, the dedicated communication device can be forcibly set as the host or standby through local configuration. In the automatic switching mode, the dedicated communication device monitors the network port working status of the other machine through the heartbeat information. When the standby machine does not receive the host heartbeat information for three consecutive frames, it can automatically switch to the host to run.
6. A two - level dual - network - card redundancy method based on the Linux system according to claim 5, characterized in that: In step S31, the server communicates with the dedicated communication device through the switch using a single-channel gigabit network, and the dedicated communication device is connected to the switch using a dual-channel gigabit network.
7. A two - level dual - network - card redundancy method based on the Linux system according to claim 1, characterized in that: Step S4 includes the following steps: Receive and send data and switch the network port to enter step S41, receive and send the heartbeat information and perform manual or automatic switching to enter step S42. S41. The main dedicated communication device and the backup dedicated communication device simultaneously use the first master-backup mode and each receive data through a network port. The main dedicated communication device and the backup dedicated communication device present different IP addresses and MAC addresses externally. After receiving the data, the main dedicated communication device and the backup dedicated communication device work simultaneously, perform resource sharing and synchronous data processing, but only the main dedicated communication device returns the processed data to the switch through the network port. When a network port fails and cannot receive or send data, switch to the other network port. S42. The main dedicated communication device and the backup dedicated communication device send and receive the heartbeat information through the network port to monitor the heartbeat information. When the heartbeat information of the other machine is not received for three consecutive frames, judge the master-backup identifier of the other machine according to the heartbeat information, perform manual or automatic switching, and resume external sending and receiving. The manually switched primary and standby states are the manual primary and the manual standby, and the automatically switched primary and standby identifiers are the automatic primary and the automatic standby; the priority of the manual primary is higher than that of the automatic primary; when the primary and standby states of two dedicated communication devices conflict, automatic switching can also be performed according to the online time and / or device number.
8. A two-level dual-network card redundancy method based on the Linux system according to claim 7, characterized in that: Step S42 includes the following steps: S421. Receive the heartbeat information; S422. Determine whether the reception of the heartbeat information times out for three consecutive frames. If not, proceed to step S424; if so, determine whether a network cable is inserted. If so, proceed to step S423; if not, the local machine switches to the automatic standby and returns to step S421; S423. Determine whether the network port is faulty. If so, switch the network port and return to step S421. If not, the local machine switches to the automatic primary and returns to step S421; S424. Determine the status of the primary and standby identifier in the received heartbeat information of other machines. If it is the manual primary, proceed to step S425; if it is the automatic primary, proceed to step S426; if it is the manual standby, proceed to step S427; if it is the automatic standby, proceed to step S428; S425. The other machine is the manual primary, and the local machine switches to the manual standby; S426. The other machine is the automatic primary. Determine the primary and standby status of the local machine: When the primary and standby status of the local machine is the automatic primary, first determine whether the online time of the other machine is greater than that of the local machine. If so, switch the local machine to the automatic standby and return to step S421; if the online times are the same, then determine whether the device number of the other machine is less than that of the local machine. If so, switch the local machine to the automatic standby and then return to step S421; if not, return to step S421; When the primary and standby status of the local machine is the manual primary: return to step S421; When the primary and standby status of the local machine is the manual standby: switch the local machine to the automatic standby and return to step S421; When the primary and standby identifier of the local machine is the automatic standby: return to step S421; S427. The other machine is the manual standby. Determine the primary and standby status of the local machine: When the primary and standby status of the local machine is the manual standby or the automatic standby, determine whether the device number of the local machine is less than that of the other machine. If not, go to step S421; if so, switch the local machine to the automatic primary and then return to step S421; When the primary and standby status of the local machine is the manual primary or the automatic primary: return to step S421; S428. The other machine is the automatic standby. Determine the primary and standby status of the local machine: When the primary and standby status of the local machine is the automatic standby, determine whether the device number of the local machine is less than that of the other machine. If not, return to step S421; if so, switch the local machine to the automatic primary and then return to step S421; When the primary and standby status of the local machine is the manual primary, the manual standby or the automatic primary, return to step S421.
Citation Information
Cited By
Fault automatic detection system and detection method
CN121186466A