测试Flume-1.6.0写入HDFS(Hadoop-2.7.2)的简单实例

一、推荐参考博客地址:http://blog.csdn.net/xiao_jun_0820/article/category/2399621node

放在flume根目录conf文件夹下的代理配置文件写法:oop

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

a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444

a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path=hdfs://localhost:9000/user/hadoop/flume
a1.sinks.k1.hdfs.fileType=DataStream  
a1.sinks.k1.hdfs.writeFormat=Text  
a1.sinks.k1.hdfs.rollInterval=0  
a1.sinks.k1.hdfs.rollSize=10240  
a1.sinks.k1.hdfs.rollCount=0  
a1.sinks.k1.hdfs.idleTimeout=60  

# Use a channel which buffers events in memory

a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

先进到hadoop的根目录下启动HDFS (命令./sbin/start-dfs.sh)测试

而后开启终端启动上面的代理文件,开启另外一个终端测试端口链接。spa

能够参考本博此文:http://my.oschina.net/u/2478308/blog/731838.net

写入成功后会在终端中显示例如FlumeData.1470365774656.tmp的文件,该文件会根据设置的时间去除.tmp后缀。代理

事项:code

 一、HDFS的写入路径为 hdfs://namenodepath:namenodeport/自定义用户目录/自定义数据存储目录。对应目录须要提早建立,代理启动写入时不会本身建立目录。orm

 二、须要切换到有hdfs写入权限的用户。blog

 三、dfs.fileType=DataStream  hdfs.writeFormat=Text 使生成的文件能够读取。hadoop

 四、flume写入hdfs后能够经过例如./bin/hdfs dfs -cat flume/FlumeData.1470365774656,查看hdfs中的文件内容。

 五、能够链接http://localhost:50070中Utilities查看相关目录下的写入HDFS的文件。

相关文章
相关标签/搜索