Pacemaker資料一覧
Apacheのリソースが起動後すぐに停止してしまう
対応バージョン: Pacemaker 1.0.13, Heartbeat 3.0.5
以下のようなApacheのリソース定義がある(VIP定義とのグルーピング)。
# crm configure show : primitive httpd ocf:heartbeat:apache \ params configfile="/etc/httpd/conf/httpd.conf" statusurl="http://192.168.1.101/" \ op start interval="0" timeout="90" on-fail="restart" \ op monitor interval="10" timeout="60" on-fail="restart" \ op stop interval="0" timeout="300" on-fail="block" primitive vip_httpd ocf:heartbeat:IPaddr2 \ params ip="192.168.1.101" nic="eth1" cidr_netmask="24" \ op monitor interval="10" group web vip_httpd httpd \ meta target-role="Started" :
Apacheのサービスをserviceコマンドで普通に起動した場合はうまく動作するが、Pacemakerのリソースとして起動した場合は一瞬起動してすぐに停止してしまう。
正常
# service httpd start Starting httpd: [ OK ] # tail /var/log/httpd/error_log : [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
起動後すぐに停止
# crm resource start web # crm_mon -f : Online: [ s1 s2 ] Resource Group: web vip_httpd (ocf::heartbeat:IPaddr2): Started s1 httpd (ocf::heartbeat:apache): Stopped Migration summary: * Node s1: httpd: migration-threshold=1000000 fail-count=1000000 * Node s2: Failed actions: httpd_start_0 (node=s1, call=281, rc=1, status=complete): unknown error # tail /var/log/httpd/error_log : [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/ [notice] caught SIGWINCH, shutting down gracefully
これはPacemakerのApache Resource Agent(/usr/lib/ocf/resource.d/heartbeat/apache)がApacheの動作をモニタする際に以下の動きをするからである。
1.apache_monitor_basic()においてリソース定義のstatusurl=に指定したURLにアクセスし(358行目)、HTMLファイルが取得できないと次の処理に移り、363行目で呼び出したattempt_index_monitor_request()関数内において$OCF_RESKEY_statusurlに上記URLが設定されている(340行目)ために1を返し、結果的に371行目でエラー($OCF_ERR_GENERIC)を返す。
328 attempt_index_monitor_request() { : 340 if [ -n "$OCF_RESKEY_statusurl" ]; then 341 return 1; 342 fi : 357 apache_monitor_basic() { 358 if ${ourhttpclient}_func "$STATUSURL" | grep -Ei "$TESTREGEX" > /dev/null 359 then 360 return $OCF_SUCCESS 361 fi 362 363 attempt_index_monitor_request 364 if [ $? -eq 0 ]; then 365 return $OCF_SUCCESS 366 fi 367 368 if ! ocf_is_probe; then 369 ocf_log err "Failed to access httpd status page." 370 fi 371 return $OCF_ERR_GENERIC 372 }
2.エラーを受け取った上位の関数はapache_stop()を呼び出しApacheを停止する。
191 while : # wait until the user set timeout 192 do 193 apache_monitor 194 ec=$? 195 if [ $ec -eq $OCF_NOT_RUNNING ] 196 then 197 tries=`expr $tries + 1` 198 ocf_log info "waiting for apache $CONFIGFILE to come up" 199 sleep 1 200 else 201 break 202 fi 203 done 204 205 if [ $ec -ne 0 ] && silent_status; then 206 apache_stop 207 fi
これを回避するにはドキュメントルート(httpd.confのDocumentRootで指定したディレクトリ、/var/www/html等)にダミーのindex.htmlを置いておけばよい。
ダミーなので以下のような内容で構わない。
<html> </html>
この対処を行えばリソースは正常に起動する。
# crm resource cleanup httpd s1 # crm_mon -f : Online: [ s1 s2 ] Resource Group: web vip_httpd (ocf::heartbeat:IPaddr2): Started s1 httpd (ocf::heartbeat:apache): Started s1 :関連