如何手工搭建红帽高可用集群

发布时间:2026/7/8 3:22:04
如何手工搭建红帽高可用集群 1. 环境准备# 在所有节点上安装必要软件包yum install -y pcs pacemaker corosync fence-agents-all# 启用并启动 pcsd 服务systemctl enable pcsdsystemctl start pcsd# 设置 hacluster 用户密码所有节点使用相同密码passwd hacluster2. 集群认证和创建# 在一个节点上认证所有集群节点pcs cluster auth node1 node2 -u hacluster -p your_password# 创建集群pcs cluster setup my_cluster node1 node2# 启动集群pcs cluster start --allpcs cluster enable --all3. 配置 STONITH防止脑裂# 配置 fencing 设备根据实际环境选择pcs stonith create fence_vm fence_vmware_soap \pcmk_host_listnode1,node2 \ipaddrvcenter.example.com \loginadmin \passwdpassword \ssl1 \ssl_insecure1 \datacenterDatacenter \protocolhttps4. 添加集群资源# 添加虚拟 IP 地址pcs resource create VirtualIP IPaddr2 \ip192.168.1.100 cidr_netmask24 op monitor interval30s# 添加 Web 服务示例pcs resource create WebServer apache \configfile/etc/httpd/conf/httpd.conf op monitor interval1min# 设置资源依赖关系pcs constraint colocation add WebServer with VirtualIP INFINITYpcs constraint order VirtualIP then WebServer5. 验证集群状态# 查看集群状态pcs status# 查看集群配置pcs config show# 测试故障转移pcs cluster stop node1