1、Flume的安装非常简单,解压即玩,但是还是要配置一下JAVA_HOME
2、根据数据采集的需求配置采集方案,描述在配置文件中(文件名可任意自定义)
3、指定采集方案配置文件,在相应的节点上启动flume agent
tar -xvf apache-flume-1.8.0-bin.tar.gz
改名
mv apache-flume-1.8.0-bin flume-1.8.0
编写配置文件
vim /home/hadoop/install/flume-1.8.0/conf/netcat-logger.conf
netcat-logger
# Name the components on this agent
#给三个组件取个名字
a1.sources = r1
a1.channels = c1
a1.sinks = k1
# 描述和配置source组件:r1
a1.sources.r1.type = netcat
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 44444
# 描述和配置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
从端口接收数据—>通道里面---->显示在控制台
启动
bin/flume-ng agent --conf conf --conf-file conf/netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console
–conf conf 指定配置文件所在目录
–conf-file conf/netcat-logger.conf 指定特定配置文件
–name a1 agent名字
-Dflume.root.logger=INFO,console
192.168.2.10 安装telnet
yum -y install telnet
监听文件改动
vim /home/hadoop/install/flume-1.8.0/conf/file-logger.log
a1.sources = r1
a1.sinks = k1
a1.channels = c1
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /data/flume/log/test.log
a1.sources.r1.channels = c1
a1.sinks.k1.type = logger
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
创建目录
mkdir -p /data/flume/log/
chown hadoop.hadoop -R /data/flume
#shell脚本,实现循环往文件里面写数据,用于测试
#创建执行脚本目录,并且编写脚本