Network Teaming
对网络物理链路进行组合或聚合,以提供具有更高吞吐量的逻辑链路或冗余能力,这个最初在Linux内核中实现的概念被广泛地称为bonding
,Network Teaming被选择来指代这个概念的新实现,现有的bonding
驱动程序不受影响.Team提供一个小型内核驱动程序来实现包的快速处理,并提供各种用户空间应用程序来完成用户空间中的其他所有工作。
Team
与bonding
的对比
Feature | Bonding | Team |
---|---|---|
broadcast Tx policy | Yes | Yes |
round-robin Tx policy | Yes | Yes |
active-backup Tx policy | Yes | Yes |
LACP (802.3ad) support | Yes (active only) | Yes |
Hash-based Tx policy | Yes | Yes |
User can set hash function | No | Yes |
Tx load-balancing support (TLB) | Yes | Yes |
LACP hash port select | Yes | Yes |
load-balancing for LACP support | No | Yes |
Ethtool link monitoring | Yes | Yes |
ARP link monitoring | Yes | Yes |
NS/NA (IPv6) link monitoring | No | Yes |
ports up/down delays | Yes | Yes |
port priorities and stickiness (“primary” option enhancement) | No | Yes |
separate per-port link monitoring setup | No | Yes |
multiple link monitoring setup | Limited | Yes |
lockless Tx/Rx path | No (rwlock) | Yes (RCU) |
VLAN support | Yes | Yes |
user-space runtime control | Limited | Full |
Logic in user-space | No | Yes |
Extensibility | Hard | Easy |
Modular design | No | Yes |
Performance overhead | Low | Very Low |
D-Bus interface | No | Yes |
multiple device stacking | Yes | Yes |
zero config using LLDP | No | (in planning) |
NetworkManager support | Yes | Yes |
Team模式
- broadcast:广播模式,数据传输到所有端口。
- round-robin :轮询模式,数据依次在所有端口上传输。
- active-backup :主备模式,当其他端口/链接作为backup时,使用一个端口/链接。
- loadbalance:负载均衡模式,具有Tx负载均衡和基于bpf的Tx端口选择器。
- lacp :lacp模式,需要交换机开启lacp协议。
配置Team
查看网络设备
# nmcli connection show
NAME UUID TYPE DEVICE
ens33 ec77b707-d5a8-43b2-963e-bf5ed6837418 ethernet ens33
Wired connection 1 c5ec8230-4f6b-315b-9e3b-71f74b397764 ethernet ens37
Wired connection 2 3db638ab-7ca7-3cee-a7ac-81a79d658939 ethernet ens38
查看设备连接状态
# nmcli device status
DEVICE TYPE STATE CONNECTION
ens33 ethernet connected ens33
ens37 ethernet connected Wired connection 1
ens38 ethernet connected Wired connection 2
lo loopback unmanaged --
创建team接口,名称为team0,配置为主备模式
# nmcli connection add type team ifname team0 con-name team0 ipv4.addresses 192.168.240.138/24 ipv4.method manual ipv4.gateway 192.168.240.2 autoconnect yes config '{"runner":{"name":"activebackup"}}'
Connection 'team0' (c54cd942-fb78-4eee-aa10-022d2fe55187) successfully added.
执行成功后,会生成配置文件,路径为/etc/sysconfig/network-scripts/ifcfg-team0
添加ens37设备到team中
# nmcli con add type team-slave con-name team0-port1 ifname ens37 master team0
Connection 'team0-port1' (d6c693e6-0c29-413f-804c-5b0b9aeeed3c) successfully added.
添加ens38设备到team中
# nmcli con add type team-slave con-name team0-port2 ifname ens38 master team0
Connection 'team0-port2' (9b7bed39-9006-4a2d-9582-9ee30114fbf2) successfully added.
启用连接
# nmcli conn up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
# nmcli conn up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
查看连接状态
# nmcli conn
NAME UUID TYPE DEVICE
ens33 ec77b707-d5a8-43b2-963e-bf5ed6837418 ethernet ens33
team0 c54cd942-fb78-4eee-aa10-022d2fe55187 team team0
team0-port1 79b2e171-b645-481f-af16-a68af4aab4ed ethernet ens37
team0-port2 9b7bed39-9006-4a2d-9582-9ee30114fbf2 ethernet ens38
Wired connection 1 c5ec8230-4f6b-315b-9e3b-71f74b397764 ethernet --
Wired connection 2 3db638ab-7ca7-3cee-a7ac-81a79d658939 ethernet --
查看team状态
# teamdctl team0 state
setup:
runner: activebackup
ports:
ens37
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens37
日常管理操作
查看team状态
# teamdctl team0 state
setup:
runner: activebackup
ports:
ens37
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens37
从team中移除设备
# teamdctl team0 port remove ens37
[root@localhost ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens38
添加设备到team中
# teamdctl team0 state
setup:
runner: activebackup
ports:
ens37
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens38
参考文档
- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-Understanding_the_Network_Teaming_Daemon_and_the_Runners