【keepalived】自定义keepalived日志文件

keepalived 运行用户是root

keepalived默认日志存放在系统日志:/var/log/messages

# cat /var/log/messages | grep keepalived


自定义keepalived日志文件为:  /var/log/keepalived.log

# vim /etc/sysconfig/keepalived

将KEEPALIVED_OPTIONS="-D" 修改为:KEEPALIVED_OPTIONS="-D -d -S 0"



在/etc/rsyslog.conf 末尾添加  local0.*  /var/log/keepalived.log

 # vim /etc/rsyslog.conf



重启相关服务

# systemctl restart rsyslog

# systemctl restart keepalived

查看生成日志

# tail /var/log/keepalived.log



脚本实现

sed -i   '/KEEPALIVED_OPTIONS=/d' /etc/sysconfig/keepalived

echo  'KEEPALIVED_OPTIONS="-D -d -S 0"' >> /etc/sysconfig/keepalived

echo  "local0.*    /var/log/keepalived.log"  >> /etc/rsyslog.conf

systemctl  restart rsyslog

systemctl  restart keepalived

你可能感兴趣的:(【keepalived】自定义keepalived日志文件)