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

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 107|回复: 0
打印 上一主题 下一主题

[安装] 如何手工搭建红帽高可用集群

[复制链接]
跳转到指定楼层
楼主
发表于 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

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2026-7-10 05:06 , Processed in 0.346115 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表