第 4 章 配置 NIC team
网络接口控制器(NIC)team 是一种组合或聚合物理和虚拟网络接口的方法,以提供具有高吞吐量或冗余的逻辑接口。NIC team 使用小内核模块来实现对数据包流和用于其他任务的用户空间服务的快速处理。这样,NIC team 是一种易扩展和可伸缩的解决方案,满足负载均衡和冗余要求。
Red Hat Enterprise Linux 为管理员提供不同的选项来配置团队设备。例如:
-
使用
nmcli
使用命令行配置团队连接。 - 使用 RHEL web 控制台使用 Web 浏览器配置组连接。
-
使用
nm-connection-editor
应用程序在图形界面中配置组连接。
NIC team 在 Red Hat Enterprise Linux 9 中已弃用。考虑使用网络绑定驱动程序作为替代方案。详情请参阅 配置网络绑定。
4.1. 将 NIC team 配置迁移到网络绑定
网络接口控制器(NIC)team 在 Red Hat Enterprise Linux 9 中已弃用。如果您已经配置了一个可工作的 NIC team,例如,因为您从较早的 RHEL 版本升级了,您可以将配置迁移到由 NetworkManager 管理的网络绑定。
team2bond
工具仅将 team 配置转换为绑定。之后,您必须手动配置绑定的进一步设置,如 IP 地址和 DNS 配置。
先决条件
-
team-team0
NetworkManager 连接配置集被配置并管理team0
设备。 -
已安装
teamd
软件包。
步骤
可选:显示
team-team0
NetworkManager 连接的 IP 配置:# nmcli connection show team-team0 | egrep "^ip" ... ipv4.method: manual ipv4.dns: 192.0.2.253 ipv4.dns-search: example.com ipv4.addresses: 192.0.2.1/24 ipv4.gateway: 192.0.2.254 ... ipv6.method: manual ipv6.dns: 2001:db8:1::fffd ipv6.dns-search: example.com ipv6.addresses: 2001:db8:1::1/64 ipv6.gateway: 2001:db8:1::fffe ...
将
team0
设备的配置导出到 JSON 文件中:# teamdctl team0 config dump actual > /tmp/team0.json
删除 NIC team 。例如,如果您在 NetworkManager 中配置了团队,请删除
team-team0
连接配置集以及相关端口的配置集:# nmcli connection delete team-team0 # nmcli connection delete team-team0-port1 # nmcli connection delete team-team0-port2
以空运行模式运行
team2bond
程序,显示nmcli
命令,该命令使用类似设置的网络绑定设置为团队设备:# team2bond --config=/tmp/team0.json --rename=bond0 nmcli con add type bond ifname bond0 bond.options "mode=active-backup,num_grat_arp=1,num_unsol_na=1,resend_igmp=1,miimon=100,miimon=100" nmcli con add type ethernet ifname enp7s0 controller bond0 nmcli con add type ethernet ifname enp8s0 controller bond0
第一个命令包含两个
miimon
选项,因为团队配置文件包含两个link_watch
条目。请注意,这不会影响创建绑定。如果您将服务绑定到团队的设备名称并希望避免更新或破坏这些服务,请省略
--rename=bond0
选项。在这种情况下,team2bond
为绑定使用与团队相同的接口名称。-
验证推荐
team2bond
工具的绑定选项是否正确。 创建绑定。您可以执行建议的
nmcli
命令,或使用--exec-cmd
选项重新运行team2bond
命令:# team2bond --config=/tmp/team0.json --rename=bond0 --exec-cmd Connection 'bond-bond0' (0241a531-0c72-4202-80df-73eadfc126b5) successfully added. Connection 'bond-port-enp7s0' (38489729-b624-4606-a784-1ccf01e2f6d6) successfully added. Connection 'bond-port-enp8s0' (de97ec06-7daa-4298-9a71-9d4c7909daa1) successfully added.
下一步需要绑定连接配置集的名称(
bond-bond0
)。将之前在
team-team0
中配置的 IPv4 设置设置为bond-bond0
连接:# nmcli connection modify bond-bond0 ipv4.addresses '192.0.2.1/24' # nmcli connection modify bond-bond0 ipv4.gateway '192.0.2.254' # nmcli connection modify bond-bond0 ipv4.dns '192.0.2.253' # nmcli connection modify bond-bond0 ipv4.dns-search 'example.com' # nmcli connection modify bond-bond0 ipv4.method manual
将之前在
team-team0
中配置的 IPv6 设置设置为bond-bond0
连接:# nmcli connection modify bond-bond0 ipv6.addresses '2001:db8:1::1/64' # nmcli connection modify bond-bond0 ipv6.gateway '2001:db8:1::fffe' # nmcli connection modify bond-bond0 ipv6.dns '2001:db8:1::fffd' # nmcli connection modify bond-bond0 ipv6.dns-search 'example.com' # nmcli connection modify bond-bond0 ipv6.method manual
激活连接:
# nmcli connection up bond-bond0
验证
显示
bond-bond0
NetworkManager 连接的 IP 配置:# nmcli connection show bond-bond0 | egrep "^ip" ... ipv4.method: manual ipv4.dns: 192.0.2.253 ipv4.dns-search: example.com ipv4.addresses: 192.0.2.1/24 ipv4.gateway: 192.0.2.254 ... ipv6.method: manual ipv6.dns: 2001:db8:1::fffd ipv6.dns-search: example.com ipv6.addresses: 2001:db8:1::1/64 ipv6.gateway: 2001:db8:1::fffe ...
显示绑定状态:
# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v5.13.0-0.rc7.51.el9.x86_64 Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: enp7s0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Peer Notification Delay (ms): 0 Slave Interface: enp7s0 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 52:54:00:bf:b1:a9 Slave queue ID: 0 Slave Interface: enp8s0 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 52:54:00:04:36:0f Slave queue ID: 0
在这个示例中,两个端口都是上线的。
验证绑定故障切换是否正常工作:
- 从主机中临时删除网络电缆。请注意,无法使用命令行正确测试链路失败事件。
显示绑定状态:
# cat /proc/net/bonding/bond0