keepalived源码编译安装

1.下载安装包

    keepalived  yum方式安装,由于yum中自带的版本较旧,所以我们可能需要安装一个新版本的keepalived,所以这时候我们就要采用源码编译安装饭方式。

keepalived官网下载地址

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

2.解压编译安装

 tar -zxvf /opt/software/keepalived-2.0.10.tar.gz 

 cd keepalived-2.0.10/
 
./configure --prefix=/usr/local/keepalived

编译过程中出现的错误:

*** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.

解决方案:

yum install -y libnl libnl-devel

继续编译,若出现下面错误

configure: error: libnfnetlink headers missing

解决方案:

 yum install -y libnfnetlink-devel

继续编译,然后安装

./configure --prefix=/usr/local/keepalived
make && make install

制作快捷启动,在源文件的目录/opt/software/keepalived-2.0.10/keepalived/etc/init.d下有两个个快捷启动文件和生成/usr/local/keepalived目录下一个配置文件需要复制,具体执行如下命令:

 cp /opt/software/keepalived-2.0.10/keepalived/etc/init.d/keepalived /etc/init.d/

 # 需要提前在/etc下创建keepalived目录
 mkdir  -p /etc/keepalived

 cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
 cp /opt/software/keepalived-2.0.10/keepalived/etc/sysconfig/keepalived /etc/sysconfig/keepalived

这样就可以执行service keepalived [start | stop | reload | restart ]命令。

启动报“Starting keepalived: /bin/bash: keepalived: command not found”错误:

解决方案:

cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

 

你可能感兴趣的:(linux)