码迷,mamicode.com
首页 > Web开发 > 详细

Flume入门

时间:2017-03-29 16:03:27      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:inf   info   lan   command   apach   入门   数据   oop   example   

参考官方文档:http://flume.apache.org/FlumeUserGuide.html

数据采集工具。

两个官网小例子:

1. 从网络端口获取数据

在conf/下创建example.conf文件:

# example.conf: A single-node Flume configuration

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = weekend01
a1.sources.r1.port = 44444

# Describe the sink
a1.sinks.k1.type = logger

# 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
~

 

执行命令: 

bin/flume-ng agent --conf conf --conf-file example.conf --name a1 -Dflume.root.logger=INFO,console

演示效果:

技术分享

技术分享

 

2. 通过指令获取数据

在conf/下创建文件example2.conf文件:

# example.conf: A single-node Flume configuration

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/hadoop/flume/test.log
a1.sources.r1.channels = c1

# Describe the sink
a1.sinks.k1.type = logger

# 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

 

执行命令: 

bin/flume-ng agent --conf conf --conf-file conf/example2.conf --name a1 -Dflume.root.logger=INFO,console

在自己建的flume/写一段shell程序:

while true; do echo you are my girl >> test.log; sleep 1; done

演示效果:

技术分享

 

Flume入门

标签:inf   info   lan   command   apach   入门   数据   oop   example   

原文地址:http://www.cnblogs.com/DarrenChan/p/6639812.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!