在线安装
yum -y install keepalived
设置开机自启
chkconfig keepalived on;
启动
systemctl start keepalived;
离线安装
1)下载安装包上传到服务器。访问网址:Keepalived for Linux 并下载 Keepalived 的安装包。
2)解压安装。
cd /wendy;
tar -zxvf keepalived-2.0.18.tar.gz; # 解压
3)编译
cd keepalived-2.0.18 # 路径根据实际情况修改
./configure --prefix=/usr/local/keepalived --sysconf=/etc
- prefix:keepalived 安装的位置
- sysconf:keepalived核心配置文件位置,固定位置,改成其他位置则keepalived启动不了
如果出现如下警告信息 则需要安装libnl来支持IPV6,然后重新执行configure命令
*** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.
yum -y install libnl libnl-devel
4)安装
make -j 3 && make install # 安装
5) 将 Keepalived 安装成 Linux 系统服务
# 进入keppalived解压后目录
cd keepalived-2.0.18;
# 复制启动文件到指定迷路
cp keepalived/etc/init.d/keepalived /etc/init.d/
cp keepalived/etc/sysconfig/keepalived /etc/sysconfig/
# 刷新系统服务
systemctl daemon-reload;
# 启动keepalived
systemctl start keepalived;
# 设置为开机启动
systemctl enable keepalived;
# 查看keepalived状态
systemctl status keepalived;
# 关闭keepalived
systemctl stop keepalived;
配置文件和日志
日志文件位置:/var/log/messages
配置文件位置:/etc/keepalived/keepalived.conf
运维
启动
systemctl start keepalived;
关闭
systemctl stop keepalived;
重启
systemctl restart keepalived;