我想知道什么是推荐的方式来旋转PowerDNS日志文件。 我添加了以下条目到logrotate:
# cat /etc/logrotate.d/pdns /var/log/pdns/*.log { daily rotate 7 compress delaycompress }
– 但它看起来像PowerDNS不接受来自logrotate的信号,它指的是旧的日志文件:
# lsof | grep "pdns.log*" rsyslogd 17776 root 5w REG 253,0 88273 785738 /var/log/pdns/pdns.log-20140728
有两种可用的方法:
1. copytruncate选项,但有一个警告,一些日志logging数据可能会丢失。
copytruncate Truncate the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one.
2. postrotate脚本。 看起来需要完全重新启动,因为重新加载(pdns_control cycle)和kill HUP也被忽略 – 使用此方法PowerDNS将在短时间内不可用。
postrotate /sbin/service pdns reload > /dev/null 2>/dev/null || true endscript
Q1。 有没有更好的方法来避免潜在的日志数据丢失或需要重新启动?
细节:
– 系统:CentOS 6x
– 版本:pdns-3.3.1 – 相关选项
/etc/pdns/pdns.conf ... log-dns-queries=yes loglevel=5 logging-facility=6 ...
编辑:
这很奇怪,但我也注意到,它可以正常工作,使用系统日志/var/log/messages默认logging-facility 。
PowerDNSlogging到本地系统日志,因此当您旋转日志文件时,您需要发送HUP信号的系统日志守护程序。 你根本不需要发信号给PowerDNS。
例如(取自rsyslog的logrotateconfiguration):
/var/log/pdns/*.log { sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true endscript }