2011-08-16 42 views
1

我們有兩臺帶有Pacemaker(crm)設置的服務器,可啓用主/備用羣集。目前有兩種服務由Pacemaker控制/監控,如果發生故障,將導致故障切換到備用服務器,我們自己的定製服務(以下稱爲customservice1)和mysql。如何使用Pacemaker重新啓動httpd

customservice1和mysql在備用服務器上停止並且在主服務器上運行(顯然)。當故障轉移發生時,看起來心臟起搏器會停止這兩種情況(或者如果只有一個人出於任何原因失敗,我不太清楚這一點,確保他們停止),更改主要和備用的IP地址(以便DNS中的別名將始終轉到主服務器上),然後在之前的備用服務器上啓動customservice1和mysql。

我想添加一個步驟,由pacemaker控制,只需在發生故障轉移時重新啓動httpd。目前httpd一直在主服務器和備用服務器上運行。目前,httpd中的故障不會導致故障轉移,我對增加監控並不感興趣,我只是想讓起搏器在使備用服務器成爲主服務器時運行相當於'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" 

回答

0

爲了起搏器做到這一點,你需要把HTTP服務器起搏器的控制之下,然後創建組和HTTP之間的排序約束守護進程。 從內存中,您需要確保約束條件下得分> 0。

否則,您需要修改現有資源的腳本以根據需要重新啓動httpd。

+0

「將http服務器置於Pacemaker的控制下」是否意味着不僅僅是爲它添加原語?假設不,我可以讓我的新原型成爲現有團隊的成員嗎?關於httpd與其他團隊成員之間並沒有什麼需要尊重的順序,但我可能只是先做出來。 – twilbrand

0

您需要添加的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