Flume安装测试

本文档详细介绍了Apache Flume的安装步骤和测试过程,包括Avro和Spool两个案例。首先,从官网下载Flume二进制文件并解压,通过执行`bin/flume-ng version`命令检查安装是否成功。接着,展示了Avro源如何发送文件给Flume,以及Spool源如何监测目录下新增文件。通过配置agent文件和启动Flume agent,成功实现了数据的收集和输出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、从官网下载最新版的二进制Flume安装文件:apache-flume-1.6.0-bin.tar.gz

2、在指定目录/home/hadoop/下解压缩安装文件:tar -zxvf apache-flume-1.6.0-bin.tar.gz

3、在Flume安装目录下执行如下命令测试Flume是否安装成功:bin/flume-ng version

出现如下内容则表示Flume安装成功

4、Flume测试案例:


案例1:Avro
Avro可以发送一个给定的文件给Flume,Avro 源使用AVRO RPC机制。
a)创建agent配置文件

vi /home/hadoop/apache-flume-1.6.0-bin/conf/avro.conf
  
a1.sources = r1
a1.sinks = k1
a1.channels = c1
  
# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = 172.26.40.74
a1.sources.r1.port = 4141
  
# 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


b)启动flume agent a1

bin/flume-ng agent -c . -f /home/hadoop/apache-flume-1.6.0-bin/conf/avro.conf -n a1 -Dflume.root.logger=INFO,console

c)创建指定文件
echo "hello world" > /home/hadoop/apache-flume-1.6.0-bin/log.00
d)使用avro-client发送文件
bin/flume-ng avro-client -c . -H 172.26.40.74 -p 4141 -F /home/hadoop/apache-flume-1.6.0-bin/log.00
f)在172.26.40.74的控制台,可以看到以下信息:




案例2:Spool
Spool监测配置的目录下新增的文件,并将文件中的数据读取出来。需要注意两点:
1) 拷贝到spool目录下的文件不可以再打开编辑。
2) spool目录下不可包含相应的子目录
a)创建agent配置文件
vi /home/hadoop/apache-flume-1.6.0-bin/conf/spool.conf
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.channels = c1
a1.sources.r1.spoolDir = /home/hadoop/apache-flume-1.6.0-bin/logs
a1.sources.r1.fileHeader = true
# 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
b)启动flume agent a1
bin/flume-ng agent -c . -f /home/hadoop/apache-flume-1.6.0-bin/conf/spool.conf -n a1 -Dflume.root.logger=INFO,console
c)追加文件到/home/hadoop/flume-1.5.0-bin/logs目录
echo "spool test1" > /home/hadoop/apache-flume-1.6.0-bin/logs/spool_text.log
d)在m1的控制台,可以看到以下相关信息:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值