1、sources选择exec,sinks选择hbase
都是一样,找文档查参数
2、监听telnet端口
配置文件:source选择netcat(端口,tcp协议),sink选择logger(直接打印)
#定义一个agent名字为a1
#定义三个组件sources,channels,sinks
a1.sources = r1
a1.channels = c1
a1.sinks = k1
#配置sources
a1.sources.r1.type = netcat
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 8888
#配置channels
a1.channels.c1.type = memory
#配置sinks
a1.sinks.k1.type = logger
#组装
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
安装telnet yum install telnet 执行flume flume-ng agent -n a1 -f
./agent/netcatToLogger.conf -Dflume.r oot.logger=DUBUG,console
启动telnet—类似于客户端,传输数据 telnet master 8888
3、http协议
配置文件:source选择http(http协议),channel选择memory(内存),sink选择logger(控制台)
#定义一个agent名字为a1
#定义三个组件sources,channels,sinks
a1.sources = r1
a1.channels = c1
a1.sinks = k1
#配置sources
a1.sources.r1.type = http
a1.sources.r1.port = 8888
#配置channels
a1.channels.c1.type = memory
#配置sinks
a1.sinks.k1.type = logger
#组装
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
先启动agent
再使用curl发起一个http请求
curl -X POST -d ‘[ { “headers” :{“a” : “a1”,“b” : “b1”},“body” :
“hellohttpflume~”}, { “headers” :{“a2” : “a12”,“b2” : “b12”},“body”
: “hellohttpflume~”} ]’ http://master:8888