Seven kinds of bond-Mode Linux multi-card principle

Linux Multi-NIC teaming

There are seven NIC teaming mode (0 ~ 6) bond0, bond1, bond2, bond3, bond4, bond5, bond6.

There are three commonly used

mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。
mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。
mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。

Note that if you want to make load balancing mode 0, just setting here options bond0 miimon = 100 mode = 0 is not enough, switches and network cards must be connected to a special configuration (two ports should be taken aggregation), because bonding of the two network cards to do is use the same MAC address from the principle analyze (bond running in mode 0).:

IP bond is bound at mode 0 card is modified to have the same mac address, if these cards are connected to the same switch, then that switch arp mac address table corresponding to a plurality of ports there, the switch receive sent to the mac address of the packet should be forwarded to which port it? mac address is a globally unique Under normal circumstances, a mac address corresponding to a plurality of ports to make sure the switch confused. Therefore, under the bond mode0 If the connection to the switch, the port should take these polymerization mode (referred to as Cisco ethernetchannel, foundry portgroup called), because the switches do polymerization, polymerization of several ports is also bundled into a mac address. our solution is two different network card access switch can be.

Mode6 the mode switch need not be configured, because it is the bonding of the two network cards use different MAC addresses.

Seven kinds of bond Mode Description:

A first mode: mod = 0, namely: (balance-rr) Round-robin policy (lun balancing policy cycle)

Features: data packet transmission sequence is transmitted sequentially (ie: the first one package to go eth0, eth1 ... and left the next packet has been the cycle continues until the last transmission is completed), this mode provides load balancing and fault tolerance; but we know If a packet data connection or session issued from the different interfaces, then the middle and then through different links, the client is likely to issue a packet will arrive out of order, the data packets arrive out of order requirements need to be transmitting, so the network throughput will drop

The second mode: mod = 1, namely: (active-backup) Active-backup policy (primary - backup strategy)

Features: Only one device is active, a shoot down immediately when another conversion by the backup master. mac address externally visible too, it seems from the outside, the MAC address is unique Bond to avoid switch (switch) chaos. This provides fault tolerance mode only; Thus advantage of this algorithm is that it provides a high availability of the network connection, but its low resource utilization, only one interface is in working condition, when the N number of the network interface, resource utilization to 1 / N

The third model: mod = 2, namely: (balance-xor) XOR policy (balancing strategy)

Features: The specified transmission HASH policy transmission packet based. The default strategy is :( source MAC address of the XOR destination MAC address)% Number slave. Other transport policy options can be specified by xmit_hash_policy This mode provides load balancing and fault tolerance

The fourth mode: mod = 3, namely: broadcast (broadcasting policy)

Features: transmitting each packet at each slave interface This mode provides fault tolerance

The fifth mode: mod = 4, namely: (802.3ad) IEEE 802.3ad Dynamic link aggregation (IEEE 802.3ad link aggregation dynamic)
Features: Create an aggregation group, they share the same speed and duplex setting. The plurality of slave 802.3ad specification under an active work in the same polymer.

slave elections outgoing traffic is based on the transmission hash policy, which can be changed from the default XOR policy to other policies by xmit_hash_policy option. It should be noted that not all of the transmission strategy is 802.3ad adaptation, especially considering the question out of order packets in 802.3ad standard mentioned in section 43.2.4. Different implementations may have different adaptability.

Requirements:

Condition 1: ethtool support access to each slave speed and duplex settings

Condition 2: switch (switch) supports IEEE 802.3ad Dynamic link aggregation

Condition 3: Most switch (switch) to go through a specific configuration to support 802.3ad mode

Sixth Mode: mod = 5, namely: (balance-tlb) Adaptive transmit load balancing (the adapter to transmit load balancing)

Features: channel bonding does not require any special switch (switch) support. Outgoing traffic distribution according to the current load (calculated velocity) at each slave. If the slave is receiving data out of order, another slave takes over the MAC address of the slave's failure.

A necessary condition for the model: ethtool support the acquisition rate of each slave

Seventh modes: mod = 6, namely: (balance-alb) Adaptive load balancing (adapter adaptive load balancing)

Features: The model contains the balance-tlb mode while receiving load balancing plus (receive load balance, rlb) for IPV4 traffic, and does not require any support switch (switch). Receive load balancing is achieved by ARP negotiation. bonding driver intercepts the ARP response sent from this machine, and the source hardware address is rewritten to bond the unique hardware address of a slave, so that different peers use different hardware address for communication.

Receive traffic from the server will be balanced. When the unit sends an ARP request, bonding the driving end of the copy information from the IP packets and ARP preserved. When the ARP reply from the peer arrival, bonding to drive its hardware address extracted, and initiate an ARP reply to a slave bond of. One problem with using ARP negotiation load balancing is: will use the bond hardware address each time a broadcast ARP request, so after the end of the study to the hardware address to receive all the traffic will flow to the current slave. This problem can be solved by giving all of the peer sending updates (ARP reply), the response contains their unique hardware address, causing traffic redistribution. When a new slave added to the bond, or when an inactive slave re-activated, but also receive traffic redistribution. The received load is distributed sequentially (round robin) bond in the most high-speed slave

