一、准备工作:
1、准备Centos7.9的环境,ISO可以到一下链接下载:
http://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Everything-2009.iso
2、配置桥接网卡,使得虚拟机可以连接互联网
[root@node65 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@node65 ~]# ping g.cn
PING g.cn (120.253.250.226) 56(84) bytes of data.
64 bytes from 120.253.250.226 (120.253.250.226): icmp_seq=1 ttl=116 time=71.7 ms
64 bytes from 120.253.250.226 (120.253.250.226): icmp_seq=2 ttl=116 time=40.7 ms
3、建议创建3台虚拟机。网络拓扑如下:
node63.example.com
192.168.43.63
node64.example.com
192.168.43.64
node65.example.com
192.168.43.65
4、建议更新repo源
[root@node65 ~]# yum clean all
[root@node65 ~]# yum update -y
[root@node65 ~]# yum repolist
二、安装pacemaker
1、三台node安装pacemaker、corosync、fence agent
[root@node65 ~]# yum install -y pcs pacemaker corosync fence-agents-all
2、三个节点设置防火墙规则
[root@node65 ~]# firewall-cmd --permanent --add-service=high-availability
[root@node65 ~]# firewall-cmd --reload
3、三个节点设置pcsd服务开机启动并启动服务
[root@node65 ~]# systemctl enable pcsd
[root@node65 ~]# systemctl start pcsd
[root@node65 ~]# systemctl status pcsd
4、三个节点设置hacluster的密码
[root@node65 ~]# echo centos|passwd --stdin hacluster
三、配置High Availability
1、在node65上验证群集节点node63.example.com、node64.example.com、node65.example.com
[root@node65 ~]# pcs cluster auth node63.example.com node64.example.com node65.example.com -u hacluster -p centos
2、使用node65.example.com上的集群节点node63.example.com\node64.example.com、node65.example.com创建并启动集群cluster0。
[root@node65 ~]# pcs cluster setup --start --name cluster0 node63.example.com node64.example.com node65.example.com
3、在所有配置的群集节点上启用群集的自动启动。
[root@node65 ~]# pcs cluster enable --all
node63.example.com: Cluster Enabled
node64.example.com: Cluster Enabled
node65.example.com: Cluster Enabled
4、 验证集群正在运行,并且所有配置的集群节点都已加入集群。
[root@node65 ~]# pcs cluster status
Cluster Status:
Stack: corosync
Current DC: node64.example.com (version 1.1.23-1.el7_9.1-9acf116022) - partition with quorum
Last updated: Wed Jun 16 13:52:50 2021
Last change: Wed Jun 16 13:52:48 2021 by hacluster via crmd on node64.example.com
3 nodes configured
0 resource instances configured
PCSD Status:
node63.example.com: Online
node64.example.com: Online
node65.example.com: Online