使用java中的文件生成器,我将在本地文件系统中有一个目录和文件流,需要在hdfs中移动。我在互联网上搜索,我看到我可以使用flume,但我没有找到任何资源来解释如何做到这一点。你知道怎么实施吗?谢谢您
68de4m5k1#
我从来没有在同一台机器上做过(正如您在评论中提到的,关于环境),所以您可能需要做一些测试和调整,以使以下配置正常工作。在您的例子中,由于文件将在一个(或多个)目录中动态创建,因此我建议配置假脱机目录源(每个目录)和hdfs接收器。创建一个文件 test.conf 在 conf 目录并放置类似的配置:
test.conf
conf
# Name the components on this agent agent.sources = file-source agent.sinks = hdfs-sink agent.channels = mem-channel # Associate channel with source and sink agent.sources.file-source.channels = mem-channel agent.sinks.hdfs-sink.channel = mem-channel # Configure the source agent.sources.file-source.type = spooldir agent.sources.file-source.spoolDir = /tmp/spool/ agent.sources.file-source.fileHeader = true # Configure the sink agent.sinks.hdfs-sink.type = hdfs agent.sinks.hdfs-sink.hdfs.path = /tmp/log.log agent.sinks.hdfs-sink.hdfs.fileType = DataStream agent.sinks.hdfs-sink.hdfs.path = /flume/test/ # Use a channel which buffers events in memory agent.channels.mem-channel.type = memory agent.channels.mem-channel.capacity = 1000 agent.channels.mem-channel.transactionCapacity = 100
要运行代理,请在flume安装目录中执行以下命令:
bin/flume-ng agent -n agent -c conf -f conf/test.conf
开始将文件放入 /tmp/spool/ 并检查它们是否出现在hdfs中。当您要分发系统时,我建议在客户端使用avro-sink,在服务器上使用avro-source,您将在那里得到它。
/tmp/spool/
1条答案
按热度按时间68de4m5k1#
我从来没有在同一台机器上做过(正如您在评论中提到的,关于环境),所以您可能需要做一些测试和调整,以使以下配置正常工作。
在您的例子中,由于文件将在一个(或多个)目录中动态创建,因此我建议配置假脱机目录源(每个目录)和hdfs接收器。创建一个文件
test.conf
在conf
目录并放置类似的配置:要运行代理,请在flume安装目录中执行以下命令:
开始将文件放入
/tmp/spool/
并检查它们是否出现在hdfs中。当您要分发系统时,我建议在客户端使用avro-sink,在服务器上使用avro-source,您将在那里得到它。