CentOSにKeepalivedをインストール(CentOS4.6)

パッケージにOSを合わせるのもアリかと思い、CentOS4.6にしてみた。
あっさりインストール完了。動作確認もOKぽいです。

手順

yum install -y ipvsadm
wget http://dag.wieers.com/rpm/packages/keepalived/keepalived-1.1.13-5.el4.rf.i386.rpm
rpm -ivh keepalived-1.1.13-5.el4.rf.i386.rpm

CentOSの標準ディレクトリ構成っぽい。

# find / -name keepalived*
/etc/keepalived
/etc/keepalived/keepalived.conf ←keepalived設定ファイル
/etc/rc.d/init.d/keepalived ←rcスクリプト
/etc/sysconfig/keepalived ←オプション設定ファイル
/usr/sbin/keepalived

■ ロードバランサの設定(lb1)

とりあえず動かしたいだけの設定。

vi /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {
   notification_email {
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.0.25
    }
}

virtual_server 192.168.0.25 80 {
    delay_loop 3
    lb_algo rr
    lb_kind DR
    nat_mask 255.255.255.0
    persistence_timeout 50
    protocol TCP

    real_server 192.168.0.21 80 {
        weight 1
        HTTP_GET {
            url {
              path /index.html
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }

    real_server 192.168.0.22 80 {
        weight 1
        HTTP_GET {
            url {
              path /index.html
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

■ Webサーバ側の設定 (web1,web2)
編集
/etc/sysconfig/network-scripts/ifcfg-lo:0

DEVICE=lo:0
IPADDR=192.168.0.25
NETMASK=255.255.255.255
ONBOOT=yes

起動

ifup ifcfg-lo:0