Company procurement of the server installed dual network card, and bond network card binding settings, Nic binding mode A total of seven kinds (0~6) bond0, Bond1, Bond2, Bond3, Bond4, Bond5, Bond6.
First mode: Mod=0 , ie: (BALANCE-RR) Round-robin policy (balanced Whirl cycle strategy )
Features: Transmission packet sequence is transmitted sequentially (that is: the 1th packet to go eth0, the next package will go eth1 ...). This mode provides load balancing and fault tolerance until the last transmission is complete), but we know that if a connection or session packet is sent from a different interface, In the middle of a different link, the client is likely to have an unordered packet arrival problem, and the unordered arrival of the packet needs to be sent again, so that the network throughput will be degraded.
Second mode: mod=1, ie: (active-backup) active-backup policy ( primary-backup strategy )
Features: Only one device is active, and when one is down the other is converted to the primary device immediately by the backup. The MAC address is externally visible, and from the outside, the MAC address of the bond is unique to avoid the switch from confusing. This mode only provides fault tolerance, so the advantage of this algorithm is that it can provide high network connection availability, but its resource utilization is low, only one interface is working, in the case of N network interface, resource utilization is 1/n.
Third mode: mod=2, ie: (balance-xor) XOR policy (Balancing strategy )
Feature: transmits packets based on the specified transfer hash policy. The default policy is: (Source MAC address XOR destination MAC address)% slave number. Other transport policies can be specified through the Xmit_hash_policy option, which provides load balancing and fault tolerance.
Fourth mode: Mod=3, i.e.: Broadcast ( broadcast strategy )
Feature: Each packet is transmitted on each slave interface, and this mode provides fault tolerance
Fifth mode: Mod=4, i.e.: (802.3AD) IEEE 802.3ad dynamic Link Aggregation (IEEE 802.3ad dynamically linked aggregation )
Feature: Create an aggregation group that shares the same rate and duplex settings. Multiple slave are working under the same active aggregate according to the 802.3AD specification.
The slave election for outgoing traffic is based on the transfer hash policy, which can be changed from the default XOR policy to another policy through the xmit_hash_policy option. It is important to note that not all transmission strategies are 802.3AD adapted, especially considering the problem of packet chaos mentioned in the 802.3AD standard 43.2.4 section. Different implementations may have different adaptations.
Necessary:
- Conditional 1:ethtool supports getting the rate and duplex settings for each slave
- Conditional 2:switch (switch) supports IEEE 802.3ad Dynamic link Aggregation
- Condition 3: Most switch (switches) require a specific configuration to support 802.3ad mode
Sixth mode: Mod=5, i.e.: (balance-tlb) Adaptive Transmit load balancing ( adapter transport load Balancer )
Features: no special switch (switch) supported channel bonding is required. Out-of-office traffic is allocated on each slave based on the current load (calculated based on speed). If the slave that is accepting data fails, the other slave takes over the MAC address of the failed slave.
Required for this pattern: Ethtool supports getting the rate per slave
seventh mode: mod=6 , i.e.: (BALANCE-ALB) Adaptive load Balancing ( adapter Adaptive load Balancing )
Features: This mode includes balance-tlb mode, plus receive load balancing for IPV4 traffic ( Receive load balance, RLB), and does not require any switch (switch) support. Receive load balancing is implemented through ARP negotiation. The bonding driver intercepts the ARP response sent by the native and overwrites the source hardware address with the unique hardware address of one of the slave in bond, allowing different peer-to-peer communication using different hardware addresses. The
receive traffic from the server side is also balanced. When the native sends an ARP request, the bonding driver copies and saves the IP information from the ARP packet to the peer. When the ARP response arrives from the peer, the bonding driver extracts its hardware address and initiates an ARP response to one of the slave in Bond. One problem with the use of ARP negotiation for load balancing is that the hardware address of the bond is used every time the ARP request is broadcast, so when the peer learns the hardware address, the incoming traffic will flow to the current slave. This problem can be resolved by sending updates (ARP responses) to all the peers, which contain their unique hardware address, which results in the redistribution of traffic. When a new slave is added to bond, or an inactive slave is reactivated, the incoming traffic is also re-distributed. The received load is distributed sequentially (round robin) on the highest slave in bond
when a link is re-connected, or a new slave is added to bond, receiving traffic is redistributed in all currently active slave. Initiates an ARP reply to each client by using the specified MAC address. The Updelay parameter described below must be set to a value that is greater than or equal to the switch forwarding delay to ensure that the ARP response destined to the peer is not blocked by the switch.
Prerequisites:
- The condition 1:ethtool supports obtaining the rate of each slave;
- Condition 2: The underlying driver supports setting the hardware address of a device so that there is always a slave (curr_active_slave) using the hardware address of bond, while ensuring that slave in each bond has a unique hardware address. If the curr_active_slave fails, its hardware address will be taken over by the newly elected Curr_active_slave.
in fact, the difference between mod=6 and mod=0 : mod=6, the first eth0 flow accounted for, and then accounted for eth1,....ethx, and mod=0 words, will find that 2 ports of traffic are stable, the same bandwidth. And Mod=6, will find the first port flow is very high, the 2nd port only accounted for a small portion of traffic
The following is a brief introduction of bond binding dual network card operation record:
Through the network port binding (bond) technology, can easily realize the network port redundancy, load balancing, so as to achieve high availability and high reliability. 2 Physical network ports are: Eth0,eth1 after binding the virtual port is: Bond0 server IP is: 10.0.54.28 in mod=4 mode (common mode) first to see if the NIC supports bond binding [[email protected] ~]# Modinfo Bonding |morefilename:/lib/modules/2.6.32-696.16.1.el6.x86_64/kernel/drivers/net/bonding/ Bonding.koauthor:Thomas Davis, [email protected] and many othersdescription:ethernet Channel bonding Dri ver, V3.7.1version:3.7.1license:gplalias:rtnl-link-bondsrcversion:454ff5806f146ad7fb41356de pends:vermagic:2.6.32-696.16.1.el6.x86_64 SMP Mod_unload Modversions then the NIC binding settings [[email protected] ~]# C D/etc/sysconfig/network-scripts/[[email protected] network-scripts]# cat ifcfg-eth0device=eth0hwaddr=ec:f4: bb:dc:4c:0ctype=ethernetuuid=669f0694-9c52-4792-bd67-22c9d2c17acbonboot=yesnm_controlled=nobootproto= Nonemaster=bond0slave=yes[[email protected] network-scripts]# Cat ifcfg-eth1device=eth1hwaddr=ec:f4:bb:dc:4c : 0dtype=ethernetuuid=1d2f30f4-b3f0-41a6-8c37-54f03115f7bdonboot=yesnm_controlled=nobootproto=nonemaster=bond0slave=yes[[email protected] network-scripts]# Cat ifcfg-bond0 device=bond0name= ' bond0 ' type=ethernetnm_controlled=nouserctl=noonboot=yesbootproto=noneipaddr= 10.0.54.28netmask=255.255.255.0gateway=10.0.54.1bonding_opts= ' mode=4 miimon=100 ' IPV6INIT=no[[email Protected] network-scripts]# cat/etc/modprobe.d/bonding.conf//This file generally needs to be manually created alias Bond0 bondingoptions bonding mode= 4 miimon=100[[email protected] network-scripts]# modprobe bonding//need to perform this step, or even after restarting the NIC, the network does not restart the NIC. Need to turn off the NetworkManager service first and set the turn off! [[email protected] Network-scripts]#/etc/init.d/networkmanager stop[[email protected] network-scripts]# /etc/init.d/network Restart view bond nic mode after binding [[email protected] network-scripts]# cat/proc/net/bonding/bond0 Ethernet Channel Bonding driver:v3.7.1 (April) Bonding mode:ieee 802.3ad Dynamic Link Aggregation Show bond NIC bindings mode transmit Hash policy:layer2 (0) MII status:upmiiPolling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0802.3ad INFOLACP rate:slowmin links:0aggregator selection PO Licy (ad_select): Stablesystem priority:65535system MAC address:08:94:ef:54:b0:88active Aggregator Info:Aggregator ID: 2Number of Ports:2actor key:9partner key:1453partner Mac address:00:23:04:ee:be:d2slave interface:eth0mii status:up View the status of the NIC after binding (up or down) speed:1000 Mbpsduplex:fulllink Failur E count:0permanent HW addr:08:94:ef:54:b0:88slave queue id:0aggregator id:2actor churn State:nonepartner Churn state: Noneactor churned Count:0partner churned count:0details actor LACP Pdu:system priority:65535 system MAC Address : 08:94:ef:54:b0:88 Port Key:9 Port priority:255 Port number:1 Port state:61details partner LACP Pdu:s Ystem priority:32667 system mac address:00:23:04:ee:be:d2 oper key:1453 port priority:32768 Port Number:8 461 Port State:61slavE interface:eth1mii status:upspeed:1000 mbpsduplex:fulllink Failure count:0permanent HW addr:08:94:ef:54:b0:89slave Queue Id:0aggregator id:2actor Churn State:nonepartner churn state:noneactor churned Count:0partner Churned count:0d Etails actor LACP Pdu:system priority:65535 system mac address:08:94:ef:54:b0:88 Port Key:9 Port priority: 255 Port Number:2 Port state:61details partner LACP Pdu:system priority:32667 System mac address:00:23:0 4:EE:BE:D2 Oper key:1453 port priority:32768 Port number:8717 Port state:61=============================== ============= in order to enhance the network connectivity of the server, you can choose to use the mode=1 "primary-backup" policy to configure the two network cards: each time only one network card is active, in a network card problem can not be used when a quick switch to another card up, Ensure that the network is continuously available. Of course, the disadvantage is that only one NIC works each time, so the utilization of hardware resources is not high. Using four physical network cards, bind two groups of bond, namely BOND0 and Bond1. BOND0 adopts mode=4 mode, BOND1 adopts the main and standby mode of mode=1. So note that when you set up bond0 and Bond1, don't set two gateway addresses, or the network has a problem. Bond settings can not write the gateway address.
You can also use the following script to bind the network card settings as above, this is a generic script, directly copied to use! (The mode=4 mode is used in the script, and if other modes are used, the mode configuration will be modified in the script)
[[email protected] ~]# cat set_bond.sh #!/bin/bashif [$#! = 4]; Then echo "USAGE: $ bondname eth1 eth2 IP" echo "e.g.: $ bond1 em3 em4 10.0.1.1" Exit 1fi bondname=$1 CARD1=$2CA rd2=$3ip=$4gateway= ' Echo-n $IP | Awk-f '. ' ' {print $ '. ' $ $ '. ' $ $ '. '} ' "1 ' echo IP address is $IPecho netmask are 255.255.255.0echo gateway is $GATEWAYecho Bondname is $bondnameecho-E" \033[4 2;33M does want to go on (y| N) (NO and exit Default): \033[0m "read ANS case $ANS in y| y|yes| yes| YES);; n|no| no|no| N) exit 1;; *) echo "Exit Becasuse you cancel it" exit 1;; Esac#bond0 Configecho "device= $bondname" >/etc/sysconfig/network-scripts/ifcfg-$bondnameecho "Bootproto=none" >>/etc/sysconfig/network-scripts/ifcfg-$bondnameecho "Onboot=yes" >>/etc/sysconfig/network-scripts/ ifcfg-$bondnameecho "ipaddr= $IP" >>/etc/sysconfig/network-scripts/ifcfg-$bondnameecho "netmask= 255.255.255.0 ">>/etc/sysconfig/network-scripts/ifcfg-$bondnameecho "gateway= $GATEWAY" >>/etc/sysconfig/network-scripts/ifcfg-$bondnamecat >/etc/ sysconfig/network-scripts/ifcfg-$card 1 <<eofbootproto=nonedevice= $card 1onboot=yesmaster= $bondnameSLAVE = Yeseofcat >/etc/sysconfig/network-scripts/ifcfg-$card 2 <<eofbootproto=nonedevice= $card 2onboot=yesmaster = $bondnameSLAVE =yeseof#modprobe Configecho "Alias $bondname bonding" >>/etc/modprobe.d/bonding.confecho " Options $bondname miimon=100 mode=4 ">>/etc/modprobe.d/bonding.confmodprobe bonding# Restart the network card or restart the machine/etc/init.d/ Network restart
Execute script:
[[email protected] ~]# sh-x set_bond.sh bond0 eth0 eht1 10.0.54.28.....yes //You need to enter yes during execution ....
Operation Record of binding network card under Linux