centos7安装keepalived

2018-10-12  本文已影响0人  孔厌柔
1.下载keepalived

进入keepalived官网下载界面,选择你所需要的版本下载即可

点击Version 2.0.6下载
或者通过 wget 命令进行下载

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

此处我将文件放在:/home/gnss 下,下面的举例及命令需要注意

2.解压文件

通过 tar 命令进行解压(第1步)的下载文件

cd /etc/gnss/
tar -zxvf keepalived-2.0.6.tar.gz
3.安装

进入解压文件下,执行 configure 命令,生成Makefile,为下一步的编译做准备

cd /home/gnss/keepalived-2.0.6

# --prefix:指定安装路径
./configure --prefix=/home/etc/keepalived

执行一下命令安装

make && make install

注意
若出现下面错误信息说明你未安装GCC,安装GCC即可

#错误信息
configure: error: no acceptable C compiler found in $PATH
See 'config.log' for more details.

#安装GCC
yum install -y gcc gcc-c++

#若出现错误信息说你未安装OpenSSL,执行下面命令安装即可
yum install -y openssl openssl-devel
4.将keepalived注册为系统服务

进入(第2步)的解压文件内,执行一下命令

cd /home/gnss/keepalived-2.0.6

#复制文件
cp keepalived/etc/init.d/keepalived /etc/init.d
cp keepalived/etc/sysconfig/keepalived /etc/sysconfig/

进入(第3步)的安装目录

cd /home/gnss/keepalived

mkdir /etc/keepalived

#复制文件
cp etc/keepalived/keepalived.conf /etc/keepalived/
5.验证是否安装成功

运行keepalived查看日志文件

systemctl start keepalived

#查看日志文件
tail /var/log/message

说明

#重新加载
systemctl daemon-reload  

#设置开机自动启动
systemctl enable keepalived

#取消开机自动启动
systemctl disable keepalived

#启动
systemctl start keepalived

#停止
systemctl stop keepalived

#重启
systemctl restart keepalived
上一篇下一篇

猜你喜欢

热点阅读