前言:
Teaming 技术:可以把同一台服务器上的多个物理网卡绑定成一个虚拟的网卡,利用Teaming 技术,可以提高网络速度、实现不同网卡之间的负载(Load balancing)和网卡冗余(Fault tolerance);
与bonding的关系
在RHEL5/RHEL6中使用的是Bonding,而RHEL7提供了一项新的实现技术Teaming,用来实现链路聚合的功能,但在RHEL7中,不会使用teaming替换bonding,它们是并存的,我们可以选择Teaming,也可以选择Bonding。
teaming 技术有多种模式(runner)
1)、broadcast(广播):数据通过所有端口传输,即复制一份数据向两块网卡发出
2)、roundrobin(轮询):轮询模式,所有链路处于负载均衡状态,这种模式的特点增加了带宽,同时支持容错能力(使用时会有自动丢包情况)。
3)、activebackup(主备):类似于bonding技术的bond1模式,只有主链路在工作,当主链路断开后备链路会接替,接替过程会有两个包的延迟(丢包)
4)、loadbalance(负载均衡):具有活动的Tx负载平衡和基于BPF的Tx端口选择器(使用时会有自动丢包情况)
5)、lacp (implements the 802.3ad Link Aggregation Control、Protocol):类似于bonding技术的bond4模式,需要交换机支持802.3ad(LACP)协议
下面使用以下两个网卡进行绑定:
1、创建一个名为team0的网络端口,模式为activebackup(主备模式)
[root@localhost ~]# nmcli connection add con-name "team0" type team ifname team0 config '{"runner":{"name":"activebackup"}}'
2、修改team0网口的IP地址,网关和DNS
[root@localhost ~]# nmcli connection modify team0 ipv4.addresses "192.168.10.100/24" ipv4.dns "8.8.8.8,114.114.114.114" connection.autoconnect yes ipv4.method manual
[root@localhost ~]# echo "GATEWAY0=192.168.10.1" >> /etc/sysconfig/network-scripts/ifcfg-team0
//创建team0后会在/etc/sysconfig/network-scripts/目录下生成ifcfg-team0的文件
3、将名为eno33554968网卡添加到team0,并且改名为eth1
[root@localhost ~]# nmcli connection add con-name eth1 ifname eno33554968 type team-slave master team0
4、将名为eno50332192网卡添加到team0,并且改名为eth2
[root@localhost ~]# nmcli connection add con-name eth2 ifname eno50332192 type team-slave master team0
5、启动team0并且重启网络服务
[root@localhost ~]# nmcli connection up team0 ; systemctl restart network
6、查看team0的状态
[root@localhost ~]# teamdctl team0 state
=========================================================================================
7、在activebackup(主备)模式下如某个网口断掉会丢两个包,当接口恢复也会丢两个包
[root@localhost ~]# nmcli connection down eth1 //关闭网口
[root@localhost ~]# nmcli connection up eth1 //启用网口
8、最后如想恢复按顺序将其删除,然后重新加载即可
[root@localhost ~]# nmcli connection delete eth1
[root@localhost ~]# nmcli connection delete eth2
[root@localhost ~]# nmcli connection delete team0
[root@localhost ~]# nmcli connection reload
参考: