解决Keepalived启动“Fail to start LVS and VRRP Avaliability Monitor” 问题

前言

    小编最近在做nginx+keepalived 达到高可用的实验,配置好keepalived后,启动失败,来记录下解决过程。

正文

错误日志

    keepalived 服务启动,查看服务状态,错误信息如下

# 启动keeperalived 服务
sudo service keepalived start
# 查看keepalived 服务状态
systemctl status keepalived.service

在这里插入图片描述
在这里插入图片描述

问题解决:

    1、根据提示 输入“ systemctl status keepalived.service” 和“journalctl -xe”查看详情
在这里插入图片描述
    2、输入“journalctl -xe”
在这里插入图片描述
    可以看到详细信息“Jan 13 14:00:23 VM_110_5_centos Keepalived[22474]: Unable to find configuration file /etc/keepalived/keepalived.conf (glob returned 3)” ,
    也就是说找不到配置文件了,因为这是keepalive.conf的默认位置,而实际的配置文件位置已经是“/usr/local/etc/keepalived/keepalived.conf”,所以,这里的位置要修改下。
    说明

  • Keepalived默认的配置文件路径在/etc/keepalived/keepalived.conf
  • Keepalived默认的日志文件保存在/var/log/messages

    3、找到修改文件路径的地方
    接下来就是去看 哪里写着 “/etc/keepalived/keepalived.conf”这个东西了,
在这里插入图片描述
    去 keepalived.service 中可以看到一个路径“/usr/local/etc/sysconfig/keepalived”,顺藤摸瓜,到这个目录下去看看

vim /usr/local/etc/sysconfig/keepalived 

在这里插入图片描述

    看到 其中写着“ KEEPALIVED_OPTIONS=-D”
    这个就是修改文件路径的关键。
    经过查看资料可以找到更为详细的解释:

/usr/local/keepalived/sbin/keepalived --vrrp -P [Only run with VRRP subsystem.] 
/usr/local/keepalived/sbin/keepalived --check -C [Only run with Health-checker subsystem.] 
/usr/local/keepalived/sbin/keepalived --dont-release-vrrp -V [Dont remove VRRP VIPs & VROUTEs on daemon stop. ]
/usr/local/keepalived/sbin/keepalived --dont-release-ipvs -I [Dont remove IPVS topology on daemon stop. ]
/usr/local/keepalived/sbin/keepalived --dont-fork -n [Dont fork the daemon process. ]
/usr/local/keepalived/sbin/keepalived --use-file -f [Use the specified configuration file. Default is /etc/keepalived/keepalived.conf. ]
/usr/local/keepalived/sbin/keepalived --dump-conf -d [Dump the configuration data. ]
/usr/local/keepalived/sbin/keepalived --log-console -l [Log message to local console. ]
/usr/local/keepalived/sbin/keepalived --log-detail -D [Detailed log messages. ]
/usr/local/keepalived/sbin/keepalived --log-facility -S 0-7 [Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON) ]
/usr/local/keepalived/sbin/keepalived --help -h [Display this short inlined help screen. ]
/usr/local/keepalived/sbin/keepalived --version -v [Display the version number ]
/usr/local/keepalived/sbin/keepalived --pid -p [pidfile ]
/usr/local/keepalived/sbin/keepalived --checkers_pid -c [checkers pidfile ]
/usr/local/keepalived/sbin/keepalived --vrrp_pid -r [vrrp pidfile]

    “-D” 就是输出日志的选项,而-f 就是修改默认配置文件路径的。
    4、修改配置文件的默认路径

# 注意到要修改日志文件的默认路径就需要“-S“
-f /usr/local/etc/keepalived/keepalived.conf -D -S 0

在这里插入图片描述

补充: keepalived.service 中有一个$KEEPALIVED_OPTIONS ,跟这里的KEEPALIVED_OPTIONS 就对上了,所以在输出日志中可以看到“/usr/local/keepalived/keepalived-2.0.10/bin/keepalived -D”的输出
    5、再次尝试启动keepalived服务,发现启动成功
    当出现红框所示内容时,表示启动成功!
    另外:细心的读者应该会发现我红框圈出的部分将keepalived.service 中ExecStart 指向keepalived的启动地址也换了,这个改动可以忽略,维持原来的默认值就好!
    另外 :“systemctl daemon-reload”这一步操作经测试也可以忽略,跳过即可!
在这里插入图片描述

配置systemctl 和 keepalived 服务相关命令

# 重新加载
systemctl daemon-reload  
# 设置开机自动启动
systemctl enable keepalived.service  
# 取消开机自动启动
systemctl disable keepalived.service 
# 启动
systemctl start keepalived.service 
# 停止
systemctl stop keepalived.service

参考连接

https://blog.csdn.net/zhaihaifei/article/details/53841466
https://blog.csdn.net/u013256816/article/details/49356689

疑问

     Mac 系统上可以安装、编译keepalived 源码吗? 我用源码安装的方式还没有成功。。。

总结

    以上就是和keeplived 逐渐熟悉的过程,感谢阅读!

  • 11
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奔跑的大白啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值