Keepalived默认所有的日志都是写入到/var/log/message下的,由于message的日志太多了,而Keepalived的日志又很难分离出来,所以本文提供了一个调整Keepalived日志输出路径的方法。
具体操作步骤如下:
1. 修改 /etc/sysconfig/keepalived
把KEEPALIVED_OPTIONS="-D" 修改为KEEPALIVED_OPTIONS="-D -d -S 0"
#其中-S指定syslog的facility
2. 重启 keepalived
systemctl restart keepalived
3. 设置syslog,修改/etc/syslog.conf,添加内容如下
# keepalived -S 0
local0.* /var/log/keepalived.log
注意:local0是l是字符L的小写
4. 重启日志服务
systemctl restart rsyslog
5. 检查 /var/log/keepalived.log 文件是否存在