Logrotate + rsyslog 문제

Logrotate + rsyslog 문제

실제로 rsyslog에 문제가 있습니다.

rsyslog가 로그를 회전해야 할 때(logrotate를 통해) 다음 문제가 발생했습니다.

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

rsyslog conf에서 언급한 대로 logrotate를 실행하면 정상적으로 작동합니다.

$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
 ]

도움을 주셔서 미리 감사드립니다.

관련 정보