keepalived默认的日志文件保存在/var/log/messages,直接在控制台输入/var/log/messages 报没有权限,tail /var/log/messages 则没有打印keepalived相关日志,所以重定向keepalived的日志路径。
1.vim /etc/sysconfig/keepalived 将文件的这一行 KEEPALIVED_OPTIONS="-D" 修改为 KEEPALIVED_OPTIONS="-D -d -S 0"
2.vim /etc/rsyslog.conf 在文件的最后添加一行
local0.* /var/log/keepalived.log
3.重启rsyslog服务 systemctl restart rsyslog
4.重启keepalived服务,日志会打印到/var/log/keepalived.log