安装配置
下载安装包,解压,不再赘述。
我这里解压到/export/servers目录下
![](https://img.haomeiwen.com/i4849955/54f7350b2e2bb426.png)
conf
目录下,然后重命名flume-env.sh.template
为flume-env.sh
:![](https://img.haomeiwen.com/i4849955/8d1b188353802a50.png)
然后编辑
flume-env.sh
:首先是指定
JAVA_HOME
,注意JAVA_HOME
不包括后边的/bin/java
![](https://img.haomeiwen.com/i4849955/b891fe88653ec7fd.png)
![](https://img.haomeiwen.com/i4849955/ed5111cb924c023f.png)
采集方案配置
例:采集端口数据:
source端采集端口数据,sink端输出到终端logger
以source端和sink端数据类型命名,source-sink.conf
在conf
目录下创建netcat-logger.conf
:
# 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
![](https://img.haomeiwen.com/i4849955/45beb192e7fbc710.png)
启动agent
![](https://img.haomeiwen.com/i4849955/ec6eb7099ee03bc7.png)
在Flume的目录下运行命令:
bin/flume-ng agent --conf conf --conf-file conf/netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console
从帮助中可以看到--conf
参数可以用-c
代替,这个参数指定flume自身的配置文件所在目录;--conf-file
可以用-f
代替,指定描述采集方案的配置文件;--name
可以用-n
代替,指定agent的名字
![](https://img.haomeiwen.com/i4849955/bc399ddcc4119368.png)
启动
telnet
向本机指定端口发送数据测试,如果没有安装telnet
,可以使用yum -y install telnet
安装(yum -y erase telnet
删除)。![](https://img.haomeiwen.com/i4849955/2db164615e5cd753.png)
![](https://img.haomeiwen.com/i4849955/49168a12f24c6357.png)
网友评论