RedHat Enterprise LinuxでWebサーバロードバランス(2)

Keepalivedもやってみよー!! ってことで

1−1.OpenSSL0.9.8eのインストール

# ./configure ; make
# sudo make install

1−2.keepalivedのインストール

# CPPFLAGS='-I /usr/local/ssl/include' ./configure \
--with-kernel-dir=/usr/src/linux-2.4.21-32.EL \
--disable-lvs-syncd
# make
# sudo make install

1−3.keepalived.confの作成

# vi /usr/local/etc/keepalived/keepalived.conf
virtual_server 192.168.1.100 80 {
delay_loop 3
lvs_sched wrr
lvs_method DR
protocol TCP
real_server 192.168.1.7 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_port 80
connect_timeout 1
}
}
real_server 192.168.1.8 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_port 80
connect_timeout 1
}
}
}

virtual_server 192.168.1.101 80 {
delay_loop 3
lvs_sched wrr
lvs_method DR
protocol TCP
real_server 192.168.1.7 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_port 80
connect_timeout 1
}
}
real_server 192.168.1.8 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_port 80
connect_timeout 1
}
}
}

1−4.ipvsadmのテーブルクリア

# ipvsadm -C

1−5.keepalivedの起動

# keepalived -e /usr/local/etc/keepalived/keepalived.conf

1−6.確認

# ipvsadm
IP Virtual Server version 1.0.8 (size=65536)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.100:http wrr
-> 192.168.1.8:http Route 0 0 0
-> 192.168.1.7:http Route 1 0 0
TCP 192.168.1.101:http wrr
-> 192.168.1.8:http Route 0 0 0
-> 192.168.1.7:http Route 1 0 0

取りあえず、ちゃんと動いてるっぽい。。
Weight=0のサーバは本当に電源Offになってる奴。