Installing keepalived from source (For centos 5, rpmbuilder only provide centos 6 rpms)

1: Get the source and extract

wget?http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

tar xvfzp keepalived-1.2.7.tar.gz

2: Compile and install

cd keepalived-1.2.7
./configure
make
make install

3: init script

cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/keepalived

vi /etc/init.d/keepalived

After line 19, add

PATH=$PATH:/usr/local/sbin

4: create directories and config file

mkdir -p /etc/keepalived
touch /etc/sysconfig/keepalived

vi /etc/keepalived/keepalived.conf

On master:

vrrp_script chk_ping {
script “ping -c 1 192.168.100.1”
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 100
priority 101
virtual_ipaddress {
192.168.100.52/24 dev eth0
}
track_script {
chk_ping
}

}

On slave

vrrp_script chk_ping {
script “ping -c 1 192.168.100.1”
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 100
priority 100
virtual_ipaddress {
192.168.100.52/24 dev eth0
}
track_script {
chk_ping
}

}

5: Start service

chkconfig keepalived on

service keepalived start

?

Leave a Reply