Keepalived指定日志文件

Keepalived指定日志文件

首先查看keepalived命令的参数,-S指定syslog的facility。

/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
然后通过如下命令启动keepalived,

[root@LVS02 ~]# /usr/local/keepalived/sbin/keepalived -d -D -S 0
或者修改/etc/sysconfig/keepalived,然后用service来启动。

[root@LVS02 ~]# 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 -S 0"
[root@LVS02 ~]# service keepalived start
最后设置syslog,修改/etc/syslog.conf.

root@LVS02 ~]# cat /etc/syslog.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
# keepalived -S 0
local0.* /var/log/keepalived.log

重启syslog,设置完成。

Keepalived 的详细介绍请点这里
Keepalived 的下载地址请点这里

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/9d633d69329736a0176eb2cf1152ac73.html