安装配置corosync+pacemaker集群for-postgresql
环境介绍:
172.16.1.107 pmdata01 pmck01 | 集群节点1 |
172.16.1.108 pmdata02 pmck02 | 集群节点2 |
172.16.1.115 pgdata-vip | 集群vip |
1.备份yum配置,挂载ISO
[root@pmdata01 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[root@pmdata01 ~]# cat /etc/yum.repos.d/server.repo
[base]
name=Local Base Repository
baseurl=file:///mnt
enabled=1
gpgcheck=0
[addons-HA]
name=Local Addons HighAvailability Repository
baseurl=file:///mnt/addons/HighAvailability
enabled=1
gpgcheck=0
[addons-RS]
name=Local Addons ResilientStorage Repository
baseurl=file:///mnt/addons/ResilientStorage
enabled=1
gpgcheck=0
2.安装集群 软件包【2个节点都要安装】
yum -y install pacemaker* corosync* pcs* psmisc
yum -y install pcs fence-agents*
3.关闭防火墙或者允许防火墙通过HA集群
iptables -L
iptables -F
iptables -X
iptables -Z
systemctl stop firewalld
systemctl disable firewalld
允许通过防火墙
4.节点之间配置互信【2个节点都做】
生产本地秘钥并配置互信
ssh-keygen -t rsa
ssh-copy-id -i id_rsa.pub pmck01
ssh-copy-id -i id_rsa.pub pmck02
5.设置pcsd开机启动
systemctl enable pcsd --now
systemctl restart pcsd --now
systemctl restart pcsd
systemctl start pcsd.service
systemctl enable pcsd.service
6.配置集群认证和口令
echo Admin123|passwd --stdin hacluster
pcs cluster auth pmck01 pmck02
systemctl start corosync
systemctl start pacemaker
systemctl enable corosync
systemctl enable pacemaker
【还没开始创建集群,corosync服务可能会异常,待集群创建完毕后即可】
7.创建集群和同步节点
pcs cluster setup --name PG_PCS_HA pmck01 pmck02
[root@pmdata01 ~]# pcs cluster start --all
pmck01: Starting Cluster (corosync)...
pmck02: Starting Cluster (corosync)...
pmck02: Starting Cluster (pacemaker)...
pmck01: Starting Cluster (pacemaker)...
[root@pmdata01 ~]# pcs cluster status
Cluster Status:
Stack: corosync
Current DC: pmck01 (version 1.1.23-1.el7-9acf116022) - partition with quorum
Last updated: Sun Mar 2 14:38:54 2025
Last change: Sun Mar 2 14:37:22 2025 by hacluster via crmd on pmck01
2 nodes configured
0 resource instances configured
PCSD Status:
pmck01: Online
pmck02: Online
[root@pmdata01 ~]#
STONITH 是一种防止脑裂(split-brain scenario)的机制,在高可用性集群中用于确保在某些节点发生故障时,能安全地将这些节点隔离,从而避免数据损坏或不一致。
配置 STONITH 资源:为了使用 STONITH,你需要在集群中配置相应的 STONITH 资源。这通常涉及到指定用于隔离节点的硬件设备或方法(例如,通过 IPMI、iLO、DRAC 等远程管理接口)
至此,集群就安装完毕了,接下来就是配置和使用集群了

浙公网安备 33010602011771号