Flume搭建测试

一、环境

hadoop2.7.1集群
flume1.7.0
source为syslog
sink为hdfs

二、安装

1.下载安装包
http://flume.apache.org/
2.解压

cp apache-flume-1.7.0-bin.tar /home/cms/flume```
**3.配置环境变量**
```export FLUME_HOME=$HOME/flume
CLASSPATH以及PATH```
**4.测试是否安装成功**
```flume-ng version```

![](http://upload-images.jianshu.io/upload_images/1908836-eff9fefcdb8390df.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**5.配置flume**
注意,我这里使用的**source**为syslog
**sink**为hdfs
其他配置可参考[flume官网](http://flume.apache.org/FlumeUserGuide.html)
进入flume/conf目录
1)修改 flume-env.sh 配置文件,主要是JAVA_HOME变量设置

export JAVA_HOME=/usr/lib/jvm/java-6-sun

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

2)创建agent配置文件

cp flume-conf.properties.template flume-conf.properties```
配置souce、sink、chanel
听TCP端口作为数据源(还可以使用其他作为数据源),然后将数据写入hdfs
将文件里面的都注释掉
写入

a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = syslogtcp
a1.sources.r1.port = 5140
a1.sources.r1.host = 192.168.31.131
a1.sources.r1.channels = c1
# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.path = hdfs://master:9000/flume/syslogtcp
a1.sinks.k1.hdfs.filePrefix = syslog
 
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
#yi bai tiao jiu submit

三、测试

1.启动agent
flume-ng agent --conf ./conf/ -f /home/cms/flume/conf/flume-conf.properties -n a1 -Dflume.root.logger=INFO,console
--conf对于的是flume下的conf目录
-f 对应的是agent配置文件
-n 对于的是agent的名字
2.输入测试数据
打开另一个终端,

echo "hello'\t'word" | nc 192.168.31.131 5140


3.hdfs上查看读取到的数据

四、参考文档

1.官网
2.flume 1.4的介绍及使用示例
3.Flume-ng分布式环境的部署和配置(一)

五、总结

flume 与 spark streaming初探失败
一直报


不知道怎么解决
考虑到一般是用kafka与spark连接,所以暂时放弃

你可能感兴趣的:(Flume搭建测试)