1、下载源码包
https://www.keepalived.org/software/keepalived-2.0.19.tar.gz
2、解压源码包
tar -zxvf keepalived-2.0.19.tar.gz
3、安装依赖的库
yum -y install libnl libnl-devel openssl-devel
4、编译安装keepalived
cd keepalived-2.0.19
./configure --prefix=/usr/local/keepalived
make && make install
5、复制配置文件,和启动文件
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived/sbin/keepalived /usr/bin/
在解压的源码目录keepalived-2.0.19中
cp keepalived/etc/init.d/keepalived /etc/init.d/
查看keepalived版本:
keepalived -v
Keepalived v2.0.19 (10/19,2019)
Copyright(C) 2001-2019 Alexandre Cassen, acassen@gmail.com
Built with kernel headers for Linux 2.6.32
Running on Linux 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013
configure options: --prefix=/usr/local/keepalived
Config options: LVS VRRP VRRP_AUTH OLD_CHKSUM_COMPAT FIB_ROUTING
System options: PIPE2 SIGNALFD INOTIFY_INIT1 VSYSLOG EPOLL_CREATE1 IPV6_ADVANCED_API LIBNL1 IP_MULTICAST_ALL NET_LINUX_IF_H_COLLISION LIBIPTC_LINUX_NET_IF_H_COLLISION LIBIPVS_NETLINK VRRP_VMAC CN_PROC SOCK_NONBLOCK SOCK_CLOEXEC GLOB_BRACE SO_MARK SCHED_RT SCHED_RESET_ON_FORK
6、增加开机启动
chkconfig --add keepalived
chkconfig keepalived on
7、修改keepalived日志输出路径
修改rsyslog配置,增加keepalived日志路径:
vi /etc/rsyslog.conf
添加如下两行:
Save keepalived log
local0.* /var/log/keepalived.log
重启rsyslog:
/etc/init.d/rsyslog restart
修改keepalived启动参数:
vi /etc/sysconfig/keepalived
将
KEEPALIVED_OPTIONS="-D"
改为
KEEPALIVED_OPTIONS="-D -d -S 0"
8、启动/停止/重启/查看 keepalived
service keepalived start
service keepalived stop
service keepalived restart
service keepalived status