标签:
# 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 = localhost
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
将上述配置存为:example.conf
然后我们就可以启动 Flume 了:
1
|
bin/flume-ng agent --conf conf --conf-file conf/example.conf --name a1 -Dflume.root.logger=INFO,console
|
PS:-Dflume.root.logger=INFO,console 仅为 debug 使用,请勿生产环境生搬硬套,否则大量的日志会返回到终端。。。
-c/--conf 后跟配置目录,-f/--conf-file 后跟具体的配置文件,-n/--name 指定agent的名称
然后我们再开一个 shell 终端窗口,telnet 上配置中侦听的端口,就可以发消息看到效果了:
然后我们再开一个 shell 终端窗口,telnet 上配置中侦听的端口,就可以发消息看到效果了:
1
2
3
4
5
6
|
$ telnet localhost 44444 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is ‘^]‘ . Hello world! <ENTER> OK |
Flume 终端窗口此时会打印出如下信息,就表示成功了:
1
2
3
|
12 /06/19 15:32:19 INFO source .NetcatSource: Source starting 12 /06/19 15:32:19 INFO source .NetcatSource: Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[ /127 .0.0.1:44444] 12 /06/19 15:32:34 INFO sink.LoggerSink: Event: { headers:{} body: 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 0D Hello world!. |
http://my.oschina.net/leejun2005/blog/288136
http://idoall.org/home.php?mod=space&uid=1&do=blog&id=550
http://blog.javachen.com/2014/07/22/flume-ng/
http://www.tuicool.com/articles/ruyANnF
标签:
原文地址:http://www.cnblogs.com/gym333/p/4485917.html