一、编译安装keepalived-1.2.8
注意最新的不一定是最好的,所以选择1.2.8
tar xf keepalived-1.2.8.tar.gz
cd keepalived-1.2.8
mkdir -p /data/soft/keepalived
./configure --prefix=/data/soft/keepalived
注意:编译安装之前,可能需要先安装gcc和一些额外的包,请自行解决
make && make install
编译报错1
../include/vrrp_ipaddress.h:32:27: error: linux/if_addr.h: No such file or directory
In file included from ../include/vrrp.h:31,
from ../include/smtp.h:34,
from smtp.c:27:
../include/vrrp_ipaddress.h:41: error: field ‘ifa’ has incomplete type
make: * [smtp.o] Error 1
make: Leaving directory `/root/keepalived-1.2.7/keepalived/core'
make: [all] Error 1
make: Leaving directory `/root/keepalived-1.2.7/keepalived'
make: ** [all] Error 2
原因及解决办法:
这是kernel-headers软件版本过低造成的
yum -y install kernel-headers
问题解决
编译报错2
make: * [vrrp_ipaddress.o] Error 1
make: Leaving directory `/data/soft/keepalived-1.2.9/keepalived/vrrp'
make: [all] Error 1
make: Leaving directory `/data/soft/keepalived-1.2.9/keepalived'
make: ** [all] Error 2
解决办法:
将编译keepalived-1.2.9.tar.gz改成编译keepalived-1.2.8.tar.gz即可
转移文件到正确的位置
mkdir /etc/keepalived
pwd
/data/soft/keepalived
cp etc/keepalived/keepalived.conf /etc/keepalived/
cp etc/rc.d/init.d/keepalived /etc/init.d/
cp etc/sysconfig/keepalived /etc/sysconfig/
cp sbin/keepalived /usr/sbin/
chkconfig --add keepalived
service keepalived start
Starting keepalived: [ OK ]
chkconfig --add keepalived
chkconfig keepalived on
Keepalived 的详细介绍:请点这里
Keepalived 的下载地址:请点这里
推荐阅读:
CentOS 6.3下Haproxy+Keepalived+Apache配置笔记
Haproxy + KeepAlived 实现WEB群集 on CentOS 6