我有一个 HA 集群,其中 samba 在活动节点上运行,现在我在根邮件中收到以下错误:
Can't find pid for destination 'smbd'
error: error running non-shared postrotate script for /var/log/samba/log.smbd of '/var/log/samba/log.smbd '
Can't find pid for destination 'nmbd'
error: error running non-shared postrotate script for /var/log/samba/log.nmbd of '/var/log/samba/log.nmbd '
run-parts: /etc/cron.daily/logrotate exited with return code 1
我可以让 Logrotate 仅在服务正在运行时重新启动它吗?
根据 smane 的要求,logrotate 配置
/var/log/samba/log.smbd {
weekly
missingok
rotate 7
postrotate
[ ! -x /usr/bin/smbcontrol ] || /usr/bin/smbcontrol smbd reload-config
endscript
compress
delaycompress
notifempty
}
/var/log/samba/log.nmbd {
weekly
missingok
rotate 7
postrotate
[ ! -x /usr/bin/smbcontrol ] || /usr/bin/smbcontrol nmbd reload-config
endscript
compress
delaycompress
notifempty
}
/var/log/samba/log.samba {
weekly
missingok
rotate 7
postrotate
if [ -d /run/systemd/system ] && command systemctl >/dev/null 2>&1 && systemctl is-active --quiet samba-ad-dc; then
systemctl kill --kill-who all --signal=SIGHUP samba-ad-dc
elif [ -f /var/run/samba/samba.pid ]; then
# This only sends to main pid, See #803924
kill -HUP `cat /var/run/samba/samba.pid`
fi
endscript
compress
delaycompress
notifempty
}
答案1
现在根据您的 logrotate 配置,我可以看到这些错误来自哪里。它们来自 smbcontrol 工具,如果找不到 smbd/nbmd PID,它会返回错误代码。
以下是忽略日志轮换脚本中这些错误的简单解决方案:添加行|| true
后的/usr/bin/smbcontrol [sn]mbd reload-config
内容。即第一部分应如下所示
postrotate [ ! -x /usr/bin/smbcontrol ] || /usr/bin/smbcontrol smbd reload-config || true endscript