Corosync+Pacemaker+NFS+Httpd高可用web集群部署

本文详细介绍了如何在CentOS7环境下,利用pcs工具配置Corosync+Pacemaker高可用集群,并结合NFS和Httpd服务实现Web集群。涉及时间同步、认证、资源配置、资源组创建、资源约束定义等多个步骤,确保了Web服务的高可用性。
摘要由CSDN通过智能技术生成

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配置

此处不做赘述

 

一、启动corosyncpacemaker

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> ...]

#关闭此前定义的资源:webipwebserverwebstore

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,否则无法认证通过

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值