2017-07-19 57 views
2

我正在使用Flume收集推文并将它们存储在HDFS上。 收集部分工作正常,我可以在我的文件系统中找到我的所有推文。如何在单个文件中提取所有收集的推文

现在我想在一个文件中提取所有这些推文。 的问题是,不同的鸣叫存储如下: enter image description here

正如我们所看到的,微博都存储在128 MB的块,但只能使用几个阁,这是HDFS一种正常的行为纠正我,如果我错了。

但是我怎样才能在一个文件上得到所有不同的推文呢?

这里是我的conf文件,我与follwing命令来运行:

水槽-NG代理-n TwitterAgent -f ./my-flume-files/twitter-stream-tvseries.conf

Twitter的流tvseries.conf:

TwitterAgent.sources =微

TwitterAgent.c hannels = MemChannel

TwitterAgent.sinks = HDFS

TwitterAgent.sources.Twitter.type = org.apache.flume.source.twitter.TwitterSource TwitterAgent.sources.Twitter.consumerKey =隐藏 TwitterAgent.sources .Twitter.consumerSecret =隐藏 TwitterAgent.sources.Twitter.accessToken =隐藏 TwitterAgent.sources.Twitter.accessTokenSecret =隐藏 TwitterAgent.sources.Twitter.keywords = GOT,GameofThrones

TwitterAgent.sources.Twitter.keywords = GoT,GameofThrone小号

TwitterAgent.sinks.HDFS.channel = MemChannel TwitterAgent.sinks.HDFS.type = HDFS TwitterAgent.sinks.HDFS.hdfs.path = HDFS:// IP-addressl:8020 /用户/根/数据/叽叽喳喳/ tvseries /鸣叫 TwitterAgent.sinks.HDFS.hdfs.fileType =的数据流中 TwitterAgent.sinks.HDFS.hdfs.writeformat =文本 TwitterAgent.sinks.HDFS.hdfs.batchSize = 1000 TwitterAgent.sinks.HDFS.hdfs .rollSize = 0 TwitterAgent.sinks.HDFS.hdfs.rollCount = 10000 TwitterAgent.sinks.HDFS.hdfs.rollInterval = 600

TwitterAgent.channels.MemChannel.type =存储器 TwitterAgent.channels.MemChannel.capacity = 10000 TwitterAgent.channels.MemChannel.transactionCapacity = 1000

TwitterAgent.sources.Twitter.channels = MemChannel TwitterAgent.sinks.HDFS.channel = MemChannel

+0

您使用的是'org.apache.flume.source.twitter.TwitterSource'还是其他自定义源? (例如[Cloudera's])(http://blog.cloudera.com/blog/2012/10/analyzing-twitter-data-with-hadoop-part-2-gathering-data-with-flume/)。 – frb

+0

我使用org.apache.flume.source.twitter.TwitterSource,我在文章中添加了我的.conf。 –

回答

0

你可以配置HDFS接收器以按时间,事件或大小生成消息。所以,如果你想保存多封邮件,直到达到120MB限制,请将

hdfs.rollInterval = 0 # This is to create new file based on time 
hdfs.rollSize = 125829120 # This is to create new file based on size 
hdfs.rollCount = 0 # This is to create new file based on events (different tweets in your case) 
+0

我在哪里配置?在一个文件中?我在HortonWorks上。 –

+0

我不在HortonWorks中,所以我不知道你需要修改它。我想你会有一个UI来管理接收器类型和其他参数。它应该在那里,你可以张贴截图吗? – Tortxu13

+0

如果您不使用UI,需要编辑的文件被称为flume.conf – Tortxu13

0

您可以使用以下命令将文件连接成一个文件:

find . -type f -name 'FlumeData*' -exec cat {} + >> output.file 

,或者如果你想存储将数据放入Hive表中供以后分析,创建一个外部表并将其使用到Hive DB中。

相关问题