When a link is reconnected, or a new slave is added to the bond, all traffic received redistributed among all currently active in the slave, by using the specified MAC address to each client sends an ARP reply. updelay parameters described below must be set equal to the switch (switches) for a value greater than the forward delay, thus ensuring the ARP reply sent to the peer will not be switch (switch) intercept.

Requirements:

Conditions 1: ethtool support the acquisition rate of each slave;

Condition 2: the underlying hardware address driver support is provided a device, so that there is always a slave (curr_active_slave) using hardware address bond, while the bond to ensure that each slave has a unique hardware address. If curr_active_slave failure, and its hardware address will be taken over by the new elected curr_active_slave

In fact, the difference between mod and mod = 6 = 0: mod = 6, eth0 traffic filled first, and then accounted for eth1, ... .ethX; and mod = 0, then the flow will find two ports are stable, essentially the same bandwidth. The mod = 6, will find a high first port traffic, the two ports account for only a small part of the flow

Linux network port binding

Through a network port binding (bond) technology, it can easily implement network port redundancy, load balancing to achieve high reliability and high availability purposes. Premise conventions:

2个物理网口分别是:eth0,eth1
绑定后的虚拟口是:bond0
服务器IP是:192.168.0.100

The first step, configuration settings file:

vim /etc/sysconfig/network-scripts/ifcfg-bond0  
DEVICE=bond0  
BOOTPROTO=none  
ONBOOT=yes  
IPADDR=192.168.0.100  
NETMASK=255.255.255.0  
NETWORK=192.168.0.0  
BROADCAST=192.168.0.255  
# BROADCAST广播地址  
vim /etc/sysconfig/network-scripts/ifcfg-eth0  
DEVICE=eth0  
BOOTPROTO=none  
MASTER=bond0  
SLAVE=yes  
vim /etc/sysconfig/network-scripts/ifcfg-eth1  
DEVICE=eth1  
BOOTPROTO=none  
MASTER=bond0  
SLAVE=yes 

The second step, modify modprobe related settings file, and load the bonding module:

1. Here, we create a direct load the bonding of specific settings file /etc/modprobe.d/bonding.conf

[root@test ~]# vi /etc/modprobe.d/bonding.conf 
追加

alias bond0 bonding 
options bonding mode=0 miimon=200 
2.加载模块(重启系统后就不用手动再加载了)

[root@test ~]# modprobe bonding 
3.确认模块是否加载成功:

[root@test ~]# lsmod | grep bonding 
bonding 100065 0 

The third step, reset the Internet, and then confirm the situation:

[root@test ~]# /etc/init.d/network restart  
[root@test ~]# cat /proc/net/bonding/bond0  
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)  
Bonding Mode: fault-tolerance (active-backup)  
Primary Slave: None  
Currently Active Slave: eth0  

……

[root@test ~]# ifconfig | grep HWaddr  
bond0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74  
eth0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74  
eth1 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74 

Confirmation from the above, we can see three important information:

1. The bonding pattern is now active-backup

2. Now the state is Active Ethernet port eth0

Eth0 same physical address in the active state of the physical address 3.bond0, eth1, and is, so to avoid chaos upper switches.

Any unplug a cable, and then access your server to see if the network or through the.

The fourth step, the system starts automatically bound to increase the default gateway:

[root @ test ~] # vi /etc/rc.d/rc.local
added

ifenslave bond0 eth0 eth1 
route add default gw 192.168.0.1 

Such as Internet access would not increase routing, address changes by 0.1 environment.

Look: The foregoing merely two Ethernet ports bond0 bind to a case where, if we want to bond a plurality of ports, such as physical network interface eth0 and eth1 bond0 composition, and eth2 are bond1 eth3 composition,

Then the same method to set network port settings file Step 1 above and talk method, but /etc/modprobe.d/bonding.conf setting like this can not be simply superimposed:

alias bond0 bonding  
options bonding mode=1 miimon=200  
alias bond1 bonding  
options bonding mode=1 miimon=200 

The correct settings There are two methods:

The first, as you can see, in this way, then multiple bond port mode can only be set to the same:

alias bond0 bonding  
alias bond1 bonding  
options bonding max_bonds=2 miimon=200 mode=1 

Second, this way, different bond opening mode can be set to be different:

alias bond0 bonding  
options bond0 miimon=100 mode=1  
install bond1 /sbin/modprobe bonding -o bond1 miimon=200 mode=0 

A closer look at these two settings above method, now if it is to set up three, four, or even more bond mouth, you will be right!

Postscript: a brief look at the meaning of the above when loading the bonding module, options in some of the parameters:

miimon monitor network links the frequency, in milliseconds, we set is 200 milliseconds.

The number of port configurations bond max_bonds

mode bond pattern, are the following, in a general practice, the 0 and 1 with more,

If you want to understand the characteristics of each of these modes you need to rely on your own readers to find information and do practice.

Guess you like

Origin www.cnblogs.com/fan-gx/p/11069845.html