keepalived的日志在哪里、配置keepalived日志路径

前言

环境:centos 7.9 keepalived-2.2.7

keepalived默认日志路径

默认情况下,不管yum安装的keepalived还是源码编译安装的keepalived,其都是受systemd管理的,所以日志可以这样看:

 systemctl  status keepalived.service -l
 journalctl  -u keepalived.service  -f
 tail -22f /var/log/messages | grep Keepalived

修改keepalived日志路径

默认的日志路径太不友好,可以让keepalived单独输出日志到指定文件,如下配置:

keepalived的环境变量配置默认在 yum 安装的在 /etc/sysconfig/keepalived ,源码编译安装的在/usr/local/keepalived/etc/sysconfig/keepalived

[root@node2 ~]# vim /usr/local/keepalived/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 -S 0"		#改这一句,添加-S 0

[root@node2 ~]#  vim /etc/rsyslog.conf 
#在下面这一行后面添加
# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log

#添加这一行
# save keepalived log to keepalived.log
local0.*                                                /var/log/keepalived.log
[root@node1 sysconfig]# systemctl restart rsyslog				#重启rsyslog
[root@node1 sysconfig]# systemctl restart keepalived 			#重启keepalived 

[root@node1 sysconfig]# tail -222f /var/log/keepalived.log		#keepalived的日志已经成功指定到我们定义的文件了
Oct 15 20:49:20 node1 Keepalived[109485]: Starting Keepalived v2.2.7 (01/16,2022)
Oct 15 20:49:20 node1 Keepalived[109485]: Running on Linux 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 (built for Linux 3.10.0)
Oct 15 20:49:20 node1 Keepalived[109485]: Command line: '/usr/local/keepalived/sbin/keepalived' '-D' '-S' '0'
Oct 15 20:49:20 node1 Keepalived[109485]: WARNING - using deprecated default config file '/etc/keepalived/keepalived.conf' - please move to '/usr/local/etc/keepalived/keepalived.conf'
Oct 15 20:49:20 node1 Keepalived[109485]: Opening file '/etc/keepalived/keepalived.conf'.
Oct 15 20:49:20 node1 Keepalived[109485]: Configuration file /etc/keepalived/keepalived.conf
Oct 15 20:49:20 node1 Keepalived[109486]: NOTICE: setting config option max_auto_priority should result in better keepalived performance
Oct 15 20:49:20 node1 Keepalived[109486]: Starting VRRP child process, pid=109487
Oct 15 20:49:20 node1 Keepalived_vrrp[109487]: Registering Kernel netlink reflector
Oct 15 20:49:20 node1 Keepalived_vrrp[109487]: Registering Kernel netlink command channel
Oct 15 20:49:20 node1 Keepalived_vrrp[109487]: SECURITY VIOLATION - scripts are being executed but script_security not enabled.
Oct 15 20:49:20 node1 Keepalived_vrrp[109487]: Assigned address 192.168.118.132 for interface ens33
Oct 15 20:49:20 node1 Keepalived_vrrp[1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值