Pacemaker+Heartbeatを試してみる(インストール編)の続き。
サーバの構成は以下。
ノード名 | 外向けIPアドレス | インターコネクト1 | インターコネクト2 |
---|---|---|---|
ha1.localdomain | 192.168.56.10(eth1) | 172.35.10.10(eth2) | 172.40.20.10(eth3) |
ha2.localdomain | 192.168.56.20(eth3) | 172.35.10.20(eth4) | 172.40.20.20(eth5) |
それぞれのサーバでha.cfを設定。
ha.cfは雛形になるファイルがあるので、そのファイルをコピーして使用する。
必要な部分のみコメントアウトを外していく。
ucast、nodeは環境に合わせて設定。nodeは、uname -nで出力される名前を指定する。
auto_failbackはoffに変更した。(系切替後に故障サーバが復旧したとき、自動で切り戻る事を防止する)
「pacemaker on」は自分で追加。
両方のサーバの違いはucastの指定部分のみ。
[root@ha1 /]# cp -p /usr/share/doc/heartbeat-3.0.5/ha.cf /etc/ha.d/ha.cf [root@ha1 /]# vi /etc/ha.d/ha.cf [root@ha1 /]# cat /etc/ha.d/ha.cf | egrep -v '^#' | egrep -v '^$' debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local0 keepalive 2 deadtime 30 warntime 10 initdead 120 udpport 694 ucast eth2 172.35.10.20 ucast eth3 172.40.20.20 auto_failback off node ha1.localdomain node ha2.localdomain pacemaker on
[root@ha2 /]# cp -p /usr/share/doc/heartbeat-3.0.5/ha.cf /etc/ha.d/ha.cf [root@ha2 /]# vi /etc/ha.d/ha.cf [root@ha2 /]# cat //etc/ha.d/ha.cf | egrep -v '^#' | egrep -v '^$' debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local0 keepalive 2 deadtime 30 warntime 10 initdead 120 udpport 694 ucast eth4 172.35.10.10 ucast eth5 172.40.20.10 auto_failback off node ha1.localdomain node ha2.localdomain pacemaker on
authkeysの設定。こちらは両方のサーバで共通。
コピー後にファイルの権限変更が必要なので注意。
今回はsha1アルゴリズムを使用している。
# cp -p /usr/share/doc/heartbeat-3.0.5/authkeys /etc/ha.d/authkeys # chown root:root /etc/ha.d/authkeys # chmod 600 /etc/ha.d/authkeys # vi /etc/ha.d/authkeys # cat //etc/ha.d/authkeys | egrep -v '^#' | egrep -v '^$' auth 2 2 sha1 secret
両系でheartbeatを起動してみる。
# service heartbeat start
で、起動してみたが、crm_monがいつまでも接続できない。
/var/log/ha-logを見ると、以下のようなエラーが。
Oct 07 17:23:52 ha1.localdomain heartbeat: [5107]: ERROR: glib: ucast: error binding socket. Retrying: Permission denied Oct 7 17:23:52 ha1 heartbeat: [5107]: ERROR: glib: ucast: error binding socket. Retrying: Permission denied Oct 07 17:23:53 ha1.localdomain heartbeat: [5107]: ERROR: glib: ucast: error binding socket. Retrying: Permission denied Oct 7 17:23:53 ha1 heartbeat: [5107]: ERROR: glib: ucast: error binding socket. Retrying: Permission denied Oct 07 17:23:54 ha1.localdomain heartbeat: [5107]: ERROR: glib: ucast: unable to bind socket. Giving up: Permission denied Oct 07 17:23:54 ha1.localdomain heartbeat: [5107]: ERROR: make_io_childpair: cannot open ucast eth2 Oct 7 17:23:54 ha1 heartbeat: [5107]: ERROR: glib: ucast: unable to bind socket. Giving up: Permission denied Oct 7 17:23:54 ha1 heartbeat: [5107]: ERROR: make_io_childpair: cannot open ucast eth2 Oct 07 17:23:55 ha1.localdomain heartbeat: [5111]: CRIT: Emergency Shutdown: Master Control process died. Oct 07 17:23:55 ha1.localdomain heartbeat: [5111]: CRIT: Killing pid 5107 with SIGTERM Oct 07 17:23:55 ha1.localdomain heartbeat: [5111]: CRIT: Emergency Shutdown(MCP dead): Killing ourselves. Oct 7 17:23:55 ha1 heartbeat: [5111]: CRIT: Emergency Shutdown: Master Control process died. Oct 7 17:23:55 ha1 heartbeat: [5111]: CRIT: Killing pid 5107 with SIGTERM Oct 7 17:23:55 ha1 heartbeat: [5111]: CRIT: Emergency Shutdown(MCP dead): Killing ourselves. Oct 7 17:26:59 ha1 heartbeat: [5179]: info: Pacemaker support: on
SELinuxが悪さをしているという情報があった。SELinux、iptablesを無効にしてみる。
# getenforce Enforcing # setenforce 0 # getenforce Permissive # iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination # service iptables stop
再度チャレンジ。
両方のサーバでheartbeatを起動。
# service heartbeat start
crm_monの内容を確認。
# crm_mon -1r ============ Last updated: Tue Oct 7 18:09:46 2014 Stack: Heartbeat Current DC: ha2.localdomain (8b5fa310-2ad6-6504-5874-35e498f88c61) - partition with quorum Version: 1.0.13-30bb726 2 Nodes configured, unknown expected votes 0 Resources configured. ============ Online: [ ha1.localdomain ha2.localdomain ] Full list of resources:
サーバ2台がOnlineになった。起動出来たっぽい。
SELinuxは特に要らないので、iptablesともどもOFFにする。
# vi /etc/selinux/config SELINUX=enforcing ↓ SELINUX=permissive
# chkconfig iptables off # chkconfig --list iptables iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
(追記)
/etc/ha.d/ha.cfの内容を変更してpacemaker再起動を繰り返すと、crm_monの結果に
Node ha1.localdomain (994f9fdb-49d2-458f-a26f-3d7ace82063b): UNCLEAN (offline) Node ha2.localdomain (701f93e2-b2e2-4c22-b5e7-57f88fd864b6): UNCLEAN (offline)
のような出力が現れる。
これを削除するには、crm configure edit でcrm設定を開き、該当のnode定義を削除する必要がある。
参考:
OSごとコピーしてLinux-HA環境作りTai! « Linux-HA Japan