启停与增删节点
1.启动和停止集群服务控制集群节点在运行时是否参与集群。
2.启用和禁用集群服务可以控制集群节点是否自动启动集群服务并在启动时加入集群。
3.在集群中添加和删除集群节点将永久更改该节点是否为集群的成员。
4.备用模式和非备用模式控制集群节点是否允许承载集群内的资源。
启停pcs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| 在当前节点上启停pcs pcs cluster start pcs cluster start --all
指定某个节点启停pcs pcs cluster stop 10.163.2.106 pcs cluster start 10.163.2.106
所有节点启停pcs pcs cluster stop pcs cluster stop --all
开机启动/开机不启动 pcs cluster enable pcs cluster disable
|
添加/移除节点
新节点需要满足的要求:
1.防火墙配置
2.必须安装pcs与fence-agents-all及依赖项
3.启动pcsd服务
4.修改hacluster用户密码与其他节点一致
5.使用pcs host auth进行节点身份验证
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| pcs cluster destroy --all
pcs cluster setup mycluster pcs1 pcs2
yum config-manager --set-enabled highavailability yum -y install pcs pacemaker corosync fence-agents-all systemctl enable pcsd --now firewall-cmd --permanent --add-service=high-availability firewall-cmd --reload echo 123456 | passwd --stdin hacluster
pcs host auth pcs3 -u hacluster -p 123456 pcs cluster node add pcs3 pcs cluster start pcs3 pcs cluster enable pcs3
pcs cluster status Cluster Status: Cluster Summary: * Stack: corosync (Pacemaker is running) * Current DC: pcs1 (version 2.1.10-1.el9-5693eaeee) - partition with quorum * Last updated: Thu Aug 7 15:32:07 2025 on pcs1 * Last change: Thu Aug 7 15:30:56 2025 by hacluster via hacluster on pcs1 * 3 nodes configured * 0 resource instances configured Node List: * Online: [ pcs1 pcs2 pcs3 ]
PCSD Status: pcs1: Online pcs2: Online pcs3: Online
|
standby维护模式
字面意思,就是维护模式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| pcs node standby pcs2
pcs cluster status Cluster Status: Cluster Summary: * Stack: corosync (Pacemaker is running) * Current DC: pcs1 (version 2.1.10-1.el9-5693eaeee) - partition with quorum * Last updated: Thu Aug 7 15:51:06 2025 on pcs1 * Last change: Thu Aug 7 15:50:56 2025 by root via root on pcs1 * 3 nodes configured * 0 resource instances configured Node List: * Node pcs2: standby * Online: [ pcs1 pcs3 ]
PCSD Status: pcs2: Online pcs1: Online pcs3: Online
pcs node unstandby pcs2 pcs node unstandby --all
|
集群仲裁机制
核心概念
- 投票权(Votes):每个节点默认拥有1票
- 法定票数(Quorum):集群正常运作所需的最小票数
- 仲裁策略:决定当集群失去法定票数时的行为,默认为stop
法定票数,3节点就是2,5节点就是3,以此类推
仲裁机制举例
ABC三节点
A宕机
BC确认自己有法定票数,隔离A
A的资源由B或C进行接管
ABCDE五节点
ABC与DE连接断开,ABC和DE都觉得自己是正常的对方断开了
此时ABC票数3有法定票数,DE票数2无法定票数
ABC启动fencing隔离DE,继续运行所有资源
DE发现自己票数不够,停止所有资源
仲裁参数
参数可以在集群创建时添加,也可以在corosync.conf文件中手动编辑
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| wait_for_all=1:集群启动时等待所有节点在线,避免启动期脑裂
auto_tie_breaker=1:平票裁决,适用双数节点
last_man_standing=1:每10秒重新计算Quorum 比如5节点掉俩之后,3节点重新计算,但需要节点一个一个下线
自动更新 pcs quorum update
手动修改后同步 pcs cluster sync
重载配置 pcs cluster reload corosync
重启服务 pcs cluster restart
|