Logrotate + rsyslog 问题

Logrotate + rsyslog 问题

实际上,我对 rsyslog 有疑问。

当 rsyslog 应该轮换日志(通过 logrotate)时;我遇到了这个问题:

gzip: standard input: Bad file descriptor
error: failed to compress log /var/log/messages-20190716-1563261724

如果我通过 logrotate 运行,正如 rsyslog conf 中提到的那样,它效果很好:

$outchannel 消息,/var/log/messages,60000000,/usr/sbin/logrotate /etc/logrotate.conf

所以,这是我的conf:

/etc/logrotate.d/syslog:

/var/log/messages
{
# !! Rotate size must be less than in rsyslog.conf (60M !!)
size 50M
rotate 4
compress
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
/bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}

/etc/rsyslog.conf:

$ModLoad imklog
$ModLoad imuxsock
$ModLoad imtcp.so # load module
# Maximum TCP sessions (default 200)
$InputTCPMaxSessions 1024
# start up TCP listener at port 514
$InputTCPServerRun 514
# Where to place spool files
$WorkDirectory /export/rsyslog
# infinite retries on insert failure
$ActionResumeRetryCount -1
# save in-memory data if rsyslog shuts down
$ActionQueueSaveOnShutdown on
# Don't slow down dequeuing
$ActionQueueDequeueSlowdown 0
# Queue Types
$MainMsgQueueType FixedArray
$ActionQueueType FixedArray
# Become DA (Disk Assisted Queues)
$MainMsgQueueFileName mainq
$ActionQueueFileNAme actionq
# Disable Rate Throttling (avoids system hang?)
$MainMsgQueueTimeoutEnqueue 0
$ActionQueueTimeoutEnqueue 0
# Set Max Disk space usage
$MainMsgQueueMaxDiskSpace 2g
$ActionQueueMaxDiskSpace 2g
# Message queue size (default 10000)
$MainMsgQueueSize 100000
$ActionQueueSize 100000
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
# Rotate when reaching 60M => see /etc/logrotate.d/syslog
$outchannel messages,/var/log/messages,60000000,/usr/sbin/logrotate /etc/logrotate.conf

我的 /var/log/messages 中有 rsyslog 警告:

Jul 17 14:11:52 hoodriver rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="28100" x-in
fo="http://www.rsyslog.com"] start
Jul 17 14:11:52 hoodriver rsyslogd: WARNING: rsyslogd is running in compatibility mode. Automatically
 generated config directives may interfer with your rsyslog.conf settings. We suggest upgrading your
config and adding -c5 as the first rsyslogd option.
Jul 17 14:11:52 hoodriver rsyslogd-2184: action '$printk' treated as ':omfile:$printk' - please chang
e syntax, '$printk' will not be supported in rsyslog v6 and above. [try http://www.rsyslog.com/e/2184
 ]

在此先感谢您的帮助

相关内容