说明:
-c目录,-f 具体文件,文件名 ,-n 代理名称,以下两个命令等同,一个是简写
bin/flume-ng agent --conf ./conf --conf-file ./conf/example.conf --name a1 -Dflume.root.logger=INFO,console
bin/flume-ng agent -c ./conf -f ./conf/example.conf -n a1 -Dflume.root.logger=INFO,console
1.案例一:exesource
在example2.conf设置如下:
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = echo 'hello'
# 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 -c ./conf -f ./conf/example2.conf -n a1 -Dflume.root.logger=INFO,console (第二张是第一张执行后显示的结果)
2.案例二:netcatsource
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 = 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 = 100000
a1.channels.c1.transactionCapacity = 1000
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
2.执行命令:在第一个窗口输入 :[jurf@ljf-centos apache-flume-1.6.0-bin]$ bin/flume-ng agent -c ./conf -f ./conf/example.conf -n a1 -Dflume.root.logger=INFO,console
在第二个窗口输入:telnet localhost 44444;(之后输入要传输的的内容)
3. 如图:
有两个问题:1.为何不能显示汉字;2.为何显示的文字不能超过16位的长度。待研究.........
退出telnet命令:ctrl + ] 回车
之后: quit
详细文档见百度网盘