美文网首页
centos7安装keepalived

centos7安装keepalived

作者: 孔厌柔 | 来源:发表于2018-10-12 15:54 被阅读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
    

    说明

    • keepalived的日志输出默认是:/var/log/message 文件,我在网上找了下修改输出位置,都是修改/etc/sysconfig/keepalived 文件,配置rsyslog服务,然而并没有什么卵用,你们可以测试一下,若有找到其他方式的请评论
    • centos7对keepalived操作的基本命令
    #重新加载
    systemctl daemon-reload  
    
    #设置开机自动启动
    systemctl enable keepalived
    
    #取消开机自动启动
    systemctl disable keepalived
    
    #启动
    systemctl start keepalived
    
    #停止
    systemctl stop keepalived
    
    #重启
    systemctl restart keepalived
    

    相关文章

      网友评论

          本文标题:centos7安装keepalived

          本文链接:https://www.haomeiwen.com/subject/ybkgaftx.html