一.bond网络
网卡bond是通过多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡。bond模式共有平衡轮询、主动备份、广播三种。
1:平衡轮循-轮循策略
mode=0(balance-rr)
所有接口都采用轮循方式在所有Slave中传输封包;任何Slave都可以接收。
2:主动备份-容错
mode=1(active-backup)
一次只能使用一个Slave接口,但是如果出现该接口故障,另一个Slave将接替它。
配置:建立绑定bond0配置文件
vim /etc/sysconfig/network-scripts/ifcfg-bond0
>DEVICE="bond0"
BOOTPROTO="none"
IPADDR="10.1.1.250"
PREFIX="24"
ONBOOT="yes"
BONDING_OPTS="mode=1 millon=50"
3.广播-容错
所有封包都通过所有Slave接口广播。
4.配置
添加bond
mcli connection add type bond con-name bond0 ifname bond0 mode active-backup ip4 172.25.254.136/24
监测bond变动以及网络状态(新开一个终端)
watch -n 1 cat /proc/net/bonding/bond0
分别绑定两块网卡到bond上去:
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
通过停掉其中一块网卡观察bond反应以及网络变化
ifconfig eth0 down#停掉eth0
nmcli connection delete eth0#将eth0从bond解绑
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0#加上eth0
ifconfig eth1 down#停掉eth1
二.Team模式
Team和bond0功能相似;Team不需要手动加载相应内核模块;Team有更强的拓展性;支持8块网卡。Team模式共有广播容错、平衡轮叫、主备和负载均衡四种。
配置
添加team,名字为team0
nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.136/24
监测team0变动以及网络状态
watch -n 1 teamdctl team0 state
绑定多块(此处为eth0,eht1,eth2)网卡到team0上去:
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
nmcli connection add con-name eth2 ifname eth2 type team-slave master team0
测试:通过停掉其中一块或者多块网卡观察team0反应以及网络变化
ifconfig eth0 down
ifconfig eth0 up
ifconfig eth1 down
ifconfig eth1 up
ifconfig eth2 down
ifconfig eth2 up
ifconfig eth1 down
ifconfig eth0 up
测试结果展示1:添加完成正常运行后将所有网卡停掉,结果ping命令暂停,后面出现主机无法到达的提示
测试结果展示2.将所有停掉的网卡中的一块启动,网络就恢复了正常