syslog服务重启需要花费太多时间才能完成

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了syslog服务重启需要花费太多时间才能完成相关的知识,希望对你有一定的参考价值。

在我的系统rsyslog服务运行中,更改rsyslog配置后我需要重启rsyslog服务,但有时需要太多时间(大约1.30分钟1)重启服务。 (用于发送系统日志消息的TLS连接)

rsyslog.conf文件包含:

$SystemLogRateLimitInterval 0

$DefaultNetstreamDriver          gtls # gnu TLS
$DefaultNetstreamDriverCAFile    /etc/certs/ca.crt
$ActionSendStreamDriverMode      1
$ActionSendStreamDriverAuthMode  x509/certvalid
local6.*    @@<ipv4_addr>:6514

journalctl -u rsyslog.service命令输出:

Oct 15 11:43:26 centos74 rsyslogd[9989]:  [origin software="rsyslogd" swVersion="8.24.0" x-pid="9989" x-info="http://www.rsyslog.com"] exiting on signal 15.
Oct 15 11:43:26 centos74 systemd[1]: Stopping System Logging Service...
Oct 15 11:44:56 centos74 systemd[1]: rsyslog.service stop-sigterm timed out. Killing.
Oct 15 11:44:56 centos74 systemd[1]: rsyslog.service: main process exited, code=killed, status=9/KILL
Oct 15 11:44:56 centos74 systemd[1]: Unit rsyslog.service entered failed state.
Oct 15 11:44:56 centos74 systemd[1]: rsyslog.service failed.
Oct 15 11:44:56 centos74 systemd[1]: Starting System Logging Service...
Oct 15 11:44:56 centos74 rsyslogd[11480]:  [origin software="rsyslogd" swVersion="8.24.0" x-pid="11480" x-info="http://www.rsyslog.com"] start
Oct 15 11:44:56 centos74 systemd[1]: Started System Logging Service.

如何减少重启时间?

答案

使用local6.* @@<ipv4_addr>:6514表明您使用的是TCP协议而不是UDP(您应该只使用一个@)。由于您使用的是TCP,因此必须初始化并维护客户端和服务器之间的连接,这可能需要更长的时间。

如果时间对您来说确实是一个大问题,并且您没有符合消息一致性(UDP可能会导致消息丢失),那么您应该查看UDP以减少启动时间。

如果您想坚持使用TCP协议,我建议您调查您的网络架构,以改进/优先考虑客户端和服务器之间的路径。

以上是关于syslog服务重启需要花费太多时间才能完成的主要内容,如果未能解决你的问题,请参考以下文章

Oracle 通过存储过程进行批量插入。花费太多时间

定时器完成后重启功能

从服务器检索数据花费了太多时间

centos7重启rsyslog服务|centos7重启syslog服务

将同步代码包装成异步调用

保存到数据库需要花费太多时间