1. 目标
source监听本地44444端口的数据,然后由sink在控制台展示出来。
2. 实现过程
1》在~/software下载flume最新版本:wget http://mirrors.shu.edu.cn/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
2》在当前文件夹下解压:tar -zxvf apache-flume-1.9.0-bin.tar.gz
3》进入flume根目录,新建job文件夹,在job下vim flume-telnet.conf
,输入:
#single-node flume configuration
#first: name the component on this agent
a1.sources = r1
a1.channels = c1
a1.sinks = k1
#second: describe the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
#third: describe the channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.transactionCapacity = 100
#fouth: describe the sink
a1.sinks.k1.type = logger
#fifth: bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
然后保存并退出
4》在flume根目录下执行bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-telnet.conf -Dflume.root.logger==INFO,console
启动flume,启动命令详解:
- 该命令是在flume分发包的根目录执行的
- bin/flume-ng agent --conf conf/是固定写法,表示执行bin下的flume-ng这个文件 agent表示一个组件 --conf conf/表示配置文件是在conf目录下
- –name a1表示这个组件的名字叫做a1
- –conf-file job/flume-telnet.conf表示自己写的配置文件在job目录下,名字叫做flume-telnet.conf
- -D表示动态的指定参数,这里指定的应该是root logger的日志级别
控制台没有报错,说明启动成功
5》使用telnet连接本地44444端口:telnet localhost 44444
6》在telnet控制台输入aaa,bbb,ccc看到flume的控制台抓取到了相应的数据,大功告成!!!
3. 参考文档
http://flume.apache.org/FlumeUserGuide.html#starting-an-agent