Heartbeatのインストールと基本設定

昨日Fedra Coreは2台のPCにインストール。ちょっとした可用性を求められる用途に使うのですが、両方に入れるだけのライセンスがないので、もっと下のレイヤでクラスタ構成にします。ということでここを参考にしてインストールと基本設定までをやりました。

前提条件

今回使用する機器は2つ。マシン名はverde,marronです。それぞれ名前解決が相互にできること。

インストール

インストールは昨日yumを設定したのでとっても簡単。

# yum install heartbeat

基本設定

/usr/share/doc/heartbeat-2.0.8にサンプルの設定ファイルがあるので、これを適当なところへコピーします。

# cd /usr/share/doc/heartbeat-2.0.8
# ls
AUTHORS              GettingStarted.txt  apphbd.cf      haresources
COPYING              HardwareGuide.html  authkeys       heartbeat_api.html
COPYING.LGPL         HardwareGuide.txt   faqntips.html  heartbeat_api.txt
ChangeLog            README              faqntips.txt   rsync.html
DirectoryMap.txt     Requirements.html   ha.cf          rsync.txt
GettingStarted.html  Requirements.txt    ha_logd.cf     startstop
# cp ha_logd.cf /etc/logd.cf
# cp authkeys /etc/ha.d
# cp ha.cf /etc/ha.d

authkeysファイルを編集

ファイル内容を編集します。ファイル内容はシグネチャキー。適当なことばをタイプしておけばOK。authディテクティブのコメントを外し上書き。
内容はこんな感じ。

#
#       Authentication file.  Must be mode 600
#
#
#       Must have exactly one auth directive at the front.
#       auth    send authentication using this method-id
#
#       Then, list the method and key that go with that method-id
#
#       Available methods: crc sha1, md5.  Crc doesn't need/want a key.
#
#       You normally only have one authentication method-id listed in this file
#
#       Put more than one to make a smooth transition when changing auth
#       methods and/or keys.
#
#
#       sha1 is believed to be the "best", md5 next best.
#
#       crc adds no security, except from packet corruption.
#               Use only on physically secure networks.
#
auth 1
1 sha1 Six sick slick slim sycamore saplings.

編集したらパーミションを600にしておきます。

# chmod 600 authkeys

/etc/logd.cfを編集

logfacilityをsyslogじゃなくて、heartbeatのデーモンを使うようにします。

logfacility     daemon

/etc/ha.d/ha.cfファイルを編集

最低限でこれだけ追加。

use_logd        yes
bcast   eth0
node    verde marron
crm on

それぞれのディレクティブの意味は

use_logd
ログを取るかどうか。
bcast
ブロードキャストハートビートパケットを流すネットワークインタフェイス
node
このクラスタを構成するノードのホスト名
crm
modern(r2)形式の構成を使うか。CRMはCluster Resource Managerの略。

もう一個のクラスタへ設定ファイルをコピー

設定ファイル群を、もう一台のクラスタノードへコピーします。

# cd /etc/ha.d
# scp ./ha.cf ./authkeys verde:/etc/ha.d
# cd ..
# scp ./logd.cf verde:/etc/logd.cf

起動する

yumでインストールすると、こんなスクリプトまでちゃんと入ってくるんだね。らくちんだなぁ。

# /etc/init.d/heartbeat start
Starting High-Availability services:
                                                           [  OK  ]

動いているかどうか確認

# crm_mon -i5
Refresh in 4s...

============
Last updated: Wed Jul 11 11:09:23 2007
Current DC: marron (0269a2cc-4aaa-4a7a-84aa-ce9de2f753b1)
2 Nodes configured.
0 Resources configured.
============

Node: marron (0269a2cc-4aaa-4a7a-84aa-ce9de2f753b1): online
Node: verde (dd58ba7b-eac3-44be-885c-1093359b865c): online

実際のクラスタ定義なんかは別のところで設定するみたい。これは明日以降かな。