如何使用Pacemaker重启httpd
我们有两台带有 Pacemaker (crm) 设置的服务器,可启用主/备用集群。目前有两个由 Pacemaker 控制/监控的服务,如果其中一个服务出现故障,将导致故障转移到备用服务器、我们自己的自定义服务(以下称为 customservice1)和 mysql。
customservice1 和 mysql 在备用数据库上停止并在主数据库上运行(显然)。当发生故障转移时,起搏器似乎会停止两者(或者确保如果只有一个因某种原因而失败,则它们会停止,我对此不太清楚),更改主要和备用的IP地址(以便DNS 中的别名将始终转到主数据库),然后在之前的备用数据库上启动 customservice1 和 mysql。
我想添加一个由pacemaker控制的步骤,只要发生故障转移,它就会简单地重新启动httpd。 httpd 当前始终在主数据库和备用数据库上运行。目前,httpd 中的故障不会导致故障转移,而且我对添加该监控并不真正感兴趣,我只是希望在使备用数据库成为主数据库时,pacemaker 运行相当于“service httpd restart”的操作。
添加仅重新启动服务的新原语的正确语法是什么?
当前起搏器配置如下:
node $id="XX" some.machine.name \
attributes standby="off"
node $id="YY" another.machine.name
primitive customservice1 lsb:customservice1 \
op monitor interval="30s" timeout="30s" \
op start interval="0" timeout="120" \
op stop interval="0" timeout="120" \
meta target-role="Started"
primitive mysql-server ocf:heartbeat:mysql \
params binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/some/data/dir" user="mysql" pid="/var/lib/mysql/mysql.pid" socket="/var/lib/mysql/mysql.sock" \
op monitor interval="30s" timeout="30s" \
op start interval="0" timeout="120" \
op stop interval="0" timeout="120"
primitive node1-stonith stonith:external/riloe \
params hostlist="some.machine.name" ilo_user="Administrator" ilo_hostname="some-ilo.machine.name" ilo_password="<ilopassword>" ilo_can_reset="1" ilo_protocol="2.0" ilo_powerdown_method="button" \
op monitor interval="120s" timeout="40s" \
meta target-role="Started"
primitive node2-stonith stonith:external/riloe \
params hostlist="another.machine.name" ilo_user="Administrator" ilo_hostname="another-ilo.machine.name" ilo_password="<ilopassword>" ilo_can_reset="1" ilo_protocol="2.0" ilo_powerdown_method="button" \
op monitor interval="120s" timeout="40s" \
meta target-role="Started"
primitive node_one_ip ocf:heartbeat:IPaddr2 \
params ip="1.1.1.1" cidr_netmask="255.255.255.0" nic="eth0" \
op monitor interval="40s" timeout="20s"
primitive node_two_ip ocf:heartbeat:IPaddr2 \
params ip="1.1.1.2" cidr_netmask="255.255.255.0" nic="eth0" \
op monitor interval="40s" timeout="20s" \
meta target-role="Started"
group only-group node_one_ip mysql-server customservice1
property $id="cib-bootstrap-options" \
dc-version="1.0.9-89bd754939df5150de7cd76835f98fe90851b677" \
cluster-infrastructure="Heartbeat" \
no-quorum-policy="ignore" \
last-lrm-refresh="1287686604" \
default-resource-stickiness="1"
We have two servers with a Pacemaker (crm) setup that enables a primary/standby cluster. There are currently two services controlled/monitored by Pacemaker that, if either goes down, will cause a fail-over to the standby, our own custom service (hereafter called customservice1) and mysql.
customservice1 and mysql are stopped on the standby and running on the primary (obviously). When a failover occurs, it appears that pacemaker will stop both (or ensure they are stopped if only one failed for whatever reason, I'm not quite clear on this point), change the ip address of the primary and standby (so that an alias in DNS will always go to the primary), then start customservice1 and mysql on what was previously the standby.
I would like to add a step to this, controlled by pacemaker, that will simply restart httpd whenever a failover has occurred. httpd currently is running on both the primary and standby at all times. A failure in httpd currently does not cause a failover and I'm not really interested in adding that monitoring, I simply want pacemaker to run the equivalent of 'service httpd restart' when making the standby become the primary.
What is the correct syntax for adding a new primitive that will only restart a service?
Current pacemaker configuration is below:
node $id="XX" some.machine.name \
attributes standby="off"
node $id="YY" another.machine.name
primitive customservice1 lsb:customservice1 \
op monitor interval="30s" timeout="30s" \
op start interval="0" timeout="120" \
op stop interval="0" timeout="120" \
meta target-role="Started"
primitive mysql-server ocf:heartbeat:mysql \
params binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/some/data/dir" user="mysql" pid="/var/lib/mysql/mysql.pid" socket="/var/lib/mysql/mysql.sock" \
op monitor interval="30s" timeout="30s" \
op start interval="0" timeout="120" \
op stop interval="0" timeout="120"
primitive node1-stonith stonith:external/riloe \
params hostlist="some.machine.name" ilo_user="Administrator" ilo_hostname="some-ilo.machine.name" ilo_password="<ilopassword>" ilo_can_reset="1" ilo_protocol="2.0" ilo_powerdown_method="button" \
op monitor interval="120s" timeout="40s" \
meta target-role="Started"
primitive node2-stonith stonith:external/riloe \
params hostlist="another.machine.name" ilo_user="Administrator" ilo_hostname="another-ilo.machine.name" ilo_password="<ilopassword>" ilo_can_reset="1" ilo_protocol="2.0" ilo_powerdown_method="button" \
op monitor interval="120s" timeout="40s" \
meta target-role="Started"
primitive node_one_ip ocf:heartbeat:IPaddr2 \
params ip="1.1.1.1" cidr_netmask="255.255.255.0" nic="eth0" \
op monitor interval="40s" timeout="20s"
primitive node_two_ip ocf:heartbeat:IPaddr2 \
params ip="1.1.1.2" cidr_netmask="255.255.255.0" nic="eth0" \
op monitor interval="40s" timeout="20s" \
meta target-role="Started"
group only-group node_one_ip mysql-server customservice1
property $id="cib-bootstrap-options" \
dc-version="1.0.9-89bd754939df5150de7cd76835f98fe90851b677" \
cluster-infrastructure="Heartbeat" \
no-quorum-policy="ignore" \
last-lrm-refresh="1287686604" \
default-resource-stickiness="1"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了让 Pacemaker 执行此操作,您需要将 http 服务器置于 Pacemaker 的控制之下,然后在组和 http 守护程序之间创建排序约束。
根据记忆,您需要确保分数 > 0 的约束。
否则,您需要修改现有资源的脚本以根据需要重新启动 httpd。
In order for Pacemaker to do this, you'd need to put the http server under Pacemaker's control and then create an ordering constraint between the group and the http daemon.
From memory you need to make sure score > 0 on the constraint.
Otherwise, you'd need to modify the script of an existing resource to restart httpd as necessary.
您需要在 Pacemaker 上添加 httpd 原语:
或者,如果您想使用脚本 LSB:
并在您的“only-group”组中添加“apache2”(关心顺序)
You need to add httpd primitive on Pacemaker :
Or, if you want to use the script LSB :
And add 'apache2' in your 'only-group' group (care about the order)