【工作】Keepalived 重定向日志输出位置-一一网络 【工作】Keepalived 重定向日志输出位置 – 一一网络

【工作】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]

免责声明:务必仔细阅读

  • 本站为个人博客,博客所转载的一切破解、path、补丁、注册机和注册信息及软件等资源文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。

  • 本站为非盈利性站点,打赏作为用户喜欢本站捐赠打赏功能,本站不贩卖软件等资源,所有内容不作为商业行为。

  • 本博客的文章中涉及的任何解锁和解密分析脚本,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断.

  • 本博客的任何内容,未经许可禁止任何公众号、自媒体进行任何形式的转载、发布。

  • 博客对任何脚本资源教程问题概不负责,包括但不限于由任何脚本资源教程错误导致的任何损失或损害.

  • 间接使用相关资源或者参照文章的任何用户,包括但不限于建立VPS或在某些行为违反国家/地区法律或相关法规的情况下进行传播, 博客对于由此引起的任何隐私泄漏或其他后果概不负责.

  • 请勿将博客的任何内容用于商业或非法目的,否则后果自负.

  • 如果任何单位或个人认为该博客的任何内容可能涉嫌侵犯其权利,则应及时通知并提供身份证明,所有权证明至admin@proyy.com.我们将在收到认证文件后删除相关内容.

  • 任何以任何方式查看此博客的任何内容的人或直接或间接使用该博客的任何内容的使用者都应仔细阅读此声明。博客保留随时更改或补充此免责声明的权利。一旦使用并复制了博客的任何内容,则视为您已接受此免责声明.

您必须在下载后的24小时内从计算机或手机中完全删除以上内容.

您使用或者复制了本博客的任何内容,则视为已接受此声明,请仔细阅读


更多福利请关注一一网络微信公众号或者小程序

一一网络微信公众号
打个小广告,宝塔服务器面板,我用的也是,很方便,重点是免费的也能用,没钱太难了,穷鬼一个,一键全能部署及管理,送你3188元礼包,点我领取https://www.bt.cn/?invite_code=MV9kY3ZwbXo=


一一网络 » 【工作】Keepalived 重定向日志输出位置

发表评论

发表评论

一一网络-提供最优质的文章集合

立即查看 了解详情