参考文献
やったこと
- corosyncとpacemakerのインストール
- corosyncの基本設定
- クラスタが組めていることをcrmで確認
1. とりあえず、インストールして動かしてみる
$ sudo apt-get install corosync
$ sudo apt-get install pacemaker
$ vi /etc/corosync/corosync.conf
下記を追加
service {
name: pacemaker
ver: 0
use_mgmtd: yes
}
下記を編集
interface {
# The following values need to be set based on your environment
ringnumber: 0
bindnetaddr: 192.168.5.0 <= 適宜編集
mcastaddr: 226.94.1.1
mcastport: 5405
}
$ sudo service corosync start
=> 何も起こらない・・・・
$ sudo /etc/init.d corosync start
=> 何も起こらない
$ ps ax | grep corosync
=> corosyncがきちんと動いてないっぽい
そもそも、corosyncの起動に失敗してる。。。。
initスクリプトを見てみる
# ! /bin/sh
#
### BEGIN INIT INFO
# Provides: corosync
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: corosync cluster framework
### END INIT INFO
# Author: Fabio M. Di Nitto <fabbione@ubuntu.com>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="corosync daemon"
NAME=corosync
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
PIDFILE=/var/run/corosync.pid
RARUNDIR=/var/run/resource-agents
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/corosync ] && . /etc/default/corosync
# Make sure the Resource Agents run dir exists. Otherwise create it.
[ -d "$RARUNDIR" ] || mkdir -p $RARUNDIR
if [ "$START" != "yes" ]; then
exit 0
fi
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
^^^^^^^^^^
省略
^^^^^^^^^^
あ〜なるほど、ここで止まっているよう。
if [ "$START" != "yes" ]; then
exit 0
fi
STARTはどこで定義されているのか調べると/etc/default/corosyncで定義されているよう
# start corosync at boot [yes|no]
START=no
コメントにstart corosync at bootとか書いてあるけど、これがnoだと、ご覧の通り
普通に/etc/init.d/corosyncからもserviceからも起動できない。
これって、あえてこんな風にしてるのかな?
/etc/default/corosyncを下記のように編集
# start corosync at boot [yes|no]
START=yes
corosyncを起動
$ sudo service corosync start
* Starting corosync daemon corosync [ OK ]
おお動いた動いた、続いてpacemakerも起動
$ sudo service pacemaker start
Starting Pacemaker Cluster Manager: [ OK ]
2. crmでクラスタが組めていることを確認
しようとしたが、動かない。。。
$ crm status
Could not establish cib_ro connection: Connection refused (111)
ERROR: crm_mon exited with code 107 and said: Connection to cluster failed: Transport endpoint is not connected
それもそのはず、/etc/corosync/corosync.confでmulticastで死活監視するように設定していたが、まだ、mutlicastアドレスをnicに設定していないので設定しようとした・・・・
$ ip maddr add 226.94.1.1 dev eth0
$ ip maddr show eth0
2: eth0
link 01:00:5e:00:00:01
link 33:33:00:00:00:01
link 33:33:ff:91:14:ca
inet 224.0.0.1
inet6 ff02::1:ff91:14ca
inet6 ff02::1
inet6 ff01::1
思った通り、Multicast IPアドレスが振れない。。。
断念して、/etc/corosync/corosync.confを変更して、unicastで死活監視することに
下記のように変更
$diff -u /etc/corosync/corosync.conf.old /etc/corosync/corosync.conf
--- /etc/corosync/corosync.conf.old 2015-04-20 13:00:58.684539742 +0000
+++ /etc/corosync/corosync.conf 2015-04-20 13:37:59.006067011 +0000
@@ -43,10 +43,15 @@
rrp_mode: none
interface {
+ member {
+ memberaddr: 192.168.5.10
+ }
+ member {
+ memberaddr: 192.168.5.11
+ }
# The following values need to be set based on your environment
ringnumber: 0
bindnetaddr: 192.168.5.0
- mcastaddr: 226.94.1.1
mcastport: 5405
}
transport: udp
んで、いろいろ再起動
$ sudo service corosync start
$ sudo service pacemaker start
確認すると、
$ crm status
Last updated: Mon Apr 20 13:41:49 2015
Last change: Mon Apr 20 13:03:35 2015 via crmd on pace-test-one
Stack: corosync
Current DC: pace-test-one (1084753162) - partition with quorum
Version: 1.1.10-42f2063
2 Nodes configured
0 Resources configured
Online: [ pace-test-one pace-test-two ]
おお、クラスタに2つ登録されている!!ここにはhostnameが出るみたい