One, Nic binding:
First step: Create a ifcfg-bondx
# vi/etc/sysconfig/network-scripts/ifcfg-Bond0device=bond0bonding_opts="mode=0 miimon=100"Bootproto=Noneonboot=Yesbroadcast=192.168.0.255ipaddr=192.168.0.180NETMASK=255.255.255.0NETWORK=192.168.0.0Userctl=nobonding_opts="mode=0 miimon=100", mode has multiple modes for different functions,
Step Two: Modify /etc/sysconfig/network-scripts/ifcfg-ethx
# vi/etc/sysconfig/network-scripts/ifcfg-eth0device=eth0bootproto=noneonboot=yesmaster=bond0slave= yesuserctl=no# vi/etc/sysconfig/network-scripts/ifcfg-eth1device=eth1bootproto=noneonboot=yesmaster= Bond0slave=yesuserctl=no
Step Three: Configure /etc/modprobe.conf, add alias bond0 bonding
Alias Scsi_hostadapter mptbasealias scsi_hostadapter1 mptspialias scsi_hostadapter2 ata_piixalias Scsi_hostadapter3 Ahcialias net-pf-10 offalias ipv6 offoptions IPv6 disable=1alias eth0 b0 back group name, eth0 And eth3 corresponds to Bond0alias eth1 b1alias eth2 e1000alias eth3 b0alias eth4 b1alias bond0 bondingalias bond1 bondingoptions Bond 0 miimon=100 mode=1 primary=eth0options bond1 miimon=100 mode=1 primary=eth1#options bonding max_bonds=2 miimon=200 mode= 1
Fourth step: Restart the Network Service
#service Network Restart
Check the/proc/net/bonding/bond0 to see what modeis currently in use, and if so, which NIC is currently working.
Cat/proc/net/bonding/bond0 Ethernet Channel Bonding driver:v3.4.0-1 (October 7,) bonding mode:fault-tolerance (acti Ve-backup) Primary Slave:eth0 (Primary_reselect always) currently Active slave:eth0mii status:upmii Polling Interval (ms) : 100Up Delay (ms): 0Down Delay (ms): 0Slave interface:eth0mii status:upspeed:1000 mbpsduplex:fulllink Failure Count: 0Permanent HW addr:00:0c:29:c8:7f:34slave interface:eth3mii status:upspeed:1000 mbpsduplex:fulllink Failure count:0p Ermanent HW addr:00:0c:29:c8:7f:52
Cat/proc/net/bonding/bond1ethernet Channel Bonding Driver:v3.4.0-1 (October 7) Bonding Mode:fault-tolerance (acti Ve-backup) Primary slave:nonecurrently Active slave:eth1mii status:upmii Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave interface:eth1mii status:upspeed:1000 mbpsduplex:fulllink Failure count:0permanent HW addr:00:0c: 29:c8:7f:3eslave interface:eth4mii status:upspeed:1000 mbpsduplex:fulllink Failure count:0permanent HW addr:00:0c:29 : c8:7f:5c
Seven Bond modes Description: 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, After passing through different links, there is a good chance that packets will arrive out of order at the client, and the unordered arrival packets need to be sent again, so the throughput of the network will drop.
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 availability of network connection, but its resource utilization is low, only one interface is working, and the resource utilization is 1/n in the case of N network interface.
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.3adDynamic Link Aggregation (IEEE 802.3ad dynamic Link 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 Balancer)
Features: This mode includes the 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.
Linux bond configuration steps, seven types of bond mode description