问题:
td-agent --dry-run
给出包含输出的以下错误:
$ td-agent --dry-run
2017-08-01 15:31:49 +0200 [info]: reading config file path="/etc/td-agent/td-agent.conf"
2017-08-01 15:31:49 +0200 [info]: starting fluentd-0.12.35 as dry run mode
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-mixin-config-placeholders' version '0.4.0'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-mixin-plaintextformatter' version '0.2.6'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-kafka' version '0.5.5'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-mongo' version '0.8.0'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-rewrite-tag-filter' version '1.5.5'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-s3' version '0.8.2'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-scribe' version '0.10.14'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-td' version '0.10.29'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-td-monitoring' version '0.2.2'
2017-08-01 15:31:49 +0200 [info]: gem 'fluent-plugin-webhdfs' version '0.4.2'
2017-08-01 15:31:49 +0200 [info]: gem 'fluentd' version '0.12.35'
2017-08-01 15:31:49 +0200 [info]: adding match pattern="td.*.*" type="tdlog"
2017-08-01 15:31:49 +0200 [error]: dry run failed: out_file: `/var/log/td-agent/failed_records.20170801_0.log` is not writable
错误:/var/log/td-agent/failed_records.20170801_0.log
不可写
问题:
什么可能导致此错误,我可以尝试解决它?注意(下面)该文件不存在,并且该目录是可写的。
旁注:我非常感谢td-agent
调试功能的任何链接。 (将DAEMON_ARGS=-vv
添加到/etc/default/td-agent
并重新启动守护程序,对输出没有任何影响。)
设置和我尝试的内容:
我使用官方文档在Ubuntu 17.04(zesty zapus)上安装了td-agent: https://docs.fluentd.org/v0.12/articles/install-by-deb#step-0-before-installation
我遵循了所有预安装步骤: https://docs.fluentd.org/v0.12/articles/install-by-deb
我安装了td-agent和Xenial的说明,因为Zesty不在列表中。所以我做了:
$ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent2.sh | sh
状态似乎很好:
$ /etc/init.d/td-agent status
● td-agent.service - LSB: data collector for Treasure Data
Loaded: loaded (/etc/init.d/td-agent; generated; vendor preset: enabled)
Active: active (running) since Tue 2017-08-01 11:12:30 CEST; 2min 36s ago
Docs: man:systemd-sysv-generator(8)
Process: 6386 ExecStart=/etc/init.d/td-agent start (code=exited, status=0/SUCCESS)
Tasks: 9 (limit: 4915)
Memory: 82.2M
CPU: 393ms
CGroup: /system.slice/td-agent.service
├─6419 /opt/td-agent/embedded/bin/ruby /usr/sbin/td-agent --log /var/log/td-agent/td-agent.…id
└─6422 /opt/td-agent/embedded/bin/ruby /usr/sbin/td-agent --log /var/log/td-agent/td-agent.…id
Aug 01 11:12:29 foo.bar systemd[1]: Starting LSB: data collector for Treasure Data...
Aug 01 11:12:30 foo.bar td-agent[6386]: Starting td-agent: * td-agent
Aug 01 11:12:30 foo.bar systemd[1]: Started LSB: data collector for Treasure Data.
该文件不存在,目录可写,我在群组td-agent
中,因此我认为这与Fluentd gives the error: Log file is not writable, when starting the server无关。
$ ls -la /var/log/td-agent
total 32
drwxr-xr-x 3 td-agent td-agent 4096 Aug 1 11:12 .
drwxrwxr-x 17 root syslog 4096 Aug 1 14:22 ..
drwxr-xr-x 2 td-agent td-agent 4096 Aug 1 11:12 buffer
-rw-r--r-- 1 td-agent td-agent 17034 Aug 1 14:21 td-agent.log
$ groups foo
foo : foo adm cdrom sudo dip plugdev lpadmin sambashare docker td-agent
strace的相关片段:
[pid 8484] open("/opt/td-agent/embedded/lib/ruby/2.1.0/zlib.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 8484] open("/opt/td-agent/embedded/lib/ruby/2.1.0/x86_64-linux/zlib.so", O_RDONLY|O_CLOEXEC) = 7
[pid 8484] fcntl(7, F_GETFD) = 0x1 (flags FD_CLOEXEC)
[pid 8484] fstat(7, {st_mode=S_IFREG|0755, st_size=256704, ...}) = 0
[pid 8484] fstat(7, {st_mode=S_IFREG|0755, st_size=256704, ...}) = 0
[pid 8484] close(7) = 0
[pid 8484] stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
[pid 8484] stat("/var/log/td-agent/failed_records.20170802_0.log", 0x7ffe01bfc4f0) = -1 ENOENT (No such file or directory)
[pid 8484] stat("/var/log/td-agent/failed_records.20170802_0.log", 0x7ffe01bfc4f0) = -1 ENOENT (No such file or directory)
[pid 8484] stat("/var/log/td-agent/failed_records.20170802_0.log", 0x7ffe01bfc4f0) = -1 ENOENT (No such file or directory)
[pid 8484] stat("/var/log/td-agent", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 8484] stat("/var/log/td-agent", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 8484] stat("/var/log/td-agent", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 8484] geteuid() = 1000
[pid 8484] getegid() = 1000
[pid 8484] getuid() = 1000
[pid 8484] getgid() = 1000
[pid 8484] access("/var/log/td-agent", W_OK) = -1 EACCES (Permission denied)
[pid 8484] stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2335, ...}) = 0
[pid 8484] write(1, "\33[1;35m2017-08-02 10:12:51 +0200"..., 1402017-08-02 10:12:51 +0200 [error]: dry run failed: out_file: `/var/log/td- agent/failed_records.20170802_0.log` is not writable) = 140
----(另一个)编辑:
好的,所以该组没有写权限,并且(最重要的是)td-agent不会成为用户td-agent(即使以root身份运行它 - 它仍保持root)。这是td-agent的错误还是功能?