CentOS 环境集群搭建实操指南

一、常见场景与选型
二、通用前置准备
三、高可用集群搭建步骤(Corosync + Pacemaker + pcs)
yum install -y pacemaker pcs corosync fence-agents-allsystemctl enable --now pcsdpasswd hacluster(示例统一为 centos)pcs cluster auth node1 node2 node3 -u hacluster -p centospcs cluster setup --start --name cluster0 node1 node2 node3pcs cluster enable --allpcs cluster status、pcs statusfirewall-cmd --permanent --add-service=high-availability && firewall-cmd --reloadpcs property set stonith-enabled=false(仅测试)pcs resource create VIP ocf:heartbeat:IPaddr2 ip=192.168.122.170 cidr_netmask=24 op monitor interval=30spcs resource create WEB systemd:httpd op monitor interval=60spcs constraint colocation add WEB with VIP INFINITY;pcs constraint order promote VIP then start WEBpcs status resourcespcs cluster standby node1 观察 VIP 与 WEB 是否漂移至其他节点;恢复:pcs cluster unstandby node1以上流程覆盖从安装、认证、建集群到资源配置与验证的完整闭环,适合在 CentOS 7/8 环境快速落地 HA。四、其他常见集群快速路径
kubeadm init(按提示完成 kubeconfig 与网络插件安装,如 Calico)。kubeadm join ... 将 Worker 加入集群。kubectl get nodes、kubectl get pods -A。hdfs namenode -format。start-dfs.sh、start-yarn.sh;验证:jps 查看进程与健康状态。redis-cli --cluster create <ip:port> ... --cluster-replicas 1redis-cli --cluster check <ip:port>。etcdctl endpoint health。以上路径适合在 CentOS 上快速构建容器编排、大数据、缓存与键值存储等常见集群形态。五、运维与排错要点
/var/log/pacemaker.log、/var/log/corosync.log,配合 pcs status、crm_verify -L -V 定位资源与约束问题。pcs cluster standby <node> 隔离节点,变更后逐步恢复并回归生产。这些实践能显著提升集群的稳定性与可维护性,并缩短故障定位时间。