在Redhat系统下,可以使用下面的方法将keepalived的日志输出到/var/log/下的某个文件里:
1.将keepalived日志输出到local0:
vim /etc/sysconfig/keepalived
KEEPALIVED_OPTIONS="-D -d -S 0"
2.在/etc/rsyslog.conf里添加:
local0.* /var/log/keepalived.log
3.重新启动keepalived和rsyslog服务:
service rsyslog restart
service keepalived restart
如果按照上面的步骤配置完之后,还不能在/var/log/keepalived.log里看到log,可以查看通过“netstat -anp|grep syslog”查看syslog是否配置在本地:
[root@vm1 ~]# netstat -anp|grep syslog
unix 6 [ ] DGRAM 70809915 4217/rsyslogd /dev/log