高可用配置部署:
pacemaker:资源管理器(CRM),负责启动与停止服务,位于 HA 集群架构中资源管理、资源代理层
corosync:消息层组件(Messaging Layer),管理成员关系、消息与仲裁,为高可用环境中提供通讯服务,位于高可用集群架构的底层,为各节点(node)之间提供心跳信息;
resource-agents:资源代理,在节点上接收CRM的调度,对某一资源进行管理的工具,管理工具通常为脚本;
pcs:命令行工具集;
fence-agents:fencing 在一个节点不稳定或无答复时将其关闭,使其不会损坏集群的其它资源,其主要作用是消除脑裂
#在全部控制节点安装相关服务,以controller003节点为例;
3.1 配置SSH免密认证
#连续回车三次生成空密码ssh
ssh-keygen
ssh-copy-id root@controller004
ssh-copy-id root@controller005
3.2 构建pacemaker集群
apt install pacemaker pcs corosync resource-agents heartbeat -y
#启动pcs服务,在全部控制节点执行,以controller003节点为例
systemctl enable pcsd
systemctl start pcsd
#修改集群管理员hacluster(默认生成)密码及清理集群信息,在全部控制节点执行,以controller003节点为例
passwd hacluster
pcs cluster destroy
#认证配置在任意节点操作,以controller003节点为例;
#节点认证,组建集群,需要采用上一步设置的password
pcs host auth controller003 controller004 controller005 -u hacluster -p devops
#创建并命名集群,在任意节点操作,以controller003节点为例;
#生成配置文件:/etc/corosync/corosync.conf
pcs cluster setup openstack-v-cluster --start controller003 controller004 controller005
3.3 启动集群
#启动群集服务,开机启动,以controller003节点为例
pcs cluster enable --all
root@controller003:~# pcs cluster status
Cluster Status:
Cluster Summary:
* Stack: corosync
* Current DC: controller004 (version 2.0.3-4b1f869f0f) - partition with quorum
* Last updated: Wed Apr 14 18:57:52 2021
* Last change: Wed Apr 14 14:25:13 2021 by hacluster via crmd on controller003
* 3 nodes configured
* 28 resource instances configured
Node List:
* Online: [ controller003 controller004 controller005 ]
PCSD Status:
controller004: Online
controller003: Online
controller005: Online
#查看corosync状态;
#“corosync”表示一种底层状态等信息的同步方式
root@controller003:~# pcs status corosync
Membership information
----------------------
Nodeid Votes Name
1 1 controller003 (local)
2 1 controller004
3 1 controller005
#查看节点
root@controller003:~# corosync-cmapctl | grep members
runtime.members.1.config_version (u64) = 0
runtime.members.1.ip (str) = r(0) ip(192.168.1.3)
runtime.members.1.join_count (u32) = 1
runtime.members.1.status (str) = joined
runtime.members.2.config_version (u64) = 0
runtime.members.2.ip (str) = r(0) ip(192.168.1.4)
runtime.members.2.join_count (u32) = 1
runtime.members.2.status (str) = joined
runtime.members.3.config_version (u64)