精读笔记(RHCA 英文教材)· RH358 Chapter 1 Managing Network Services
大约 4 分钟
精读笔记(RHCA 英文教材)· RH358 Chapter 1 Managing Network Services
教材原文:RHCA 官方英文教材(教材第 1~2 页)(OCR 整书版已从本站移除,本页为章节精读) 说明:本教材到手版本为 Instructor Guide(讲师手册),每章给出 Schedule/Objectives/Key Takeaways/教学提示,正文细节需配合学生手册与实验;本笔记按“讲义要点 + 必要补充”双语整理。 关联知识:
02-04-日志与网络、02-05-服务管理与安全、02-08-Ansible自动化
Chapter 1 | Managing Network Services(管理网络服务)
Chapter Objectives(本章目标)
By the end of this chapter, students should be able to:
- Discuss the goal of this course and review how to manage services.(理解课程目标并复习服务管理)
- Review how to configure and manage network interfaces with NetworkManager and related tools.(用 NetworkManager 及相关工具配置管理网卡)
- Automate configuration of services and network interfaces with Ansible.(用 Ansible 自动化服务与网卡配置)
Chapter Schedule(课时,共 115 分钟)
| Section | 主题 | 方法 |
|---|---|---|
| 1 | Controlling Network Services | Lecture + Demo / Guided Exercise(各 10 分钟) |
| 2 | Configuring Network Interfaces | Lecture / Guided Exercise(各 15 分钟) |
| 3 | Automating Service and Network Interface Configuration | Lecture / Guided Exercise(各 20 分钟) |
| - | Lab Performance Checklist | 25 分钟 |
Key Takeaways(本章要点)
Determine the status of system daemons and network services started by systemd. Start, stop, and enable services using systemctl. Configure IPv4 and IPv6 networking using nmcli. Use Ansible to configure network settings using the
rhel-system-roles.networkrole. 中文归纳:① 用 systemd 判断守护进程/网络服务状态;② systemctl 启停与开机自启;③ nmcli 配置 IPv4/IPv6;④ 用rhel-system-roles.network角色做网络自动化。
补充精讲 A:systemd 服务管理(Section 1 对应知识)
- 服务由 unit(单元)描述,服务类单元后缀
.service;单元文件在/usr/lib/systemd/system/(软件自带)与/etc/systemd/system/(管理员自定义,优先级高)。 - 查看/控制命令: | 命令 | 作用 | | --- | --- | |
systemctl status httpd| 查看服务状态(含是否 enable) | |systemctl start/stop/restart/reload 服务| 启/停/重启/重载配置 | |systemctl enable/disable 服务| 开机自启/取消自启(enable 建软链接) | |systemctl --now enable 服务| 立即启动并设置自启 | |systemctl is-active/is-enabled 服务| 只回状态字(active/enabled),便于脚本判断 | |systemctl list-units --type=service| 列出服务单元 | |journalctl -u 服务| 查看某服务日志 | - 判断“服务是否真在运行”别只看进程名:
systemctl status/systemctl is-active更权威。
补充精讲 B:NetworkManager 与 nmcli(Section 2 对应知识)
- RHEL 网络由 NetworkManager 守护进程统一管理,推荐命令行工具 nmcli(配置文件在
/etc/NetworkManager/system-connections/,也可用nmtui文本界面)。 - 核心概念:connection(连接配置档,可理解为一套网卡配置)绑在 device(物理网卡)上。
- 常用 nmcli 命令: | 场景 | 命令 | | --- | --- | | 查看设备/连接 |
nmcli device status、nmcli connection show| | 新建静态 IPv4 |nmcli connection add con-name eth0-static type ethernet ifname eth0 ipv4.method manual ipv4.addresses 192.0.2.10/24 ipv4.gateway 192.0.2.1 ipv4.dns 192.0.2.53| | 动态 DHCP | 上面命令把ipv4.method改auto即可 | | 同时配 IPv6 | 加ipv6.method manual ipv6.addresses 2001:db8::10/64| | 启用连接 |nmcli connection up eth0-static| | 改已有连接 |nmcli connection modify eth0-static ipv4.addresses ...后 up 生效 | | 删除连接 |nmcli connection delete eth0-static| | 立即激活自动生成的配置 |nmcli device reapply eth0| - 判断生效:
ip addr show、ip route(RHEL8/9 中 ifconfig 属旧工具,需 net-tools)。
补充精讲 C:用 Ansible 自动化(Section 3 对应知识)
- 安装系统角色:
yum install rhel-system-roles(RHEL8/9 官方支持)。 - 网络配置走
rhel-system-roles.network角色:角色管理/etc/NetworkManager/system-connections/,幂等、可批量。 - 最小 playbook 思路:
- name: Configure network using system role hosts: servers roles: - rhel-system-roles.network # vars: 声明 network_connections 列表(name/type/state/ip 等) - 服务自动化同理:Ansible 的
service/systemd模块封装 systemctl 语义(state=started/enabled、daemon_reload),把“服务管理”变成可审计代码。 - 章节 Lab:用一台虚拟机依次完成 systemctl 查看/启停服务、nmcli 配网、再写一个调用 system role 的 playbook 复现同样配置。
核心词汇表
| 英文 | 中文速记 |
|---|---|
| network service | 网络服务 |
| daemon | 守护进程(后台服务) |
| systemd unit | systemd 单元(.service/.socket…) |
| enable / disable | 开机自启 / 取消自启 |
| NetworkManager | RHEL 网络管理守护进程 |
| nmcli | NetworkManager 命令行工具 |
| connection profile | 连接配置档 |
| ethernet device | 物理以太网设备 |
| static / dhcp (auto) | 静态配置 / 动态获取 |
| IPv4/IPv6 addressing | 双栈地址配置 |
| rhel-system-roles.network | 官方网络系统角色 |
| idempotent configuration | 幂等配置(重复跑结果一致) |
本章自测
- systemd 中 enable 与 start 的区别?2. 如何判断某服务是否开机自启?3. nmcli 新建静态 IPv4 连接的核心参数有哪些?4. DHCP 与静态在 nmcli 里 method 分别是什么?5. 用哪个角色做网络自动化?6. 讲师手册 Key Takeaways 四条分别是什么?
