我正在使用flume spooldir将文件放入hdfs,但是我在hdfs中得到了太多的小文件。我想过使用批量大小和滚动间隔,但我不想依赖于大小和间隔。所以我决定在flume中一次推一个文件。我该怎么做?
xj3cbfub1#
根据https://flume.apache.org/flumeuserguide.html#spooling-目录源,如果设置 a1.sources.src-1.fileHeader = true ,则可以在hdfs接收器中指定任何头(例如文件名头)(请参阅 %{host} 在转义序列描述中https://flume.apache.org/flumeuserguide.html#hdfs-Flume。编辑:对于示例配置,可以尝试以下操作:
a1.sources.src-1.fileHeader = true
%{host}
a1.sources = r1 a1.sources.r1.type = spooldir a1.sources.r1.channels = c1 a1.sources.r1.spoolDir = /flumespool a1.sources.r1.basenameHeader = true a1.channels = c1 a1.channels.c1.type = memory a1.sinks = k1 a1.sinks.k1.type = hdfs a1.sinks.k1.channel = c1 a1.sinks.k1.hdfs.path = /flumeout/%{basename} a1.sinks.k1.hdfs.fileType = DataStream
1条答案
按热度按时间xj3cbfub1#
根据https://flume.apache.org/flumeuserguide.html#spooling-目录源,如果设置
a1.sources.src-1.fileHeader = true
,则可以在hdfs接收器中指定任何头(例如文件名头)(请参阅%{host}
在转义序列描述中https://flume.apache.org/flumeuserguide.html#hdfs-Flume。编辑:对于示例配置,可以尝试以下操作: