精读笔记(RHCA 英文教材)· RH436 Chapter 12 Eliminating Single Points of Failure
大约 6 分钟
精读笔记(RHCA 英文教材)· RH436 Chapter 12 Eliminating Single Points of Failure
教材原文:RHCA 官方英文教材(PDF 第 389~412 页)(OCR 整书版已从本站移除,本页为章节精读) 关联知识:Ch1(建集群)、Ch3(fencing);本章=把集群自身短板补齐:① 集群通信多网络链路冗余;② 多级 fencing。 结构:2 个 Section(12.1 网络冗余+GE spof-network;12.2 多级 fencing+GE spof-fencing)+ 章末 Lab(lab: spof-review)。
Chapter Goal / Objectives(原文+译)
- GOAL: Identify and eliminate single points of failure in your cluster to decrease risk and increase average service availability.(找出并消除集群单点故障,降低风险、提高平均服务可用性。)
- OBJECTIVES: ① 配 HA 集群用多条网络链路做集群通信;② 配置多级 fencing。
12.1 Configuring Network Redundancy for Cluster Communication
SPoF 常见硬件点
- 电源:双冗余电源分别接两台 UPS / 不同市电来源 / 至少不同电闸;大机房再加发电机。
- 本地存储:RAID1/5/6 容错阵列。
- 网卡(NIC):bond(teaming)多网卡。
- 交换机:bond 的网卡接到不同交换机上。
- fencing 硬件:只配一台 fencing 设备时它挂了=无法隔离故障机→服务无法迁移。解法=多级 fencing(见 12.2)。
- 共享存储连接:FC 用多 HBA+multipath;iSCSI 用多条(bond)网络登录同一 target+multipath;后端阵列自身也要冗余(如 RAID)。
knet 多链路原理
- corosync 用 kronosnet(knet) 做网络层:一个弹性的安全抽象层;最多 8 条独立网络,一条断走其余。
- 每条链路必须不同子网;同子网要多网卡用 teaming(不能当 knet 多链路)。
- ⚠️ Red Hat 不支持两台机直连 crossover 网线;用 DLM 时只支持单条网络连接(lvmlockd/共享 VG/GFS2 都依赖 DLM,同样受限)。
- ⚠️ pcs/pcsd 管理通道不走 knet(走节点名对应网络),所以管理网络挂不影响 corosync 通信。
建集群时配多链路
pcs cluster setup mycluster \
node1.example.com addr=192.168.0.1 addr=10.4.0.101 addr=172.16.0.1 \
node2.example.com addr=192.168.0.2 addr=10.4.0.102 addr=172.16.0.2 \
...给已有集群加链路/删链路
pcs cluster link add \
node1.example.com=192.168.100.211 node2.example.com=192.168.100.212 \
node3.example.com=192.168.100.213 node4.example.com=192.168.100.214
pcs cluster link remove 3 # 按 ring 号删- 配置落在
/etc/corosync/corosync.conf的 nodelist:每个 node 有ring0_addr、ring1_addr…;ring 号从 0 起唯一标识链路。 - 日志排障:
grep down /var/log/cluster/corosync.log里link: host: 2 link: 1 is down(host=节点 ID,link=ring 号),对照 corosync.conf 定位断的是哪条子网。
12.1 GE(lab: spof-network)
- 跑 prep.yml(装集群包/配防火墙/设 hacluster 密码/启 pcsd/认证节点)。
- nodea:
pcs cluster setup cluster1 nodea… addr=192.168.0.10 addr=192.168.2.10 …(每节点 2 条链路)→pcs cluster start --all→pcs cluster enable --all。 - 跑 stonith.yml 配好 fencing(三节点各有 fence_nodeX)。
- 验证:
ip addr找 192.168.2.0/24 网卡(eth3)→nmcli dev disconnect eth3断一条链路 →pcs status三节点仍 Online →grep down /var/log/cluster/corosync.log见link: host: 2 link: 1 is down等 →cat /etc/corosync/corosync.conf确认 ring1=192.168.2.0/24(链路 1 断,通信走 ring0 继续)。
12.2 Configuring Multiple Fencing Device Levels(多级 fencing)
概念
- 一台节点有多个 fence 设备时按**层(level)**组织,level 从 1 开始顺序编号。
- fence 节点时先试 level 1 的全部设备(按加入顺序);level 1 任一设备失败=整个 level 视为失败,跳到 level 2 继续,以此类推;成功即停。
- 例:先试 fence_ipmilan,失败再用 fence_apc 断电。
命令
pcs stonith level add 1 node1.example.com fence_ipmi_node1 # level+节点+设备(多设备逗号分隔)
pcs stonith level add 2 node1.example.com fence_apc_node1
pcs stonith level # 查看拓扑
pcs stonith level clear node1.example.com # 清某节点全部 level(不带节点=全清)- 往已有 level 加设备不方便:删掉整个 level 重建(
pcs stonith level delete)。
双电源 power fencing(同 level 多设备)
- 冗余电源节点要真正断电必须两路都断;错误做法:A 断→A 开→B 断→B 开(全程从未完全断电)。
- 正确:两个 STONITH 资源放同一个 level:
pcs stonith create fence_apcA_node1 fence_apc ip=10.12.0.7 username=apc password=s3cr3t pcmk_host_map="node1.example.com:2"
pcs stonith create fence_apcB_node1 fence_apc ip=10.12.0.8 username=apc password=s3cr3t pcmk_host_map="node1.example.com:3"
pcs stonith level add 1 node1.example.com fence_apcA_node1,fence_apcB_node1- 同一 level 的多个设备:集群先对所有设备执行 off,再统一执行 on→ 保证某一时刻所有电源都关(RHEL7.1 及以前行为不同,配置更复杂)。
12.2 GE(lab: spof-fencing)
pcs stonith config:已有三台 fence_nodeX(fence_ipmilan,ip=192.168.0.10X,pcmk_host_list 各自节点)。- 教室二线 fence:
pcs stonith create fence_classroom fence_rh436 ip=192.168.0.100 username=admin password=password power_timeout=180 pcmk_host_map="nodea…:1;nodeb…:2;nodec…:3"(plug 号映射)。 - 每节点建两级:level1=fence_nodeX、level2=fence_classroom →
pcs stonith level验证。 - 故意搞坏主设备:
pcs stonith update fence_nodec ip=broken.example.com→pcs status:fence_nodec Stopped(监控起不来,Failed Resource Actions 一堆 error),fence_classroom 接管运行。 pcs stonith fence nodec.private.example.com(等数分钟,nodec 重启)→ 输出 fenced:level1 失败后 level2 成功隔离。
Lab 概要(lab: spof-review)
三节点集群(nodeb/nodec/noded):
- 加第二条链路:
pcs cluster link add nodeb…=192.168.1.11 nodec…=192.168.1.12 noded…=192.168.1.13→ 检查 corosync.conf ring1_addr。 - 跑
/root/spof-review/stonith.sh建 fence_classroom(fence_rh436);按表格给每节点建 level:level1=fence_classroom、level2=fence_nodeX(注意顺序与 GE 相反,考试按题目要求)→pcs stonith level核对 →lab grade spof-review。
命令速查表
| 用途 | 命令 |
|---|---|
| 建集群带多链路 | pcs cluster setup <名> <node> addr=<ip> addr=<ip> … |
| 加/删链路 | pcs cluster link add <node>=<ip> …;pcs cluster link remove <ring号> |
| 查看链路配置 | /etc/corosync/corosync.conf(ring0_addr…) |
| 断/通网卡测冗余 | nmcli dev disconnect eth3;nmcli device connect eth3 |
| 日志查链路 | grep down /var/log/cluster/corosync.log(host=节点ID link=ring号) |
| 加 fence level | pcs stonith level add <level> <node> <dev1>[,<dev2>…] |
| 查看/清 level | pcs stonith level;pcs stonith level clear [<node>] |
| 双电源同层 | 两资源后 pcs stonith level add 1 <node> devA,devB |
| 手动 fence | pcs stonith fence <node> |
| 实验/评分 | lab start spof-network|spof-fencing|spof-review;lab grade spof-review |
词汇表
| 英文 | 中文 | 速记 |
|---|---|---|
| SPoF | 单点故障 | 一环断全链断 |
| knet / kronosnet | corosync 网络层 | 最多 8 条链路、不同子网 |
| ring number | 环号 | corosync 链路编号(0 起) |
| redundant power supply | 冗余电源 | 双电源分接不同来源 |
| fence level | 隔离级别 | 从 1 起;整级失败才进下一级 |
| multilevel fencing | 多级隔离 | level1 主、level2 备… |
| pcmk_host_map | 主机映射 | 节点名→fence 设备插槽/口 |
| pcs stonith level add | 加隔离级 | 多设备逗号分隔 |
| pcs cluster link add/remove | 加/删链路 | 指定每节点新子网 IP |
| plug number | 插槽号 | 机箱/PDU 上的端口号 |
自测 10 题
- knet 最多支持几条链路?(8,且必须不同子网)
- 同子网多网卡想冗余怎么办?(teaming/bond,不是 knet 链路)
- 用 DLM(GFS2/共享VG)时支持几条集群网络?(1 条)
- 建集群时怎么配多链路?(pcs cluster setup 每节点多个 addr=)
- 已有集群加链路命令?(pcs cluster link add <node>=<ip> …)
- corosync 日志
link: host: 2 link: 1 is down含义?(host=节点ID 2、链路 ring 1 断开) - fence level 语义?(从 level1 开始;level 内任一设备失败则该级失败,试下一级)
- 双电源节点怎么正确 fence?(两 fence 资源同 level,先全 off 后全 on,保证同时断电)
- 往已有 level 加设备怎么做?(删级重建)
- pcs 管理通道受 knet 保护吗?(不受;pcsd 走节点名网络)
