Java教程

Keepalived安装与注册成服务

本文主要是介绍Keepalived安装与注册成服务,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

安装Keepalived

  1. 在官网下载Keepalived,https://www.keepalived.org/download.html

  2. 将安装包上传到服务器的/mydata/keepalived目录

  3. 解压安装包

    tar -zxvf keepalived-2.0.18.tar.gz

  4. 安装 libnl/libnl-3依赖

    yum -y install libnl libnl-devel  

  5. 解压后进入到解压路径,会看到configure,使用configure命令配置安装目录与核心配置文件所在位置

    ./configure --prefix=/usr/local/keepalived --sysconf=/etc

    prefix:keepalived安装的位置

    sysconf:keepalived核心配置文件所在位置,必须指定为/etc,改成其他位置则keepalived启动不了

  6. 安装keepalived

    make && make install


将Keepalived注册为服务

当前情况下,我们需要进入到keepalived运行目录下才能启动keepalived,需要使用kill -9 停止keepalived,这样很不友好,下面介绍如何将Keepalived注册为服务。

进入Keepalived解压目录(不是安装目录)

https://img1.sycdn.imooc.com/63fa05fc0001378a04240186.jpg

拷贝,并覆盖目标目录下的文件

cp init.d/keepalived /etc/init.d/
cp sysconfig/keepalived /etc/sysconfig/

https://img4.sycdn.imooc.com/63fa065200015a8c04290074.jpg

重新加载服务

systemctl daemon-reload

启动服务

systemctl start keepalived.service

停止服务

systemctl stop keepalived.service

重启服务

systemctl reststart keepalived.service


这篇关于Keepalived安装与注册成服务的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!