正确的STONITH配置
根据您提供的信息:
192.168.3.220是 io01的带外管理IP192.168.3.221是 io02的带外管理IP
# 删除旧的
pcs stonith delete stonith-io01
pcs stonith delete stonith-io02
每个STONITH资源应该管理对应节点的带外接口。以下是正确的配置:
# 1. 创建用于管理io01带外的STONITH资源
# 这个资源用于隔离io01节点,使用io01的带外管理接口
pcs stonith create stonith-io01 fence_ipmilanplus \
ipaddr=192.168.3.220 \
login=USERID \
passwd=12345678 \
pcmk_host_list=io01.gqliu.cn \
pcmk_reboot_action=reboot \
power_timeout=60 \
op monitor interval=60s \
op start timeout=60s \
op stop timeout=60s
# 2. 创建用于管理io02带外的STONITH资源
# 这个资源用于隔离io02节点,使用io02的带外管理接口
pcs stonith create stonith-io02 fence_ipmilanplus \
ipaddr=192.168.3.221 \
login=root \
passwd=12345678 \
pcmk_host_list=io02.gqliu.cn \
pcmk_reboot_action=reboot \
power_timeout=60 \
op monitor interval=60s \
op start timeout=60s \
op stop timeout=60s
交叉位置约束配置
为了让隔离功能高可用,我们让每个STONITH资源优先运行在另一个节点上:
# 让stonith-io01(管理io01的带外)优先运行在io02上
# 这样当io01故障时,io02可以隔离io01
pcs constraint location stonith-io01 prefers io02.sxicc.cas.cn=100
# 让stonith-io02(管理io02的带外)优先运行在io01上
# 这样当io02故障时,io01可以隔离io02
pcs constraint location stonith-io02 prefers io01.sxicc.cas.cn=100
防环回规则
# 防止STONITH资源运行在它们要隔离的节点上
pcs constraint location stonith-io01 avoids io01.sxicc.cas.cn=INFINITY
pcs constraint location stonith-io02 avoids io02.sxicc.cas.cn=INFINITY
设置隔离层级
# 指定每个节点的隔离设备
pcs stonith level add 1 io01.sxicc.cas.cn stonith-io01
pcs stonith level add 1 io02.sxicc.cas.cn stonith-io02
启用STONITH
# 启用STONITH功能
pcs property set stonith-enabled=true
pcs property set stonith-action=poweroff
pcs property set stonith-timeout=120s
pcs property set no-quorum-policy=freeze
验证配置
# 查看STONITH配置
pcs stonith
# 查看详细配置
pcs stonith config stonith-io01
pcs stonith config stonith-io02
# 查看约束
pcs constraint
# 验证集群状态
pcs status
配置逻辑说明
- 资源与目标对应:
stonith-io01:管理192.168.3.220(io01的带外),目标节点是io01stonith-io02:管理192.168.3.221(io02的带外),目标节点是io02
- 交叉运行:
stonith-io01优先运行在io02上stonith-io02优先运行在io01上
- 隔离逻辑:
- 当
io01需要被隔离时,运行在io02上的stonith-io01会向192.168.3.220(io01的带外) 发送关机指令 - 当
io02需要被隔离时,运行在io01上的stonith-io02会向192.168.3.221(io02的带外) 发送关机指令
- 当
测试命令
# 模拟测试(不实际执行)
pcs stonith fence io01.gqliu.cn --off
pcs stonith fence io02.gqliu.cn --off
# 注意:实际隔离测试需要在维护窗口进行
# 可以先在一个节点上执行,观察集群行为
# pcs stonith fence io02.gqliu.cn
这样配置后,您的STONITH设置就符合逻辑了:每个STONITH资源管理对应节点的带外接口,并且交叉运行在对方节点上,实现高可用的隔离功能。