问题
Here's my td-agent.conf file
<source>
@type http
port 8888
</source>
<match whatever.access>
@type file
path /var/log/what.txt
</match>
But when I try to start the server using
sudo /etc/init.d/td-agent start
it gives the following error:
'2016-02-01 10:45:49 +0530 [error]: fluent/supervisor.rb:359:rescue in >main_process: config error file="/etc/td-agent/td-agent.conf" error="out_file: >
/var/log/what.txt.20160201_0.log
is not writable"
Can someone explain what's wrong?
回答1:
If you installed td-agent v2
, it creates its own user and group called td-agent
. I believe that when you run the td-agent
service, it switches to this user and hence it expects the directory to have write permissions for this user. I faced the same issue and did something like: (Use sudo
if needed for below commands.)
mkdir /logs
chown td-agent:td-agent /logs
and update your section to:
<match whatever.access>
@type file
path /logs/what.txt
</match>
回答2:
I think when you try to start td-agent, you do not have permission to access /var/log/
, using ls -l
to check its permission mode and change it with chmod
.
I got the same problem, after change directory's access permission, td-agent can be started.
来源:https://stackoverflow.com/questions/35123483/fluentd-gives-the-error-log-file-is-not-writable-when-starting-the-server