bond接口与team接口的区别:
bond接口:仅支持2块网卡
team接口:与bond接口功能类似,区别在于team不需要手动加载相应的内核模块, 它有更强的拓展性,支持8块网卡
bond网络接口
概述:
1.什么是bond?
网卡bond是通过多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡,在生产场景中是一种常用的技术
2.bond常用的2种模式
01.mode=0(balance-rr)
> 表示负载分担round-robin,并且是轮询的方式比如第一个包走eth0,第二个包走eth1,直到数据包发送完毕。
>
> 优点:流量提高一倍
>
> 缺点:需要接入交换机做端口聚合,否则可能无法使用
02.mode=1(active-backup)
表示主备模式,即同时只有1块网卡在工作。
优点:冗余性高
缺点:链路利用率低,两块网卡只有1块在工作
##命令配置bond网络接口
在虚拟机上添加网卡,使之有多个网卡可调配
配置bond接口
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.134/24
ip addr show
为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
建立监控
watch -n 1 cat /proc/net/bonding/bond0
分别使用命令
ifconfg eth0 down
ifconfg eth1 down
ifconfg eth0 up
ifconfg eth1up
观察效果
team网络接口
1.什么是team?
team实现的功能跟bond相似,team本质上也是一个虚拟的网卡驱动(networkdevicedriver),
只不过并没有真实的物理网卡与之对应,而是由这个虚拟网卡去“管辖”一系列的真实的物理网卡,
它的代码结构和一般网卡驱动的代码结构非常类似。
2.team的种类?
broadcast # 广播容错
roundrobin # 平衡轮叫
activebackup # 主备模式
loadbalance # 负载均衡模式,判断不同网卡的负载,给负载最少的网卡发送数据包
配置team接口
还原环境
nmcli connection delete bond0
删除网卡
nmcli connection delete eth0
nmcli connection delete eth1
利用命令
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.134/24
搭建team接口
监控命令
watch -n 1 teamdctl team0 stat
重新添加网卡,并改变其类型
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
使用命令
ifconfg eth0 down
ifconfg eth1 down
ifconfg eth0 up
ifconfg eth1up
观察效果