2012年2月12日日曜日

Pacemaker で仮想 IP の切り替え

Pacemaker でまず仮想 IP の切り替えを行う時に嵌まったこと。

OS は CentOS 5.7 でやってみる。インストールは、LINUX-HA JAPAN より、ローカルリポジトリ + yum を使用。

クラスタ制御部には、Corosync を使用することにする。
/etc/corosync/corosync.conf を作成。
# Please read the corosync.conf.5 manual page
compatibility: whitetank

aisexec {
        user: root
        group: root
}

service {
    name: pacemaker
    ver: 0
    use_mgmtd: yes
}

totem {
    version: 2
    secauth: off
    threads: 0
    rrp_mode: active
    clear_node_high_bit: yes
    token: 4000
    consensus: 10000
    rrp_problem_count_timeout: 3000
    interface {
        ringnumber: 0
        bindnetaddr: 192.168.234.0
        mcastaddr: 226.94.1.1
        mcastport: 5405
        ttl: 1
    }
}

logging {
    fileline: on
    to_stderr: no
    to_logfile: yes
    to_syslog: no
    logfile: /var/log/cluster/corosync.log
    debug: off
    timestamp: on
}
bindnetaddr にはインターフェースの IP でなくネットワークアドレスを指定する。
ログをファイルに出力するように指定。

/etc/init.d/corosync start で起動して、crm_mon を実行して確認する。
Attempting connection to the cluster.........................
帰ってこない・・・

一般ユーザで実行したからっぽい。グループに、haclient を追加したら帰ってきた。
============
Last updated: Sun Feb 12 00:54:09 2012
Stack: openais
Current DC: localhost.localdomain - partition WITHOUT quorum
Version: 1.0.11-1554a83db0d3c3e546cfd3aaff6af1184f79ee87
1 Nodes configured, 2 expected votes
0 Resources configured.
============

Online: [ localhost.localdomain ]

次に、 crm configure help でコマンドを確認しようとするも、
cibadmin not available, check your installation
となる、sudo でやってもダメだった。仕方ないので root になって行う。
# crm configure property no-quorum-policy="ignore" stonith-enabled="false"
# crm configure rsc_defaults resource-stickiness="INFINITY" migration-threshold="1"
# crm configure primitive vip ocf:heartbeat:IPaddr2 \
params ip="192.168.234.51" nic="eth0" cidr_netmask="24" op monitor interval="10s"
eth0 に 192.168.234.51 の仮想 IP を作成する設定。

ifconfig で確認するも設定したアドレスが見当たらない。
eth0 にはそもそも実インターフェースの IP が割当たっているからだ。
ip addr show eth0 で確認できる。
inet 192.168.234.51/24 brd 192.168.234.255 scope global secondary eth0

最初、CentOS 6 を使用して普通に yum でインストールして開始したわけだが、こっちのほうが嵌まった。
Pacemaker が 1.1 になっており、クラスタ部に heartbeat が使えなかったり、corosync.conf の service の ver を 1 にしないとだったり、vip 指定時に nic に eth0:1 などを指定すると警告が出たりとかなり面倒だった。

結局、CentOS5.7 を使うことになり、落としたわけだが・・・