flume正在向我要推送的hdfs文件添加一个随机数(test.csv>test.csv.1591560702234)

zphenhs4  于 2021-05-31  发布在  Hadoop
关注(0)|答案(1)|浏览(170)

当我把一个文件放到本地目录( vagrant/flume/test.csv ),在hdfsFlume中( /user/inputs/test.csv.1591560702234 ),我想知道为什么hdfs 1591560702234 以及如何移除它!
这是我的flume.conf文件


# Flume agent config

a1.sources = r1
a1.sinks =  k2
a1.channels = c1

a1.channels.c1.type = file
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000

a1.sources.r1.channels = c1
a1.sources.r1.type = spooldir
a1.sources.r1.basenameHeader = true
a1.sources.r1.spoolDir = /vagrant/flume

a1.sinks.k2.type = hdfs
a1.sinks.k2.channel = c1

a1.sinks.k2.hdfs.filePrefix = %{basename}
a1.sinks.k2.hdfs.writeFormat = Text

# a1.sinks.k2.hdfs.fileSuffix =

a1.sinks.k2.hdfs.fileType = DataStream
a1.sinks.k2.hdfs.path = /user/inputs/

a1.sinks.k2.rollInterval = 0
a1.sinks.k2.rollSize = 0
a1.sinks.k2.rollCount = 0
a1.sinks.k2.idleTimeout = 0

# Bind the source and sink to the channel

a1.sources.r1.channels = c1
a1.sinks.k2.channel = c1
wlp8pajw

wlp8pajw1#

flume以毫秒为单位添加时间。从你的例子来看:

select from_unixtime(ceil(1591560702234 / 1000));
+----------------------+--+
|         time         |
+----------------------+--+
| 2020-06-07 22:11:43  |
+----------------------+--+

我认为用flume配置删除时间戳是不可能的。
但是你可以加一个后缀 hdfs.fileSuffix . 根据文件:

hdfs.fileSuffix –   Suffix to append to file (eg .avro - NOTE: period is not automatically added)

您还可以在一个文件中放置更多具有某些flume属性的事件
请检查
批量大小
卷大小
滚动时间
滚动计数
您还可以使用hdfs命令合并目录。

getmerge
Usage: hadoop fs -getmerge [-nl] <src> <localdst>

将源目录和目标文件作为输入,并将src中的文件连接到目标本地文件中。也可以将-nl设置为允许在每个文件的末尾添加换行符(lf)-跳过空文件可以用来避免在空文件的情况下不需要的换行符。
示例:

hadoop fs -getmerge -nl /src /opt/output.txt
hadoop fs -getmerge -nl /src/file1.txt /src/file2.txt /output.txt

相关问题