1、把keepalived-1.2.2.tar.gz、openssl-1.0.1c.tar.gz、popt-1.16.tar.gz上传至home目录;
2、安装OpenSSL
# cd /home
# tar -zxf openssl-1.0.1c.tar.gz
# cd openssl-1.0.1c/
# ./config --prefix=/usr/local --openssldir=/usr/local/ssl
# make && make install
# ./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
# make clean
# make && make install
2、安装popt
# cd /home
# tar zxvf popt-1.16.tar.gz
# cd popt-1.16
# ./configure
# make
# make install
3、安装keepalived
# cd /home
# tar -xzvf keepalived-1.2.2.tar.gz
# cd keepalived-1.2.2
# ./configure --prefix=/usr/local/keepalived
# make
# make install clean
4、删除安装文件
# cd /home
# rm -Rf openssl-1.0.1c
# rm -Rf popt-1.16
# rm -Rf keepalived-1.2.2
5、修改keepalived配置文件
把文件keepalived.conf上传至/usr/local/keepalived/etc/keepalived覆盖原有文件
主机修改virtual_ipaddress为虚拟IP地址
从机把priority由100修改为99,并且修改virtual_ipaddress为虚拟IP地址
6、如果使用了iptables,则需要在iptables中加入一条配置
-A INPUT -p vrrp -j ACCEPT
iptables默认配置文件的位置在哪里
/etc/sysconfig/iptables
修改完后,重启iptables:service iptables restart
6、启动keepalived和开机启动
# cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
# mkdir /etc/keepalived
# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
# cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
# chkconfig --level 2345 keepalived on
# service keepalived start