Linux:CentOS5(x64):install:heartbeat
提供:KinusatiWiki
目次 |
heartbeatのインストール
CentOS(x64)でdrbdを利用したHAクラスタリング環境を構築するためheartbeatを利用する
heartbeatセットアップ作業
インストール作業(1/2台目)
yumで一発です。簡単・・といいたいのですが、一回目のインストールでは「ユーザ hacluster は存在します」というエラーで失敗しますのでコマンドを二回実行します。
# yum -y install heartbeat ... (1/3): heartbeat-pils-2.1.3-3.el5.centos.x86_64.rpm | 220 kB 00:00 (2/3): heartbeat-stonith-2.1.3-3.el5.centos.x86_64.rpm | 348 kB 00:00 (3/3): heartbeat-2.1.3-3.el5.centos.x86_64.rpm | 1.8 MB 00:00 -------------------------------------------------------------------------- Total 4.1 MB/s | 2.3 MB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : heartbeat-pils 1/3 Installing : heartbeat-stonith 2/3 useradd: ユーザ hacluster は存在します error: %pre(heartbeat-2.1.3-3.el5.centos.x86_64) scriptlet failed, exit status 9 error: install: %pre scriptlet failed (2), skipping heartbeat-2.1.3-3.el5.centos Installed: heartbeat.x86_64 0:2.1.3-3.el5.centos Dependency Installed: heartbeat-pils.x86_64 0:2.1.3-3.el5.centos heartbeat-stonith.x86_64 0:2.1.3-3.el5.centos Complete! # yum -y install heartbeat ... Installed: heartbeat.x86_64 0:2.1.3-3.el5.centos Complete!
コンフィグ設定(1/2台目)
コンフィグファイルを作成します。ファイルは次の3ファイルです。
- /etc/ha.d/ha.cf
- /etc/logd.cf
- /etc/ha.d/authkeys
/etc/ha.d/ha.cf
ha.cfを編集する。test1.example.com, test2.example.comでクラスタリングする。
# cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d # vi /etc/ha.d/ha.cf keepalive 2 deadtime 30 initdead 120 udpport 694 mcast eth0 225.0.0.1 694 1 0 auto_failback off watchdog /dev/watchdog node test1.example.com node test2.example.com use_logd yes crm yes
なおクラスタリング時にはクラスタメンバ間で生死確認を行うのだが、BroadCastで行うと同一セグメントに2クラスタ以上存在すると以下のメッセージが出て具合が悪いので、マルチキャストで構成することにした。
heartbeat[16149]: 2010/03/07_11:07:52 ERROR: process_status_message: bad node [other1.example.com] in message heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG: Dumping message with 12 fields heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[0] : [t=status] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[1] : [st=active] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[2] : [dt=7530] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[3] : [protocol=1] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[4] : [src=other1.example.com] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[5] : [(1)srcuuid=0xa640b48(36 27)] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[6] : [seq=95cb] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[7] : [hg=4b73dc92] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[8] : [ts=4b930a77] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[9] : [ld=0.00 0.00 0.00 1/80 23920] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[10] : [ttl=3] heartbeat[16149]: 2010/03/07_11:07:52 ERROR: MSG[11] : [auth=1 4c9e6516]
/etc/logd.cf
logd.cfを編集する
# cp /usr/share/doc/heartbeat-2.1.3/logd.cf /etc/ # vi /etc/logd.cf debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility none
/etc/ha.d/authkeys
authkeysを編集する
# cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/authkeys # vi /etc/ha.d/authkeys auth 2 2 sha1 HI! # chmod 600 /etc/ha.d/authkeys
リソースの登録
HAクラスタにはリソースという概念がある。 登録されるリソースにはIP・ファイルシステム・Apacheプロセス等多岐にわたる。 このリソースを連携させることでクラスタの起動・停止・ファイルオーバ・フェイルバック・プロセス異常の検知等が動作する。
ここではDRBDデバイスと仮想IPアドレスのリソースを登録する。
リソースファイルの作成(1台目)
まずリソースファイルのひな形を作成する。
# cd /etc/ha.d
# vi /etc/ha.d/haresources
test1.example.com \
IPaddr2::192.168.0.11/24/eth0/192.168.0.255 \
MailTo::root@example.com::failover-test1.example.com \
drbddisk::r0 \
Filesystem::/dev/drbd0::/mnt
ひな形からXML形式に変換する。
# /usr/lib64/heartbeat/haresources2cib.py haresources
なぜかIPaddr2リソースで定義したnetmaskとデバイスが逆に登録されるため修正する。
# vi /var/lib/heartbeat/crm/cib.xml <nvpair id="IPaddr2_1_attr_1" name="nic" value="24"/> => nicの指定なのにnetmaskの"24"が登録されている <nvpair id="IPaddr2_1_attr_2" name="cidr_netmask" value="eth0"/> => netmaskの指定なのにnicの"eth0"が登録されている
以下のように修正する
<nvpair id="IPaddr2_1_attr_1" name="nic" value="eth0"/> <nvpair id="IPaddr2_1_attr_2" name="cidr_netmask" value="24"/>
設定ファイルを検証する
# crm_verify -x /var/lib/heartbeat/crm/cib.xml
リソースファイルの作成(2台目)
2台目のリソースファイルひな形を作成する
# cd /etc/ha.d
# vi /etc/ha.d/haresources
test2.example.com \
IPaddr2::192.168.0.11/24/eth0/192.168.0.255 \
MailTo::root@example.com::failover-test1.example.com \
drbddisk::r0 \
Filesystem::/dev/drbd0::/mnt
後は一台目と同じ。
# /usr/lib64/heartbeat/haresources2cib.py haresources # vi /var/lib/heartbeat/crm/cib.xml <nvpair id="IPaddr2_1_attr_1" name="nic" value="24"/> => nicの指定なのにnetmaskの"24"が登録されている <nvpair id="IPaddr2_1_attr_2" name="cidr_netmask" value="eth0"/> => netmaskの指定なのにnicの"eth0"が登録されている 以下のように修正する <nvpair id="IPaddr2_1_attr_1" name="nic" value="eth0"/> <nvpair id="IPaddr2_1_attr_2" name="cidr_netmask" value="24"/> # crm_verify -x /var/lib/heartbeat/crm/cib.xml
クラスタサービスを起動する(1/2台目とも) =
heartbeatを起動する
# chkconfig heartbeat on # service heartbeat start