Logging

收集日誌文件的權限被拒絕

  • October 15, 2019

我已經收集了執行,並以 root 身份啟動它:

service collectd start

但是,我看不到日誌。我執行時得到以下資訊:服務收集狀態:

logfile plugin: fopen (/var/log/collectd/collectd.log) failed: Permission denied
logfile plugin: fopen (/var/log/collectd/collectd.log) failed: Permission denied
logfile plugin: fopen (/var/log/collectd/collectd.log) failed: Permission denied
logfile plugin: fopen (/var/log/collectd/collectd.log) failed: Permission denied
logfile plugin: fopen (/var/log/collectd/collectd.log) failed: Permission denied

文件系統的權限如下:

[root@avocado]# ls -la /var/log/collectd/
total 8
drwxrwxrwx.  2 root root 4096 Aug 16 06:07 .
drwxr-xr-x. 20 root root 4096 Aug 16 06:00 ..
-rwxrwxrwx.  1 root root    0 Aug 16 06:07 collectd.log

我在嘗試解決此問題時手動創建了 /var/log/collectd 文件夾和 /var/log/collectd/collectd.log 文件。

collectd配置如下:

#LoadPlugin syslog
LoadPlugin "logfile"
#LoadPlugin log_logstash

<Plugin "logfile">
   LogLevel "info"
   File "/var/log/collectd/collectd.log"
   Timestamp true
   PrintSeverity false
</Plugin>

我錯過了什麼?我怎樣才能收集到停止抱怨權限並正確記錄?

很可能是SElinux。getenforce 返回什麼?

對我來說,它是 selinux,這修復了它:

setenforce 0

引用自:https://serverfault.com/questions/797039