这里写目录标题
- 实验环境的准备
- 软件的安装
- 配置高可用yum源
- 建立集群
- 为建立认证的用户hacluster创建密码
- 建立认证
- 集群的启动
- 集群状态的查看
- 资源的放置
- 资源的类型
- 组资源的配置
pacemaker
Pacemaker是一个集群管理器。它利用首选集群基础设施(OpenAIS
或heartbeat)提供的消息和成员能力,由辅助节点和系统进行故障检测和回收,实现性群集服务(亦称资源)的高可用性。
注意:pacemaker的字面意思为心脏起搏器,但是并不发送心跳,只是一个集群管理器。
corosync
Corosync是集群管理套件的一部分,通常会与其他资源管理器一起组合使用它在传递信息的时候可以通过一个简单的配置文件来定义信息传递的方式和协议等,实现HA心跳信息传输的功能。
实验环境的准备
vm1:172.25.3.1 vm2:172.25.3.2
两台机器之间进行免密
vm1下
ssh-keygen
ssh-copy-id vm2
软件的安装
rhel7中,系统镜像自带的资源有额外的高可用套件及存储套件 他们存放在镜像里的addons文件夹下
[ root@foundation3 images]# cd /mnt/rhel7.6
[ rootafoundation3 rhel7.6]# ls
addons GPL media. repo RPM- GPG- KEY- redhat- release
EFI images Packages TRANS. TBL EUL isolinux repodata
extra_ files.json L ive0S RPM- GPG KEY- redhat-beta
配置高可用yum源
[dvd]
name=rhel7.6
baseurl-http://172.25.3.250/rhel7.6
gpgcheck=0
[HighAvailability]
name=HighAvailability
baseurl=http://172.25.3.250/ rhel7.6/addons/HighAvailability
gpgcheck=0
[ResilientStorage ]
name=Resi lientStorage
baseurl=http://172.25.3.250/ rhel7.6/addons/ResilientStorage
gpgcheck=0
在vm1,vm2上同时安装pacemaker+corosync 还有集群管理工具pcs及依赖性psmisc policycoreutils-python
yum install pacemaker corosync pcs psmisc policycoreutils-python -y
集群管理工具pcs命令需要连接pcsd服务,把pcsd服务并设置为开机自启动
systemctl enable pcsd --now
建立集群
为建立认证的用户hacluster创建密码
[ root@vm1 ~]#echo westos|passwd -- stdin hacluster
Changing password for user hacluster.
passwd: all authentication tokens updated successfully.
[ root@vm1 ~]#ssh vm2 echo westos|passwd -- stdin hacluster
建立认证
[root@server1 ~]# pcs cluster auth server1 server2
server1: Already authorized
server2: Already authorized
集群的启动
pcs cluster start --all
集群状态的查看
[root@vm1 ~]# pcs cluster statusCluster Status:Stack: corosyncCurrent DC: server1 (version 1.1.19-8.el7-c3c624ea3d) - partition with quorumLast updated: Thu Aug 6 12:04:12 2020Last change: Wed Aug 5 09:30:26 2020 by root via cibadmin on server22 nodes configured2 resources configuredPCSD Status:vm1: Onlinevm2: Online
资源的放置
pcs resource create ClusterIP ocf:heartbeat:IPaddr2 ip=172.25.3.100 op monitor interval=30
在集群中添加资源ClusterIP:172.25.3.100 j监控时间为30s
ocf heartbeat:IPaddr2为资源启动脚本
[root@vm2 ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: server1 (version 1.1.19-8.el7-c3c624ea3d) - partition with quorum
Last updated: Thu Aug 6 13:42:45 2020
Last change: Thu Aug 6 13:42:27 2020 by root via cibadmin on server12 nodes configured
1 resource configuredOnline: [ vm1 vm2 ]Full list of resources:ClusterIP (ocf::heartbeat:IPaddr2): Started vm2Daemon Status:corosync: active/enabledpacemaker: active/enabledpcsd: active/enabled
此时停掉vm2上的集群组件,vm1会接管ClusterIP
[root@vm1 ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: server1 (version 1.1.19-8.el7-c3c624ea3d) - partition with quorum
Last updated: Thu Aug 6 13:45:13 2020
Last change: Thu Aug 6 13:42:27 2020 by root via cibadmin on server12 nodes configured
1 resource configuredOnline: [ vm1 ]
OFFLINE: [ vm2 ]Full list of resources:ClusterIP (ocf::heartbeat:IPaddr2): Started vm1Daemon Status:corosync: active/enabledpacemaker: active/enabledpcsd: active/enabled
资源的类型
# pcs resource standards
lsb
ocf
service
systemd
当将apache作为资源时,就应该使用systemd的方式
pcs resource create apache systemd:httpd op monitor interval=1min
[root@vm1 ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: server2 (version 1.1.19-8.el7-c3c624ea3d) - partition with quorum
Last updated: Thu Aug 6 14:25:20 2020
Last change: Thu Aug 6 14:25:06 2020 by root via cibadmin on server12 nodes configured
1 resources configuredOnline: [ vm1 vm2 ]Full list of resources:apache (systemd:httpd): Started vm1Daemon Status:corosync: active/enabledpacemaker: active/enabledpcsd: active/enabled
组资源的配置
pcs resource group add webgroup ClusterIP apache
[root@server1 ~]# pcs status
Cluster name: mycluster
Stack: corosync
Current DC: server2 (version 1.1.19-8.el7-c3c624ea3d) - partition with quorum
Last updated: Thu Aug 6 14:34:23 2020
Last change: Thu Aug 6 14:33:26 2020 by root via cibadmin on server12 nodes configured
2 resources configuredOnline: [ vm1 vm2 ]Full list of resources:Resource Group: webgroupClusterIP (ocf::heartbeat:IPaddr2): Started vm2apache (systemd:httpd): Started vm2Daemon Status:corosync: active/enabledpacemaker: active/enabledpcsd: active/enabled
在这里可以看出资源启动顺序为按编写顺序启动