Keepalived服务日志导出配置
文章目录
- 1.Keepalived服务日志导出设置
- 1.1 创建日志
- 1.2 rsyslog配置
- 1.3 keepalived服务配置
- 1.4 启动服务
- 1.5 问题
1.Keepalived服务日志导出设置
1.1 创建日志
此处可以手动创建,也可以等待默认生成,如果默认syslog生成的话一般用户和用户组为root,提前手动创建好之后,可以修改其所属用户和用户组为其他用户
mkdir -p /var/log/keepalived
touch /var/log/keepalived/keepalived.log
1.2 rsyslog配置
# 1.先删除
sed -i "/^local1\.\*[[:space:]]\{1,\}\/var\/log\/keepalived\/keepalived.log/d" /etc/rsyslog.conf
# 2.添加
sed -i "\$a\local1.* /var/log/keepalived/keepalived.log" /etc/rsyslog.conf
1.3 keepalived服务配置
vim /usr/lib/systemd/system/keepalived.service
# --log-detail -D 详细日志信息
# --dump-conf -d 导出配置数据
# --log-facility -S 设置本地的syslog设备,编号 0-7,本次使用1
# -S 1 表示指定为local1设备
# 启动命令添加参数:-D -d -S 1
ExecStart=/usr/sbin/keepalived -D -d -S 1 xxx
1.4 启动服务
systemctl daemon-reload
systemctl restart rsyslog
systemctl restart keepalived
1.5 问题
1.经过以上配置,keepalived服务的日志,确实打印到/var/log/keepalived/keepalived.log文件中,但是同时,/var/log/message中依然存在keepalived服务日志,依然还会打印到/var/log/message文件中;