共计 2998 个字符,预计需要花费 8 分钟才能阅读完成。
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 的下载地址 :请点这里
推荐阅读:
CentOS 6.3 下 Haproxy+Keepalived+Apache 配置笔记 http://www.linuxidc.com/Linux/2013-06/85598.htm
Haproxy + KeepAlived 实现 WEB 群集 on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm
Keepalived+Haproxy 配置高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/56748.htm
Haproxy+Keepalived 构建高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/55880.htm