In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you how to bind dual network cards under linux, the content is very detailed, interested friends can refer to, hope to be helpful to you.
The implementation of dual network card binding on Linux is to use two network cards to form a virtual network card. This combined device looks like a separate Ethernet interface device. Generally speaking, the two network cards have the same IP address and parallel links are aggregated into a logical link. In fact, this technology has long existed in Sun and Cisco, known as Trunking and Etherchannel technology, and is also used in the 2.4.x kernel of Linux, known as bonding.
The earliest application of bonding technology is on the cluster-beowulf, which is designed to improve the data transmission between cluster nodes. Let's discuss the principle of bonding. What is bonding needs to start with the promisc mode of the network card. We know that under normal circumstances, the network card only receives the Ethernet frame in which the destination hardware address (MAC Address) is its own Mac and filters out other data frames to reduce the burden on the driver. But the network card also supports another mode called hybrid promisc, which can receive all frames on the network, such as tcpdump, which is running in this mode. Bonding also runs in this mode, and modifies the mac address in the driver to change the Mac address of the two network cards to the same, so that it can receive data frames of a specific MAC. Then the corresponding data frames are transmitted to the bond driver for processing.
RHEL 6 configuration 1 backup network card configuration file [root@redhat6 ~] # cp / etc/sysconfig/network-scripts/ifcfg-eth0 ~ / ifcfg-eth0.bak [root@redhat6 ~] # cp / etc/sysconfig/network-scripts/ifcfg-eth2 ~ / ifcfg-eth2.bak2 configuration binding
Virtual network interface profile, which specifies the network card IP,ifcfg-bond0:
[root@redhat6 ~] # vi / etc/sysconfig/network-scripts/ifcfg-bond0DEVICE=bond0IPADDR=192.168.1.111NETMASK=255.255.255.0ONBOOT=yesBOOTPROTO=noneUSERCTL=noNM_CONTROLLED=noBONDING_OPTS= "mode=1 miimon=100"
Configure a real network card, eth0 and eth2
[root@redhat6 ~] # vi / etc/sysconfig/network-scripts/ifcfg-ethDEVICE=ethBOOTPROTO=noneONBOOT=yesMASTER=bond0SLAVE=yesUSERCTL=noNM_CONTROLLED=no
NM_CONTROLLED=no NetworkManager is not permitted to configure this device.USERCTL=no Non-root users are not allowed to control this device.
BOOTPROTO=none No boot-time protocol should be used
3 restart the network service [root@redhat6 ~] # service network restart4, test the network
Unplug a network cable to look at the ping data, confirm that there is no problem, plug the network cable connected, and then unplug another network cable to observe the binding effect of the dual network card.
5. 7 modes of Bonding
Load balancing Mode of define BOND_MODE_ROUNDROBIN 0 (balance-rr Mode) Network Card
Fault tolerance Mode of define BOND_MODE_ACTIVEBACKUP 1 (active-backup Mode) Network Card
Define BOND_MODE_XOR 2 (balance-xor mode) requires switch support
Define BOND_MODE_BROADCAST 3 (broadcast mode)
Define BOND_MODE_8023AD 4 (IEEE 802.3ad dynamic Link aggregation Mode) requires switch support
Define BOND_MODE_TLB 5 Adaptive Transmission load balancing Mode
Define BOND_MODE_ALB 6 Network Card Virtualization
The value of mode has seven modes of 0-6, and the commonly used ones are 0-6 and 1-6.
Mode=0: load balancing mode, with automatic backup, but requires "Switch" support and setting.
Mode=1: automatic backup mode. If one line is disconnected, the other lines will be backed up automatically.
Mode=6: load balancing mode, with automatic backup, no need for "Switch" support and configuration.
Description of bond mode parameters under linux system: (mode=4 is recommended when the switch supports LACP, which can provide better performance and stability)
0-polling mode, the bound Nic will divide the access equally according to the polling algorithm. 1-High availability mode, only one network card is used at run time, and the rest of the network card is used as a backup, which is recommended when the load does not exceed the bandwidth or pressure of a single network card. 2-based on the load balancing mode of HASH algorithm, the network card is diverted according to the TCP protocol layer of xmit_hash_policy, so that the access from different processing sources can be processed on the same network card as far as possible. 3-broadcast mode, all bound network cards will get the same data, generally used for very special network requirements, such as the need to send the same data to two switches that are not connected to each other. 4-802.3ab load balancing mode requires the switch to also support 802.3ab mode. In theory, when both the server and the switch support this mode, the maximum bandwidth of the network card can be doubled (for example, from 1Gbps to 2Gbps). The output data will be output through all bound network cards, and only one of them will be selected when receiving data. If the network card that is being used to receive data fails, it will be taken over by other network cards, requiring that the network cards and network card drivers used can get speed information through the ethtool command. 6-Adapter input / output load balancing mode, which realizes load balancing while receiving data on the basis of "mode 5". It not only requires the ethtool command to get speed information, but also supports the dynamic modification of the MAC address of the network card.
In the dual network card binding mode, the performance of the network card is not double the bandwidth and transmission speed as most people guess; in fact, it may be just the opposite.
This problem still needs to see where the bottleneck lies.
Generally multi-network card binding, the processor should be no problem, the capacity is very strong, the network is also very strong, the bottleneck is in the network card, so binding a few pieces can solve the bottleneck of the network card and improve the reliability.
If it is a board, although the network is also very strong, it is estimated that the bottleneck is not the network card, but the processing capacity of the board. Adding multiple network cards may reduce the performance of the board. Multi-Nic binding should be in hybrid mode, handing the original hardware processing to the driver, increasing the burden on the software / board.
Ordinary desktop server, now the performance should be very strong, not a bottleneck, so the use of multiple network card binding can reflect the advantage.
Every method has its premise.
Learn about the algorithms of each mode of bonding, the rotation algorithm used in load balancing mode, and the backup algorithm used in hot backup.
In theory, in dual network card binding backup mode, only one network card works, and the result of traffic test should be the same as using a single network card.
Also in theory, when sending and receiving general network data in dual-Nic bound load balancing mode, I mean less than 1588 messages and other non-sharded data, the bandwidth and speed will be doubled.
My guess: now I am in load balancing mode, I transfer a 4GB file, and the file is sliced, and the consecutive slices are processed separately by two network cards under the rotation algorithm. On the one hand, the software algorithm consumes time, on the other hand, it may be out of order, and it takes time to apply for retransmission or other reasons.
Now there are two questions: 1, why there is only round-robin mode, the two network cards on the development board are of the same model; 2, the speed of transferring files in load balancing mode is slower than that of using a single network card.
Looking forward to the eldest brother to solve the doubt, thank you.
To sum up.
1. The problem that you can only enter the load balancer; the configuration files modules.conf and modprobe.conf read when the module is loaded are applicable to the old and new kernel versions, respectively. Second, the mode parameter in these two files is used to set the binding mode. If the file name is wrong, the setting is of course invalid. In addition, bongding needs to be compiled into a module in the kernel instead of being added directly to the kernel.
2. Transferring large files when the Nic is bound is slower than when it is unbound. Tests show that in load balancing mode, the time required to transfer large files is twice as long as that of unbound single network port, and the time required for hot backup mode is four times longer than that of single network port. Conjecture and unproven reason: when load balancing, the messages transmitted on the network are generally less than 1588, and the network card processes these typical network messages very quickly. However, what is transferred now is a very large file, which is larger than 1588, and the file is divided into many slices. File reorganization requires shards to arrive in order, and it may be due to reasons such as the reversal of the order of slices processed by two NICs. In addition, the additional binding algorithm also takes time; when hot backup, the binding algorithm takes time.
On how to bind the dual network card under linux to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.