【工作】Keepalived 重定向日志输出位置

热门标签

, , , ,

一一网络

做互联网综合资源分享云平台!。

立即加入一一网络

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

有时候由于为了排查问题,我们需要查看keepalived的输出日志,而默认keepalived的日志输出到/var/log/messages里面,和系统日志一起,查看起来非常不方便,所以需要将日志路径修改到合适的位置。

Keepalived 默认的配置文件路径在/etc/keepalived/keepalived.conf
Keepalived 默认的日志文件保存在/var/log/messages

1.修改 keepalived 服务配置

# cat /etc/sysconfig/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"

“-D” 是输出日志的选项,
“-f” 是修改默认配置文件路径的选项,后面跟配置文件路径即可,(可选)
“-S” 是修改日志文件的默认输出路径
举例:KEEPALIVED_OPTIONS="-f [配置文件路径] -D -S 0"

# vim /etc/sysconfig/keepalived

KEEPALIVED_OPTIONS="-D -S 0"     #-S后面的是数字0

这里的“-S 0”表示local0.* ,还需要配合rsyslog服务才能达到效果。

2. 修改 rsyslog 服务配置

# vim /etc/rsyslog.conf

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*  /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.*  /var/log/secure
# Log all the mail messages in one place.
mail.*  -/var/log/maillog
# Log cron stuff
cron.*  /var/log/cron
# Everybody gets emergency messages
*.emerg *
# 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  #添加此行,路径可自行指定

3.重启服务

# /etc/init.d/keepalived restart
# /etc/init.d/rsyslog restart

检查 /var/log/keepalived.log 文件是否存在,如果有就说明以上操作成功。

4.Keepalived相关管理的知识拓展

/usr/local/keepalived/sbin/keepalived --vrrp -P [Only run with VRRP subsystem.]
/usr/local/keepalived/sbin/keepalived --check -C [Only run with Health-checker subsystem.]
/usr/local/keepalived/sbin/keepalived --dont-release-vrrp -V [Dont remove VRRP VIPs & VROUTEs on daemon stop. ]
/usr/local/keepalived/sbin/keepalived --dont-release-ipvs -I [Dont remove IPVS topology on daemon stop. ]
/usr/local/keepalived/sbin/keepalived --dont-fork -n [Dont fork the daemon process. ]
/usr/local/keepalived/sbin/keepalived --use-file -f [Use the specified configuration file. Default is /etc/keepalived/keepalived.conf. ]
/usr/local/keepalived/sbin/keepalived --dump-conf -d [Dump the configuration data. ]
/usr/local/keepalived/sbin/keepalived --log-console -l [Log message to local console. ]
/usr/local/keepalived/sbin/keepalived --log-detail -D [Detailed log messages. ]
/usr/local/keepalived/sbin/keepalived --log-facility -S 0-7 [Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON) ]
/usr/local/keepalived/sbin/keepalived --help -h [Display this short inlined help screen. ]
/usr/local/keepalived/sbin/keepalived --version -v [Display the version number ]
/usr/local/keepalived/sbin/keepalived --pid -p [pidfile ]
/usr/local/keepalived/sbin/keepalived --checkers_pid -c [checkers pidfile ]
/usr/local/keepalived/sbin/keepalived --vrrp_pid -r [vrrp pidfile]

未经允许不得转载:作者:admin, 转载或复制请以 超链接形式 并注明出处 一一网络
原文地址:《【工作】Keepalived 重定向日志输出位置》 发布于2019-06-17

分享到:
赞(1)

评论 抢沙发

评论前必须登录!

  注册



【工作】Keepalived 重定向日志输出位置

长按图片转发给朋友

一一网络
一一网络是一个做互联网的综合资源分享平台,邹洪博客,Emblog,Blog,免费,技术教程,破解源码,资源分享,永久免费,资源分享平台,免费破解,资源分享云平台,永久免费,技术教程分享网站,免费技术学习平台,一一网络是一个专注于网络资源开发和共享加建站教程、源码下载、WordPress主题、网站开发交流、程序软件下载、建站资源、多媒体交流、电影资源、Android软件分享为一体的多互动交流平台。

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

Q Q 登 录
微 博 登 录