精读笔记(RHCA 英文教材)· RH358 Chapter 2 Configuring Link Aggregation
精读笔记(RHCA 英文教材)· RH358 Chapter 2 Configuring Link Aggregation
教材原文:RHCA 官方英文教材(教材第 3~4 页)(OCR 整书版已从本站移除,本页为章节精读) 说明:本教材到手版本为 Instructor Guide(讲师手册),每章给出 Schedule/Objectives/Key Takeaways/教学提示,正文细节需配合学生手册与实验;本笔记按“讲义要点 + 必要补充”双语整理。 关联知识:
02-04-日志与网络、02-08-Ansible自动化;前置:RH358 Chapter 1 的 NetworkManager/nmcli 与 systemd 服务管理
Chapter 2 | Configuring Link Aggregation(配置链路聚合)
Chapter Objectives(本章目标)
By the end of this chapter, students should be able to:
- Use network teaming to provide link redundancy or higher throughput.(用 network teaming 提供链路冗余或更高吞吐)
- Manage a network team interface.(管理网络 team 接口)
- Automate the creation and configuration of a network team with Ansible.(用 Ansible 自动化创建与配置网络 team)
Chapter Schedule(课时,共 90 分钟)
| Section | 主题 | 方法 |
|---|---|---|
| 1 | Configuring Network Teaming | Lecture/Demo + Guided Exercise(各 10 分钟) |
| 2 | Managing Network Teaming | Lecture/Demo + Guided Exercise(各 15 分钟) |
| 3 | Automating Network Teaming | Lecture/Demo 10 分钟 + Guided Exercise 15 分钟 |
| - | Lab Performance Checklist | 15 分钟 |
Key Takeaways(本章要点)
Define and activate network teams.(定义并激活网络 team) Change the configuration of a network team.(修改网络 team 配置) Change the runner used by a team interface.(更换 team 接口使用的 runner) Troubleshoot a network team with teamnl and teamdctl.(用 teamnl 与 teamdctl 排障) Automate the creation and configuration of network teams by using the
rhel-system-roles.networkAnsible Role and Ansible modules.(用 rhel-system-roles.network 角色与 Ansible 模块自动化) 中文归纳:① 建 team(把多块物理网卡聚合为一个逻辑接口);② 改 team 配置;③ 换 runner(负载均衡算法);④ teamnl/teamdctl 排障;⑤ rhel-system-roles.network 做自动化。
Instructor Tips(讲师提示:teaming vs bonding)
- Linux 更早的链路聚合方案叫 channel bonding(内核驱动实现,绑定为 bond 接口);RHEL 8 出于向后兼容仍提供 bonding。
- network teaming 性能更好、扩展性更强(模块化设计:内核 team 驱动 + 用户态 teamd 守护进程),相对 bonding 还有多项优势。
- 方法对比表见 Red Hat 文档:
comparison-of-network-teaming-and-bonding-features(RHEL 8 Configuring and managing networking)。
补充精讲 A:网络 team 基础(Section 1 对应知识)
- 概念:Network Teaming = 把多块物理网卡(port/成员口)聚合为一个逻辑 team 接口,对外呈现单块网卡;好处:① 冗余(一块网卡/链路断掉流量自动切到其余成员,业务不断);② 更高吞吐(多链路分摊流量)。
- 组成:内核
team驱动创建虚拟 team 设备 + 用户态 teamd(守护进程管理端口状态与负载均衡)+ libteam 库;一个 team 接口由若干 “port” 组成。 - 与 bonding 差异速记:bonding 是内核驱动(RHEL 兼容保留);teaming 是“内核驱动+用户态 teamd”的模块化实现,runner 算法可热切换、可扩展。
- RHEL 8 里 team 与 bond 配置都由 NetworkManager 统一管理(连接配置档在
/etc/NetworkManager/system-connections/),支持 nmcli 配置。
补充精讲 B:nmcli 创建与管理 team(Section 2 对应知识)
- 典型两步(先建 team 主连接,再给每块物理网卡建 team-slave 连接并挂进 team): | 步骤 | 命令示例 | | --- | --- | | 建 team 主连接(LACP runner、静态 IP) |
nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"lacp"}}' ipv4.method manual ipv4.addresses 192.0.2.10/24| | 建第 1 块成员口 |nmcli connection add type team-slave con-name team0-port1 ifname eth1 master team0| | 建第 2 块成员口 |nmcli connection add type team-slave con-name team0-port2 ifname eth2 master team0| | 启用 team |nmcli connection up team0| - runner 选择(决定流量分配算法):
activebackup(主备冗余,一块 active,断线切备)、loadbalance(基于 L4 哈希均衡 + 发送侧负载均衡,吞吐优先)、lacp(802.3ad 链路聚合控制协议,需交换机支持)、broadcast/roundrobin/random等。 - 查看与修改:
nmcli connection show team0;改 runner:nmcli connection modify team0 team.config '{"runner":{"name":"activebackup"}}'后nmcli connection up team0生效;加删成员口即再建/删 team-slave 连接。 - 验证:
ip link show team0(看状态/成员)、teamdctl team0 state(看端口与 runner 状态)。
补充精讲 C:teamnl / teamdctl 排障(Key Takeaway 4)
teamdctl:teamd 的控制与状态查询工具。 | 命令 | 作用 | | --- | --- | |teamdctl team0 state| 查看 team 整体状态(setup/runner/端口 up/down) | |teamdctl team0 port list/port config dump| 查看成员口列表/配置 | |teamdctl team0 state view| 详细状态视图 |teamnl:直接与内核 team 驱动交互的低层排障工具(无需依赖 teamd 状态机)。 | 命令 | 作用 | | --- | --- | |teamnl team0 ports| 列出内核视角的 team 成员口及状态 | |teamnl team0 options| 查看 team 选项 | |teamnl team0 getoption .../setoption ...| 读写内核 team 选项 |- 排障思路:先
nmcli connection show确认连接 up →teamdctl team0 state看 teamd 认识哪些端口、是否 active →teamnl team0 ports看内核链路实际状态(对比找“配置了但内核没起来”的口)→ 查物理线缆/交换机端口/team-slave 连接。
补充精讲 D:用 Ansible 自动化(Section 3 对应知识)
- 首选官方角色
rhel-system-roles.network:安装yum install rhel-system-roles;角色的network_connections列表支持type: team与type: team-slave,幂等管理连接配置档。 - 要点:team 主连接声明
type: team+team: {runner: ...}(如{"runner": {"name": "lacp"}}),成员口声明type: team-slave+controller: team0;可配 ipv4/ipv6、state: up。 - 若不用角色也可用内核模块与模板+服务模块组合,但官方建议 system role 保证幂等与一致性。
- 章节 Lab:建 team(两块网卡聚合)+ 换 runner + 破坏/恢复成员口观察冗余切换,并用 Ansible 复现同一 team 配置。
核心词汇表
| 英文 | 中文速记 |
|---|---|
| link aggregation / teaming | 链路聚合 / 网络聚合 |
| network team (team interface) | team 逻辑接口(多物理口合一) |
| teamd / teamdctl / teamnl | team 守护进程 / 控制工具 / 内核级排障工具 |
| port / slave | team 的成员口(物理网卡) |
| runner | 流量分配算法(activebackup/loadbalance/lacp…) |
| channel bonding | 内核 bond 聚合(旧方案,RHEL 8 兼容) |
| redundancy / throughput | 冗余 / 吞吐 |
| LACP (802.3ad) | 链路聚合控制协议(需交换机配合) |
| rhel-system-roles.network | 官方网络系统角色(自动化 team/bond/eth) |
| connection profile | NetworkManager 连接配置档 |
本章自测
- network teaming 解决什么问题?与 channel bonding 的根本区别?
- 创建 team 需要哪两类连接(主连接/成员口),nmcli 命令怎么拼?
- runner 常见三种及适用场景?如何在线更换 runner?
- teamdctl 与 teamnl 分工有何不同?
- 用 rhel-system-roles.network 自动化 team 的关键字段是什么?
- 讲师手册 Key Takeaways 五条分别是什么?
