pacemaker实现apache高可用

本文介绍如何使用Pacemaker实现Apache服务的高可用集群部署。通过配置浮动IP和集群资源,确保服务连续性。文章详细记录了从安装配置到测试验证的全过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Pacemaker实现apache高可用集群部署

Pacemaker集群搭建参考以下链接:

http://blog.youkuaiyun.com/abel_dwh/article/details/78475630

查看集群状态

[root@node2 ~]# pcs status
Cluster name: abel_cluster
Stack: corosync
Current DC: node2 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum
Last updated: Wed Nov  8 16:48:19 2017
Last change: Wed Nov  8 16:44:57 2017 by root via cibadmin on node2
2 nodes configured
2 resources configured
Online: [ node1 node2 ]
Full list of resources:

添加VIP

首先要做的是配置一个IP地址,不管集群服务在哪运行,我们要一个固定的地址来提供服务。在这里我选择 192.168.122.20作为浮动IP,给它取一个好记的名字 ClusterIP 并且告诉集群每30秒检查它一次。

[root@node1 ~]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 ip=192.168.122.20 cidr_netmask=24 op monitor interval=30s
查看我们已经创建好的资源,一个vip现在已经在node12上运行

[root@node1 ~]# pcs status

Cluster name: abel_cluster
Stack: corosync
Current DC: node2 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum
Last updated: Wed Nov  8 16:52:05 2017
Last change: Wed Nov  8 16:44:57 2017 by root via cibadmin on node2


2 nodes configured
2 resources configured


Online: [ node1 node2 ]


Full list of resources:


 ClusterIP	(ocf::heartbeat:IPaddr2):	Started node2
安装httpd(apache) 2节点

[root@node1 ~]# yum -y install httpd
给apache写一个默认首页

[root@node1 ~]# echo "This is node1 test" >/var/www/html/index.html
[root@node2 ~]# echo "This is node2 test" >/var/www/html/index.html
开启httpd的访问链接

[root@node1 ~]# vim /etc/httpd/conf/httpd.conf 
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
将apache添加到集群中

[root@node1 ~]# pcs resource create Web ocf:heartbeat:apache  configfile=/etc/httpd/conf/httpd.conf statusurl="http://127.0.0.1/server-status" op monitor interval=1min
确保资源在同一个节点运行

[root@node2 ~]# pcs constraint colocation add Web ClusterIP INFINITY
控制资源的启停顺序(先启ClusterIP再启动Web)

[root@node2 ~]# pcs constraint order ClusterIP then Web
最后我们访问测试


停止node2再次访问

[root@node1 ~]# pcs cluster stop node2
node2: Stopping Cluster (pacemaker)...
node2: Stopping Cluster (corosync)...


ok


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

abel_dwh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值