keepalived 安装设置


#install

yum install keepalived


默认配置在/etc/keepalived/keepalived.conf 日志在/var/log/messages

[root@host-192-168-3-200 ~]# vi /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="-f /conf/keepalived/keepalived.conf -P -D -S 0"

修改KEEPALIVED_OPTIONS 中参数 -f 指定conf目录 -S 日志位置
前提:
-f 指定的目录中的keepalived.conf 要从默认的目录配置复制过去,备份原来/etc/keepalived/keepalived.conf 并移除
-S 0 指定 /etc/rsyslog.conf 中的日志目录

# vi /etc/rsyslog.conf
#### RULES ####
# 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 :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

-S 指定的0即为local0.* ;添加local0.* 指定到新的log位置 /var/log/keepalived.log
此时重启rsyslog 服务 systemctl restart rsyslog
再重启 keepalived 服务 systemctl restart keepalived


查看 IP a 的虚拟ip 和 keepalived.log