重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

标题: 如何手工搭建红帽高可用集群 [打印本页]

作者: 郑全    时间: 5 天前
标题: 如何手工搭建红帽高可用集群
本帖最后由 郑全 于 2026-7-5 10:09 编辑

1. 环境准备

# 在所有节点上安装必要软件包
yum install -y pcs pacemaker corosync fence-agents-all
# 启用并启动 pcsd 服务

systemctl enable pcsd

systemctl start pcsd

# 设置 hacluster 用户密码(所有节点使用相同密码)

passwd hacluster

2. 集群认证和创建

# 在一个节点上认证所有集群节点

pcs cluster auth node1 node2 -u hacluster -p your_password

# 创建集群

pcs cluster setup my_cluster node1 node2

# 启动集群
pcs cluster start --all

pcs cluster enable --all

3. 配置 STONITH(防止脑裂)

# 配置 fencing 设备(根据实际环境选择)

pcs stonith create fence_vm fence_vmware_soap \
    pcmk_host_list="node1,node2" \
    ipaddr="vcenter.example.com" \
    login="admin" \
    passwd="password" \
    ssl="1" \
    ssl_insecure="1" \
    datacenter="Datacenter" \
    protocol="https"

4. 添加集群资源

# 添加虚拟 IP 地址

pcs resource create VirtualIP IPaddr2 \
    ip=192.168.1.100 cidr_netmask=24 op monitor interval=30s
# 添加 Web 服务(示例)

pcs resource create WebServer apache \
    configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min
# 设置资源依赖关系

pcs constraint colocation add WebServer with VirtualIP INFINITY

pcs constraint order VirtualIP then WebServer

5. 验证集群状态

# 查看集群状态

pcs status

# 查看集群配置

pcs config show

# 测试故障转移

pcs cluster stop node1






欢迎光临 重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2