1 netcat-logger案例
1 编辑conf文件
vim netcat-logger.conf
# 定义这个agent各个组件的名字
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# 描述和配置source组件:r1
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 11111
# 描述和配置sink组件:k1
a1.sinks.k1.type = logger
# 描述和配置channel组件,此处使用是内存缓存的方式
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# 描述和配置source channel sink之间的连接关系
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
2 启动Flume
bin/flume-ng agent -c conf/ -f conf/netcat-logger.conf -n a1 -Dflume.root.logger=INFO,console
-c 指定flume自身配置文件所在目录
-f 指定采集方案文件
-n 要和配置文件中的agent名字一致
3 使用telnet测试
telnet localhost 11111
// 如果没有telnet,用yum install -y telnet安装
如果出现端口占用,可以用kill命令