【问题标题】:How to use Pacemaker to restart httpd如何使用 Pacemaker 重启 httpd
【发布时间】:2011-10-28 06:06:21
【问题描述】:

我们有两台带有 Pacemaker (crm) 设置的服务器,可启用主/备用集群。目前有两个由 Pacemaker 控制/监控的服务,如果其中任何一个出现故障,将导致故障转移到备用服务器,即我们自己的自定义服务(以下称为 customservice1)和 mysql。

customservice1 和 mysql 在备用服务器上停止并在主服务器上运行(显然)。当发生故障转移时,起搏器似乎会停止两者(或者如果只有一个因某种原因失败,则确保它们停止,我不太清楚这一点),更改主服务器和备用服务器的 IP 地址(以便DNS 中的别名将始终转到主服务器),然后在之前的备用服务器上启动 customservice1 和 mysql。

我想为此添加一个步骤,由起搏器控制,只要发生故障转移,它将简单地重新启动 httpd。 httpd 目前一直在主备服务器上运行。 httpd 中的故障目前不会导致故障转移,我对添加该监控并不真正感兴趣,我只是希望起搏器在使备用服务器成为主要服务器时运行相当于“服务 httpd 重启”。

添加只会重新启动服务的新原语的正确语法是什么?

目前的起搏器配置如下:

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"

【问题讨论】:

    标签: linux cluster-computing apache high-availability failover


    【解决方案1】:

    您需要在 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"
    

    并在您的“唯一组”组中添加“apache2”(关心订单)

    group only-group node_one_ip mysql-server customservice1 apache2
    

    【讨论】:

      【解决方案2】:

      为了让 Pacemaker 执行此操作,您需要将 http 服务器置于 Pacemaker 的控制之下,然后在组和 http 守护程序之间创建一个排序约束。 根据记忆,您需要确保约束的得分 > 0。

      否则,您需要修改现有资源的脚本以根据需要重新启动 httpd。

      【讨论】:

      • “将 http 服务器置于 Pacemaker 的控制之下”是否意味着为它添加一个原语?假设不是,我可以让我的新原语成为现有组的成员吗?关于 httpd 与该组的其他成员,实际上并没有需要尊重的顺序,但我可能会先做到。
      猜你喜欢
      • 1970-01-01
      • 2012-08-06
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 2021-05-21
      • 2014-06-02
      • 2016-06-06
      • 1970-01-01
      相关资源
      最近更新 更多