Heartbeat + Pacemaker で3ノードクラスタ

Heartbeat + Pacemaker で冗長構成作ってみました。3ノードでVIPを2つ共有します。
DRBDは絡みませんのでDRBDがらみの設定が知りたい方はすぐにブラウザバック!!

環境

  • node1.info eth0[192.168.1.1] eth1[10.0.0.1]
  • node2.info eth0[192.168.1.2] eth1[10.0.0.2]
  • node3.info eth0[192.168.1.3] eth1[10.0.0.3]
  • サービス用VIP 192.168.1.4 192.168.1.5

こんな感じ?

Heartbeat + Pacemaker Install

全部rootで作業してます。。。
3台全てに設定します。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# hostsに登録
echo -e "192.168.1.1 node1.info\n192.168.1.2 node2.info\n192.168.1.3 node3.info" >> /etc/hosts

# heartbeat pacemaker インストール
cd /usr/local/src/
wget http://jaist.dl.sourceforge.jp/linux-ha/58547/pacemaker-1.0.13-1.1.el6.x86_64.repo.tar.gz
tar xvzf pacemaker-1.0.13-1.1.el6.x86_64.repo.tar.gz
mv pacemaker-1.0.13-1.1.el6.x86_64.repo /tmp/
cd /tmp/pacemaker-1.0.13-1.1.el6.x86_64.repo/
yum -c pacemaker.repo install  pacemaker-1.0.13 heartbeat.x86_64
echo "exclude=pacemaker pacemaker-libs corosync cluster-glue heartbeat resource-agents" >> /etc/yum.conf

# rsyslog.confに下記を追加
local1.*          /var/log/ha-log

ha.cfを書きます。nodeを3つにしとけば良さげです。eth0,eth1両方マルチキャストで監視します。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pacemaker on
logfacility local1

debug 0
udpport 694

keepalive 2
warntime 20
deadtime 24
initdead 48
auto_failback off

mcast eth0 225.0.0.1 694 1 0
mcast eth1 224.0.0.1 694 1 0

node node1.info
node node2.info
node node3.info
uuidfrom nodename

watchdog /dev/watchdog

authkeysも適当に。。。

1
2
auth 1
1 sha1 shared_key

chmod 400 /etc/ha.d/authkeys でパーミッション設定忘れずに。
あとはheartbeat起動すればこんな感じになるはず。。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/etc/init.d/heartbeat start

crm_mon -1A
============
Last updated: Tue May 21 07:57:46 2013
Stack: Heartbeat
Current DC: node1.info (87b07da8-5cf5-f0ec-be67-c2a90dcfd635) - partition with quorum
Version: 1.0.13-30bb726
3 Nodes configured, unknown expected votes
0 Resources configured.
============

Online: [ node1.info node2.info node3.info ]


Node Attributes:
* Node node1.info:
* Node node2.info:
* Node node3.info:

pacemaker設定

ここからはcrmシェルを使って設定します。STONITHはとりあえず無効で。。。
GW(192.168.1.254)にping打って失敗したらフェイルオーバーするようにします。
VIP1はnode1=>node3=>node2,VIP2はnode2=>node3=>node1の順にフェイルオーバーするようにlocation設定します。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
crm configure
crm(live)configure# property no-quorum-policy="ignore" stonith-enabled="false"
crm(live)configure# rsc_defaults resource-stickiness="INFINITY" migration-threshold="1"
crm(live)configure# primitive vip1 ocf:heartbeat:IPaddr2 params ip="192.168.1.4" nic="eth0" cidr_netmask="24"
crm(live)configure# primitive vip2 ocf:heartbeat:IPaddr2 params ip="192.168.1.5" nic="eth0" cidr_netmask="24"

crm(live)configure# primitive prmPingd ocf:pacemaker:pingd \
> params name="default_ping_set" host_list="192.168.1.254" multiplier="100" dampen="1" \
> op start interval="0s" timeout="90s" on-fail="restart" \
> op monitor interval="5s" timeout="30s" on-fail="restart" \
> op stop interval="0s" timeout="100s" on-fail="block"

crm(live)configure# clone clnPingd prmPingd meta clone-max="3" clone-node-max="1" target-role="Started"

crm(live)configure# location location1 vip1 \
> rule $id="location1-rule" 300: #uname eq node1.info \
> rule $id="location1-rule-0" 200: #uname eq node3.info \
> rule $id="location1-rule-1" 100: #uname eq node2.info \
> rule $id="location1-rule-2" -inf: not_defined default_ping_set or default_ping_set lt 100

crm(live)configure# location location2 vip2 \
> rule $id="location2-rule" 300: #uname eq node2.info \
> rule $id="location2-rule-0" 200: #uname eq node3.info \
> rule $id="location2-rule-1" 100: #uname eq node1.info \
> rule $id="location2-rule-2" -inf: not_defined default_ping_set or default_ping_set lt 100

crm(live)configure# verify
crm(live)configure# commit

んでうまくいけばこうなるはず。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
crm_mon -1A 
============ 
Last updated: Wed May 22 12:10:49 2013 
Stack: Heartbeat 
Current DC: node1.info (87b07da8-5cf5-f0ec-be67-c2a90dcfd635) - partition with quorum 
Version: 1.0.13-30bb726 
3 Nodes configured, unknown expected votes 
3 Resources configured. 
============ 

Online: [ node1.info node2.info node3.info ] 

vip1   (ocf::heartbeat:IPaddr2):       Started node1.info 
vip2   (ocf::heartbeat:IPaddr2):       Started node2.info 
Clone Set: clnPingd 
  Started: [ node1.info node2.info node3.info ] 

Node Attributes: 
* Node node1.info: 
    + default_ping_set                  : 100 
* Node node2.info: 
    + default_ping_set                  : 100 
* Node node3.info: 
    + default_ping_set                  : 100

あとは実際にフェイルオーバーさせて設定通りに動くか確認して完了です!

Comments