keepalived配置日志文件

keepalived默认日志接收文件为/var/log/messages不方便查看,可以指定文件接收日志。

进入keepalived的安装目录,本人安装目录为: /usr/local/keepalived

keepalived配置日志文件

进入 安装目录下的 /usr/local/keepalived/etc/sysconfig,修改keepalived文件,添加  KEEPALIVED_OPTIONS="-D -d -S 0",然后保存。

-D导出备份配置数据

-d详细日志

 -S设置本地syslog设备,编号为0-7 这里为0

[root@localhost sysconfig]# cat keepalived 
# Options for keepalived. See `keepalived --help' output and keepalived(8) and
# keepalived.conf(5) man pages for a list of all options. Here are the most
# common ones :
#
# --vrrp               -P    Only run with VRRP subsystem.
# --check              -C    Only run with Health-checker subsystem.
# --dont-release-vrrp  -V    Dont remove VRRP VIPs & VROUTEs on daemon stop.
# --dont-release-ipvs  -I    Dont remove IPVS topology on daemon stop.
# --dump-conf          -d    Dump the configuration data.
# --log-detail         -D    Detailed log messages.
# --log-facility       -S    0-7 Set local syslog facility (default=LOG_DAEMON)
#

#KEEPALIVED_OPTIONS="-D"

KEEPALIVED_OPTIONS="-D -d -S 0"

修改 rsyslog.conf 文件:添加  local0.*               /var/log/keepalived.log,keepalived的日志就会输出到 /var/log/keepalived.log 文件。

[root@localhost sysconfig]# vi /etc/rsyslog.conf 

#取了其中一段代码,添加  local0.*   /var/log/keepalived.log  这行代码

# Everybody gets emergency messages
*.emerg                                                 :omusrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit                                          /var/log/spooler

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log

local0.*                                                /var/log/keepalived.log

保存 退出, 然后重启 rsyslog 和 keepalived 服务:

[root@localhost sysconfig]# systemctl restart rsyslog
[root@localhost sysconfig]# service keepalived restart

查看日志目录:

keepalived配置日志文件

 同时,原本日志输入的  /var/log/messages 目录也会存在keepalived的日志。

上一篇:Photoshop将写真人物图片增加温暖橙紫色效果


下一篇:CDR绘制可爱的亲嘴小猫卡通画