How to use Pacemaker to restart httpd
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_hos开发者_开发百科tname="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"
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.
You need to add httpd primitive on Pacemaker :
primitive apache2 ocf:heartbeat:apache \
params configfile="/etc/apache2/apache2.conf" \
op monitor interval="30s" timeout="20s" \
op start interval="0" timeout="40s" \
op stop interval="0" timeout="60s"
Or, if you want to use the script LSB :
primitive apache2 lsb:apache2 \
op monitor interval="30s" timeout="20s" \
op start interval="0" timeout="40s" \
op stop interval="0" timeout="60s"
And add 'apache2' in your 'only-group' group (care about the order)
group only-group node_one_ip mysql-server customservice1 apache2
精彩评论