LoginSignup
3
3

More than 5 years have passed since last update.

UbuntuでPacemaker + Heartbeatを使う

Posted at

Pacemaker + Heartbeat

Pacemakerインストール準備

Active / Standby 両方で実施

/etc/apt/sources.list へリポジトリ追加し、インストール

deb http://ppa.launchpad.net/ubuntu-ha/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/ubuntu-ha/ppa/ubuntu karmic main
# atp-get update
# apt-get install pacemaker heartbeat fence-agents

heartbeatの設定

Active / Standby 両方で実施

/etc/ha.d/ha.cf を作成

pacemaker on
logfile /var/log/ha-log
keepalive 3
deadtime 30
deadping 40
warntime 10
initdead 60
udpport 694
node HOST_A
node HOST_B
ucast eth0 HOST_A_PrivateIP
ucast eth0 HOST_B_PrivateIP
uuidfrom nodename

/etc/ha.d/authkeys を作成

auth 1
1 crc

# chmod 600 /etc/ha.d/authkeys

heatbeatのlrmdをpacemakerに変更

# mv /usr/lib/heartbeat/lrmd /usr/lib/heartbeat/lrmd.org
# ln -sf /usr/lib/pacemaker/lrmd /usr/lib/heartbeat/lrmd

lrmdの変更をしたらcrm_monでのステータスがONLINEになる

(変更していなかったらSSH接続が1〜2分程度で切れていました)

Active サーバで実施

*どちらか一方のサーバでやればOKです

crmコマンドで設定をする

# crm configure property stonith-enabled="false"
(STONITHの停止)

# crm configure property no-quorum-policy="ignore"
(Quorumの設定をignoreへ変更)

ついでにZabbixの設定もする

# crm configure primitive zabbix-server lsb:zabbix-server \
 op start interval="0s" timeout="60s" on-fail="restart" \
 op monitor interval="30s" timeout="60s" on-fail="restart" \
 op stop interval="0s" timeout="60s" on-fail="fence"

Pacemaker,Heartbeatの起動

# /etc/init.d/heartbeat start
# /etc/init.d/pacemaker start

crm_monコマンドで確認

# crm_mon -i1
Last updated: Thu Nov 13 08:37:28 2014
Last change: Tue Nov 11 11:28:17 2014 via crm_resource on active
Stack: heartbeat
Current DC: standby (xxxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx) - partition with quorum
Version: 1.1.10-42f2063
2 Nodes configured
1 Resources configured


Online: [ active standby ]

zabbix-server   (lsb:zabbix-server):    Started active

activeサーバでZabbixServerが起動中であることがわかる

テスト

注意: ZabbixServerのDBをRDSにしているのでDBの切替とか特に設定してません

activeサーバでZabbixServerが起動してるのがわかったのでサーバを停止する
この後StandbyサーバでZabbixServerが起動すればOK

  • activeサーバ停止前の状態
root@active:~# /etc/init.d/zabbix-server status
 * zabbix_server is running

root@standby:~# /etc/init.d/zabbix-server status
 * zabbix_server is not running

実際にサーバを停止してみる

Last updated: Thu Nov 13 08:46:31 2014
Last change: Tue Nov 11 11:28:17 2014 via crm_resource on active
Stack: heartbeat
Current DC: standby  (xxxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx)  - partition with quorum
Version: 1.1.10-42f2063
2 Nodes configured
1 Resources configured


Online: [ standby ]
OFFLINE: [ active ]

zabbix-server   (lsb:zabbix-server):    Started standby

standbyサーバでZabbixServerが起動していることがわかる

  • activeサーバ停止後の状態
root@standby:~# /etc/init.d/zabbix-server status
 * zabbix_server is running

activeサーバを起動し、standbyサーバでZabbixServerが停止するのを確認する

Last updated: Thu Nov 13 10:21:23 2014
Last change: Tue Nov 11 11:28:17 2014 via crm_resource on active
Stack: heartbeat
Current DC: standby (32f23505-7a3b-e54c-9310-b26f6b13bece) - partition with quorum
Version: 1.1.10-42f2063
2 Nodes configured
1 Resources configured


Online: [ active standby ]

zabbix-server   (lsb:zabbix-server):    Started active

ZabbixServerがactiveに切り替わっていることを確認

  • activeサーバ起動後の状態
root@active:~# /etc/init.d/zabbix-server status
 * zabbix_server is running

root@standby:~# /etc/init.d/zabbix-server status
 * zabbix_server is not running

これで自動的にフェイルバックまで実施されるようになる。
フェイルバックしない時はcrmで以下の設定を追加する

  • どちらかのサーバで実行
# crm configure property defalut-resource-stickiness=INFINITY
# crm configure property default-resource-failure-stickiness=INFINITY
("Do you still want to commit?"にyを返す)
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3