如何使用Pacemaker重启httpd

发布于 2024-11-30 00:58:55 字数 2668 浏览 1 评论 0原文

我们有两台带有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

や三分注定 2024-12-07 00:58:55

为了让 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.

何以笙箫默 2024-12-07 00:58:55

您需要在 Pacemaker 上添加 httpd 原语:

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"

或者,如果您想使用脚本 LSB:

primitive apache2 lsb:apache2 \
     op monitor interval="30s" timeout="20s" \
     op start interval="0" timeout="40s" \ 
     op stop interval="0" timeout="60s"

并在您的“only-group”组中添加“apache2”(关心顺序)

group only-group node_one_ip mysql-server customservice1 apache2

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文