常用模式:
Mode 0(balance-rr):轮询(round-robin),轮询的在每个接口上发送数据包。该用法提供负载均衡及容错能力。
Mode 1(active-backup):主备模式,只有个slave被激活,当且仅当活动的slave接口失败时候,才会激活其他的salve,为了避免交换机发生混乱,此时绑定mac地址只有一个是可见的。
Modle 3 (broadcast):广播策略,在所有的slave接口传送报文,提供容错能力。
active-backup、balance-tlb 和 balance-alb 模式不需要交换机的任何特殊配置。其他绑定模式需要配置交换机以便整合链接。如:Cisco 交换机需要在模式 0、2 和 3 中使用 EtherChannel,但在模式4中需要 LACP和 EtherChannel。
实操:双网卡绑定,主备模式实现。
#创建bond配置文件
[root@cenots7 network-scripts]#pwd
/etc/sysconfig/network-scripts
[root@cenots7 network-scripts]#cat ifcfg-bond0
DEVICE=bond0 #设备名,虚拟的
ONBOOT=yes
BOOTPROTO=static
BONDING_OPTS="miimon=100 mode=1" #表示100毫秒监测一次链路是否通畅,mode=1,主备模式
IPADDR=192.168.38.56
NETMASK=255.255.255.0
#修改两块网卡,加入该bond0,
[root@cenots7 network-scripts]#cat ifcfg-bth0
DEVICE=ens33
TYPE=Ethernet
ONBOOT=yes
SLAVE=yes
MASTER=bond0
[root@cenots7 network-scripts]#cat ifcfg-bth1
DEVICE=ens37
TYPE=Ethernet
ONBOOT=yes
MASTER=bond0
SLAVE=yes
网络拓扑常采用如下:
| | |port3 port3| +-----+----+ +-----+----+ | |port2 ISL port2| | | switch A +--------------------------+ switch B | | | | | +-----+----+ +-----++---+ |port1 port1| | +-------+ | +-------------+ host1 +---------------+ eth0 +-------+ eth1
switchA swichB通过trunk口连接。避免单点失败
删除bond0
ifconfig bond0 down
rmmod bonding