跳转到内容
搜索 RHEL 文档

    浏览当前文档目录

    RHEL 10 两节点 HA:pcs/pacemaker 建集群与资源迁移

    RHEL 10 的 HA 栈是 pcs + pacemaker + corosync。默认仓库不带,要先启用 highavailability repo;两节点集群能起来,但没有 fencing 就只是“实验集群”。本页在 390/393 上完整走一遍。

    主机IP角色
    390192.168.2.232node 1 / DC
    393192.168.2.235node 2
    • pcs 0.12.2
    • pacemaker 3.0.1
    • corosync 3.1.10

    E3 记录:plans/content-expansion/evidence/rhel/rhel-ha/run.json(5 步,含 auth/setup/quorum/resource)。

    先给结论:先开 highavailability 仓库

    Section titled “先给结论:先开 highavailability 仓库”

    只装 pcs 会报 “No matching Packages”,因为包在:

    Terminal window
    sudo subscription-manager repos --enable rhel-10-for-x86_64-highavailability-rpms
    sudo dnf -y install pcs pacemaker corosync fence-agents-all

    两台都要装,pcsd 要 active。

    Terminal window
    sudo passwd hacluster
    sudo systemctl enable --now pcsd
    sudo firewall-cmd --add-service=high-availability --permanent
    sudo firewall-cmd --reload
    sudo pcs host auth 192.168.2.232 192.168.2.235 -u hacluster
    192.168.2.235: Authorized
    192.168.2.232: Authorized

    两台 hacluster 密码必须一致;pcsd 默认 2224/tcp。

    Terminal window
    sudo pcs cluster setup hacluster 192.168.2.232 192.168.2.235 --start
    sudo pcs cluster enable --all
    sudo pcs property set stonith-enabled=false
    Cluster has been successfully set up.
    Starting cluster on hosts: '192.168.2.232', '192.168.2.235'...
    192.168.2.232: Cluster Enabled
    192.168.2.235: Cluster Enabled
    Warning: Setting property stonith-enabled to false leaves the cluster with no enabled means to fence nodes

    刚建完可能短暂 OFFLINE,等 10–20 秒。

    $ sudo pcs status
    Cluster name: hacluster
    * Stack: corosync (Pacemaker is running)
    * Current DC: 192.168.2.232 ... - partition with quorum
    * 2 nodes configured
    Node List:
    * Online: [ 192.168.2.232 192.168.2.235 ]
    $ sudo pcs quorum status
    Quorum provider: corosync_votequorum
    Nodes: 2
    Quorate: Yes

    两节点集群的 quorum 规则特殊:一台挂掉就失去 quorum,需要 two_node: 1 或 QDevice;生产别把两节点当高可用。

    Terminal window
    sudo pcs resource create dummy ocf:heartbeat:Dummy op monitor interval=10s
    sudo pcs status resources
    * dummy (ocf:heartbeat:Dummy): Started 192.168.2.232

    Dummy 只用于验证调度,不提供真实服务。

    Terminal window
    sudo pcs resource move dummy 192.168.2.235
    sudo pcs status resources
    resource 'dummy' is running on node '192.168.2.235'
    * dummy (ocf:heartbeat:Dummy): Started 192.168.2.235

    move 会创建临时 location 约束;迁移完成后 pcs constraint 里能看到,必要时 pcs resource clear dummy 清掉。

    stonith-enabled=false 让集群能在没有 fence 设备时启动,但:

    • 节点失联时无法确认对方是否还持有资源;
    • 可能出现双写/脑裂;
    • 生产必须配 fence_ipmilan/fence_redfish/云 fence,并设 stonith-enabled=true。
    Terminal window
    sudo pcs cluster destroy --all
    sudo systemctl disable --now pcsd

    destroy 会停 pacemaker/corosync 并删除配置;包可以保留。

    • highavailability 仓库已启用;
    • 两台 pcsd active、hacluster 密码一致;
    • pcs host auth 都 Authorized;
    • pcs status 两节点 Online、Quorate Yes;
    • 资源能在节点间迁移;
    • 生产有 fence/QDevice,不靠 stonith-enabled=false。
    • 未测试真实 fence 设备;
    • 未测试 QDevice;
    • 未测试三节点/quorum 丢失;
    • 未测试资源 agent(VIP/文件系统/数据库)。