我已经在运行 collectd 并且以 root 身份启动它:
service collectd start
但是,我看不到日志。当我运行 service collectd status 时,我得到以下信息:
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>
我遗漏了什么?如何让 collectd 停止抱怨权限并正确记录?
答案1
最有可能是 SElinux。getenforce 返回什么?
答案2
对我来说这是 selinux,并且这个修复了它:
setenforce 0
答案3
yum install policycoreutils-python
然后
semanage permissive -a collectd_t