flume同步日誌文件的3種方式體驗:
截止flume1.9爲止
1、exec source
tail -n +0 -F xx.log 此種方式存在bug,當日志文件記錄大於1MB時並且指定了shell,flume會假死 修正: org.apache.flume.source.ExecSource.java process = Runtime.getRuntime().exec(commandArgs); 爲 process = new ProcessBuilder(commandArgs).redirectErrorStream(true).start();
2、tailDir source
此種方式存在bug,當監聽特定文件時,如監聽statis.log,每天切割爲statis.log.1 statis.log.2,新日誌一直寫statis.log。當切割時會丟失部分日誌。
3、spoolDir source
此種方式暫未發現問題
4、通用bug:
flume LineDeserializer 2m限制導致的bug,當單行日誌大於2MB時,會拆分成多行寫出。
修改org.apache.flume.serialization.LineDeserializer MAXLINE_DFLT = 4096; 重新打包flume-ng-core-1.9.0.jar