Corosync+Pacemaker+NFS+Httpd高可用web集群(使用资源管理工具pcs配置)
框架:pcs(Corosync+pacemaker)+nfs+httpd
集群节点1:192.168.88.132 cen7.field.com
集群节点2:192.168.88.133 node2.field.com
集群节点3:192.168.88.134 node1.field.com
vip: 192.168.88.188 资源代理:ocf:heartbeat:IPaddr
nfs服务器:node1.field.com 资源代理:ocf:heartbeat:Filesystem
web服务器:cen7.field.com node2.field.com node1.field.com 资源代理:systemd:httpd
配置集群的前提
(1)、时间同步;
(2)、.基于当前正在使用的主机名互相访问;
(3)、是否会用到仲裁设备;
配置集群的前提:参考《使用资源管理工具pcs配置Corosync+pacemaker》
配置nfs服务器:参考《Corosync+pacemaker+nfs+httpd高可用web集群》(使用资源管理工具crmsh配置)
各节点安装配置httpd:参考《Corosync+pacemaker+nfs+httpd高可用web集群》(使用资源管理工具crmsh配置)
此处不做赘述
一、启动corosync和pacemaker
1、使用crm交互模式:删除此前定义的资源
[root@cen7 corosync]# crm configure
crm(live)configure# edit
ERROR: Cannot delete running resources: webip, webserver, webstore
Edit or discard changes (yes to edit, no to discard) (y/n)? n
该报错显示:不能删除正在运行的资源,删除资源之前需要先停止资源
# resource资源管理子命令:所有的资源都在这个子命令后定义
crm(live)configure# cd
crm(live)# cd resource
crm(live)resource# help
#命令用法可以使用“help [command]”查看
crm(live)resource# help stop
Usage:
stop <rsc> [<rsc> ...]
#关闭此前定义的资源:webip、webserver、webstore
crm(live)resource# stop webip webserver webstore
#删除此前定义的资源:delete <rsc> [<rsc> ...]
crm(live)resource# cd ../configure
crm(live)configure# delete webip webserver webstore
INFO: hanging order:webserver_after_webstore deleted
INFO: constraint colocation:webserver_with_webstore_and_webip updated
INFO: hanging order:webstore_after_webip deleted
INFO: hanging colocation:webserver_with_webstore_and_webip deleted
INFO: hanging location:webservice_prefer_cen7 deleted
crm(live)configure# verify
ERROR: Warnings found during check: config may not be valid
注意:如果有无意义的配置会报如上error,使用show查看配置,直接使用edit编辑删除无效配置:wq保存退出即可。
crm(live)configure# show
node 1: cen7.field.com \
attributes standby=off
node 2: node2.field.com
node 3: node1.field.com
property cib-bootstrap-options: \
have-watchdog=false \
dc-version=1.1.18-11.el7_5.3-2b07d5c5a9 \
cluster-infrastructure=corosync \
stonith-enabled=false \
default-resource-stickiness=50
crm(live)configure# commit
2、确认pcs状态信息
[root@cen7 corosync]# pcs status
Cluster name:
WARNING: corosync and pacemaker node names do not match (IPs used in setup?)
Stack: corosync
Current DC: node1.field.com (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum
Last updated: Thu Aug 2 10:46:11 2018
Last change: Thu Aug 2 10:45:10 2018 by root via cibadmin on cen7.field.com
3 nodes configured
0 resources configured
Online: [ cen7.field.com node1.field.com node2.field.com ]
No resources
Daemon Status:
corosync: active/disabled
pacemaker: active/enabled
pcsd: inactive/disabled
3、查看配置文件:备份使用crmsh管理时的corosync.conf文件
[root@cen7 corosync]# ls
authkey corosync.conf corosync.conf.example corosync.conf.example.udpu corosync.xml.example uidgid.d
[root@cen7 corosync]# cp corosync.conf corosync.conf.bak080215
停止pacemaker和corosync服务
[root@cen7 corosync]# ansible hacluster -m service -a 'name=pacemaker state=stopped'
[root@cen7 corosync]# ansible hacluster -m service -a 'name=corosync state=stopped'
二、安装pcs配置集群管理工具
1、安装pcs
[root@cen7 corosync]# ansible hacluster -m yum -a 'name=pcs state=latest'
2、配置pcs
1)、修改pcs安装时默认用户hacluster密码,两个节点密码设置一致。
[root@cen7 corosync]# ansible hacluster -m shell -a 'echo hacluster |passwd --stdin hacluster'
192.168.88.133 | SUCCESS | rc=0 >>
更改用户 hacluster 的密码 。
passwd:所有的身份验证令牌已经成功更新。
192.168.88.134 | SUCCESS | rc=0 >>
更改用户 hacluster 的密码 。
passwd:所有的身份验证令牌已经成功更新。
192.168.88.132 | SUCCESS | rc=0 >>
更改用户 hacluster 的密码 。
passwd:所有的身份验证令牌已经成功更新。
2)、集群节点间认证
注意:认证时用户必须是pcs安装时的默认用户hacluster,否则无法认证通过