1. linux有七种网卡绑定模式:
模式代号 | 模式名称---------------------------------------------- | 模式方式 | 说明 |
---|---|---|---|
0 | (balance-rr) Round-robin policy | 轮询策略 | 该策略是按照设备顺序依次传输数据包,直到最后一个设备。这种模式提供负载均衡和容错能力。 |
1 | (active-backup) Active-backup policy | 主备策略 | 该策略只有一个设备处于活动状态。 一个宕掉另一个马上由备份转换为主设备。mac地址是外部可见的。 此模式提供了容错能力。 |
2 | (balance-xor) XOR policy | 异或策略 | 该策略是根据MAC地址异或运算的结果来选择传输设备,提供负载均衡和容错能力。 |
3 | Broadcast policy | 广播策略 | 该策略将所有数据包传输给所有接口通过全部设备来传输所有数据,提供容错能力。 |
4 | (802.3ad) IEEE 802.3ad Dynamic link aggregation | 动态链接聚合 | 该策略通过创建聚合组来共享相同的传输速度,需要交换机也支持 802.3ad 模式,提供容错能力。 |
5 | (balance-tlb) Adaptive transmit load balancing | 适配器传输负载均衡 | 该策略是根据当前的负载把发出的数据分给每一个设备,由当前使用的设备处理收到的数据。本策略的通道联合不需要专用的交换机支持,提供负载均衡和容错能力。 |
6 | (balance-alb) Adaptive load balancing | 适配器负载均衡 | 该策略在IPV4情况下包含适配器传输负载均衡策略,由ARP协商完成接收的负载,通道联合驱动程序截获ARP在本地系统发送出的请求,用其中一个设备的硬件地址覆盖从属设备的原地址。 |
以下只看主备模式
2. 第一组bonding网卡配置
2.1. 查看网卡bonding状态
~]# cat /proc/net/bonding/bondeth0
其中Currently Active Slave列出了bonding当前的活动网卡名称。
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth3
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 5000
Down Delay (ms): 2000
Slave Interface: eth3
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: bc:97:e1:c7:db:30
Slave queue ID: 0
Slave Interface: eth4
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: bc:97:e1:c7:db:38
Slave queue ID: 0
2.2. 查看 ifcfg-bondeth0 配置
~]# cat /etc/sysconfig/network-scripts/ifcfg-bondeth0
#### DO NOT REMOVE THESE LINES ####
#### %GENERATED BY CELL% ####
DEVICE=bondeth0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="mode=active-backup miimon=100 downdelay=2000 updelay=5000 num_grat_arp=100"
IPV6INIT=no
IPADDR=192.168.37.3
NETMASK=255.255.255.0
GATEWAY=192.168.37.1
NETWORK=192.168.37.0
BROADCAST=192.168.37.255
2.3. 查看 ifcfg-eth3 配置
~]# cat /etc/sysconfig/network-scripts/ifcfg-eth3
#### DO NOT REMOVE THESE LINES ####
#### %GENERATED BY CELL% ####
DEVICE=eth3
USERCTL=no
ONBOOT=yes
MASTER=bondeth0
SLAVE=yes
BOOTPROTO=none
HOTPLUG=no
IPV6INIT=no
ETHTOOL_OPTS="speed 10000 duplex full autoneg off"
2.4. 查看 ifcfg-eth4 配置
~]# cat /etc/sysconfig/network-scripts/ifcfg-eth4
#### DO NOT REMOVE THESE LINES ####
#### %GENERATED BY CELL% ####
DEVICE=eth4
USERCTL=no
ONBOOT=yes
MASTER=bondeth0
SLAVE=yes
BOOTPROTO=none
HOTPLUG=no
IPV6INIT=no
ETHTOOL_OPTS="speed 10000 duplex full autoneg off"
3. 第二组bonding网卡配置
3.1. 查看网卡bonding状态
~]# cat /proc/net/bonding/bondeth1
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 5000
Down Delay (ms): 2000
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:10:e0:fa:cf:85
Slave queue ID: 0
Slave Interface: eth2
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:10:e0:fa:cf:86
Slave queue ID: 0
3.2. 查看 ifcfg-bondeth1 配置
~]# cat /etc/sysconfig/network-scripts/ifcfg-bondeth1
#### DO NOT REMOVE THESE LINES ####
#### %GENERATED BY CELL% ####
DEVICE=bondeth1
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="mode=active-backup miimon=100 downdelay=2000 updelay=5000 num_grat_arp=100"
IPV6INIT=no
IPADDR=192.168.38.3
NETMASK=255.255.255.0
GATEWAY=192.168.38.1
NETWORK=192.168.38.0
BROADCAST=192.168.38.255
3.3. 查看 ifcfg-eth1 配置
~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
#### DO NOT REMOVE THESE LINES ####
#### %GENERATED BY CELL% ####
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bondeth1
SLAVE=yes
BOOTPROTO=none
HOTPLUG=no
IPV6INIT=no
3.3. 查看 ifcfg-eth1 配置
~]# cat /etc/sysconfig/network-scripts/ifcfg-eth2
#### DO NOT REMOVE THESE LINES ####
#### %GENERATED BY CELL% ####
DEVICE=eth2
USERCTL=no
ONBOOT=yes
MASTER=bondeth1
SLAVE=yes
BOOTPROTO=none
HOTPLUG=no
IPV6INIT=no