1.4 Flume安装部署
前置条件
- Java 1.7 or later
- 为sources,channels和sinks提供充足的内存
- 为channles提供充足的磁盘空间
- 为agent提供读和写权限
安装过程
Flume 的安装非常简单
上传安装包到数据源所在节点上
然后解压 tar -zxvf apache-flume-1.6.0-bin.tar.gz
然后进入 flume 的目录,修改 conf 下的 flume-env.sh,在里面配置 JAVA_HOME
配置flume环境变量:
vi ~/.bash_profile
export FLUME_HOME=xxx/apache-flume-1.6.0-cdh5.7.0-bin
export PATH=$FLUME_HOME/bin:$PATH
source 生效
检查是否配置成功:flume-ng version查看flume版本
根据数据采集需求配置采集方案,描述在配置文件中(文件名可任意自定义)
指定采集方案配置文件,在相应的节点上启动 flume agent
先用一个最简单的例子来测试一下程序环境是否正常
1.先在flume的conf目录下新建一个文件
test.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 = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
2.启动agent去采取数据
bin/flume-ng agent -c conf -f conf/test.conf -n a1 -Dflume.root.logger=INFO,console
-c conf 指定 flume 自身的配置文件所在目录
-f conf/netcat-logger.con 指定我们所描述的采集方案
-n a1 指定我们这个 agent 的名字
3.测试
先要往 agent 采集监听的端口上发送数据,让 agent 有数据可采。
随便在一个能跟 agent 节点联网的机器上:
telnet anget-hostname port
例如:telnet localhost 44444