Pacemaker - httpd を監視対象にする2011/06/18 |
|
httpd をクラスタ構成に設定してみます。よって httpdインストール済みを前提とします。
なお、httpd は停止させておいてください。
例として、ここでは以下の2台でクラスタ環境を構築しています。
(1) www01.srv.world ( eth0 [192.168.1.60], eth1 [10.0.0.60] ) (2) www02.srv.world ( eth0 [192.168.1.61], eth1 [10.0.0.61] )
eth0 をインターコネクト用、eth1 をサービス提供用として設定しています。
|
|
| [1] |
まず最初に仮想IPアドレスの設定をしておいてください。
|
| [2] | httpd の server-status を有効にしておきます。双方のサーバーで設定してください。 |
|
[root@www01 ~]#
vi /etc/httpd/conf/httpd.conf # 921-926行目:コメント解除しアクセス許可範囲変更 <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 10.0.0.0/24 </Location> |
| [3] | クラスタの設定です。いずれか一方のサーバーで設定してください。 |
|
[root@www01 ~]# crm configure crm(live)configure# primitive httpd ocf:heartbeat:apache \ > params configfile="/etc/httpd/conf/httpd.conf" \ > port="80" \ > op start interval="0s" timeout="60s" \ > op monitor interval="5s" timeout="20s" \ > op stop interval="0s" timeout="60s" crm(live)configure# group webserver vip httpd # グループ化する crm(live)configure# show # 設定確認
node www01.srv.world
node www02.srv.world
primitive httpd ocf:heartbeat:apache \
params configfile="/etc/httpd/conf/httpd.conf" port="80" \
op start interval="0s" timeout="60s" \
op monitor interval="5s" timeout="20s" \
op stop interval="0s" timeout="60s"
primitive vip ocf:heartbeat:IPaddr2 \
params ip="10.0.0.100" cidr_netmask="24" \
op start interval="0s" timeout="60s" \
op monitor interval="5s" timeout="20s" \
op stop interval="0s" timeout="60s"
group webserver vip httpd
property $id="cib-bootstrap-options" \
dc-version="1.1.2-f059ec7ced7a86f18e5490b67ebf4a0b963bccfe" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
no-quorum-policy="ignore" \
stonith-enabled="false"
rsc_defaults $id="rsc-options" \
resource-stickiness="INFINITY" \
migration-threshold="1"
crm(live)configure# commit # 設定を有効にする crm(live)configure# exit bye |
| [4] | 以上の設定をして crm_mon で状態を確認すると以下のようにいずれか一方のサーバーで httpd が起動します。 |
|
[root@www01 ~]# crm_mon
============
Last updated: Sun Jun 19 02:36:45 2011
Stack: openais
Current DC: www01.srv.world - partition with quorum
Version: 1.1.2-f059ec7ced7a86f18e5490b67ebf4a0b963bccfe
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ www01.srv.world www02.srv.world ]
Resource Group: webserver
vip (ocf::heartbeat:IPaddr2): Started www01.srv.world
httpd (ocf::heartbeat:apache): Started www01.srv.world
|
| [5] | Webブラウザで設定した仮想IPにアクセスすると設定通り www01.srv.world が応答します。 |
|
| [6] | www01.srv.world 側で強制的に httpd をダウンさせると設定通り即座に www02.srv.world に切り替わります。 |
|
| Sponsored Link |
|
|