Help us understand the problem. What is going on with this article?

UbuntuでPacemaker + Heartbeatを使う

More than 5 years have passed since last update.

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を返す)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away