分享

求问使用flume 1.7 taildir时出现如下错误怎么办?

李建昊 发表于 2017-11-10 16:29:06 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 4 24657
使用taildir监听一个目录,出现报错:
2017-11-11 00:22:18,468 (lifecycleSupervisor-1-0) [ERROR - org.apache.flume.source.taildir.ReliableTaildirEventReader.loadPositionFile(ReliableTaildirEventReader.java:146)] Failed loading positionFile: /usr/local/flume/log/taildir_position.json
java.io.EOFException: End of input at line 1 column 1
        at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:954)
        at com.google.gson.stream.JsonReader.nextValue(JsonReader.java:771)
        at com.google.gson.stream.JsonReader.peek(JsonReader.java:367)
        at com.google.gson.stream.JsonReader.expect(JsonReader.java:337)
        at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:306)
        at org.apache.flume.source.taildir.ReliableTaildirEventReader.loadPositionFile(ReliableTaildirEventReader.java:110)
        at org.apache.flume.source.taildir.ReliableTaildirEventReader.<init>(ReliableTaildirEventReader.java:95)
        at org.apache.flume.source.taildir.ReliableTaildirEventReader.<init>(ReliableTaildirEventReader.java:48)
        at org.apache.flume.source.taildir.ReliableTaildirEventReader$Builder.build(ReliableTaildirEventReader.java:348)
        at org.apache.flume.source.taildir.TaildirSource.start(TaildirSource.java:103)
        at org.apache.flume.source.PollableSourceRunner.start(PollableSourceRunner.java:71)
        at org.apache.flume.lifecycle.LifecycleSupervisor$MonitorRunnable.run(LifecycleSupervisor.java:249)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)


我的conf文件如下 :
a1.sources.r1.type=taildir
#a1.sources.r1.type=org.apache.flume.source.taildir.TaildirSource
a1.sources.r1.filegroups = f1
a1.sources.r1.filegroups.f1 = /mnt/hgfs/Logs
a1.sources.r1.positionFile = /usr/local/flume/log/taildir_position.json
a1.sources.r1.fileHeader = false
#加拦截器
a1.sources.r1.interceptors = i1
#时间戳拦截器
a1.sources.r1.interceptors.i1.type = timestamp

求问各路高手该怎么破?

已有(4)人评论

跳转到指定楼层
yuwenge 发表于 2017-11-10 19:10:10
可以尝试创建如下目录 [mw_shl_code=bash,true]~/.flume[/mw_shl_code]
不行的话,可以打个补丁
把下面内容存为FLUME-2773.patch
[mw_shl_code=java,true]diff --git a/flume-ng-sources/flume-taildir-source/src/main/java/org/apache/flume/source/taildir/TaildirSource.java b/flume-ng-sources/flume-taildir-source/src/main/java/org/apache/flume/source/taildir/TaildirSource.java
index 97ca43b..8816327 100644
--- a/flume-ng-sources/flume-taildir-source/src/main/java/org/apache/flume/source/taildir/TaildirSource.java
+++ b/flume-ng-sources/flume-taildir-source/src/main/java/org/apache/flume/source/taildir/TaildirSource.java
@@ -22,6 +22,9 @@ import static org.apache.flume.source.taildir.TaildirSourceConfigurationConstant
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -151,6 +154,12 @@ public class TaildirSource extends AbstractSource implements

     String homePath = System.getProperty("user.home").replace('\\', '/');
     positionFilePath = context.getString(POSITION_FILE, homePath + DEFAULT_POSITION_FILE);
+    Path positionFile = Paths.get(positionFilePath);
+    try {
+      Files.createDirectories(positionFile.getParent());
+    } catch (IOException e) {
+      throw new FlumeException("Error creating positionFile parent directories", e);
+    }
     headerTable = getTable(context, HEADERS_PREFIX);
     batchSize = context.getInteger(BATCH_SIZE, DEFAULT_BATCH_SIZE);
     skipToEnd = context.getBoolean(SKIP_TO_END, DEFAULT_SKIP_TO_END);[/mw_shl_code]


回复

使用道具 举报

水墨风漾 发表于 2019-10-21 14:39:22
大佬你好 我也遇到和你一样的错!你这边解决了吗?可以分享一下吗?多谢多谢了!
回复

使用道具 举报

s060403072 发表于 2019-10-21 20:21:07
水墨风漾 发表于 2019-10-21 14:39
大佬你好 我也遇到和你一样的错!你这边解决了吗?可以分享一下吗?多谢多谢了!

现在flume1.8了,这可能是一个bug。推荐楼主直接使用Flume1.8.试试
回复

使用道具 举报

xiaoqingwuku 发表于 2019-12-31 09:52:07
这个是tailsource 代码的一个bug,有一定概率回执空taildir_position.json文件,这个是要改源码的。https://issues.apache.org/jira/p ... 48?filter=allissues,说明在这。
https://github.com/apache/flume/pull/313代码修改在这
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条