大数据处理工具1——Flume安装及使用

大数据处理工具1——Flume安装及使用

序言:最近在做一个商业数据分析系统,用到了一些工具,把使用过程记录一下。

          flume-1.7.0  +  Ubuntu 14.04.1 LTS  +  java-7-openjdk-amd64 + hadoop-2.6.0

一、下载解压

    官网:http://flume.apache.org/

    进入点击Download下的 apache-flume-1.7.0-bin.tar.gz  (不是下载src文件)

    解压:tar -zxvf apache-flume-1.7.0-bin.tar.gz


二、配置Java环境变量

    1.进入解压后的Flume文件夹

    2.修改 flume-env.sh 配置文件,主要是JAVA_HOME变量设置

      # cp conf/flume-env.sh.template conf/flume-env.sh

      # vim  conf/flume-env.sh

      在末尾追加:JAVA_HOME=/usr/lib/jvm/java-7-oracle(这里为本机的Java位置)


三、编写配置文件

    在conf中创建文件filetest-conf.properties,这里就是配置文件,包含很多种。

    这里我使用Spool监测配置的目录下新增的文件,并将文件中的数据读取出来存入HDFS

 
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/apache-tomcat-8.5.15/wifiData
a1.sources.r1.deletePolicy = immediate
 
# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.path = hdfs://master:55555/flume/input
a1.sinks.k1.hdfs.fileType = DataStream 
a1.sinks.k1.hdfs.writeFormat = Text
a1.sinks.k1.hdfs.rollSize = 20480
a1.sinks.k1.hdfs.filePrefix = data
a1.sinks.k1.hdfs.rollInterval = 1
#a1.sinks.k1.hdfs.idleTimeout = 1
 
# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 1000
 

四、运行

在Flume的conf文件夹下:

# ../bin/flume-ng agent -c . -f filetest-conf.properties -n a1 -Dflume.root.logger=INFO,console


五、记录一下遇到的问题:

flume传一个文件变成了多个
flume-ng 写入hdfs上后出现一个文件被分割了很多个小文件在hdfs上:
http://wenda.chinahadoop.cn/question/991
http://blog.sina.com.cn/s/blog_40d46ec20102wnz7.html
配置文件agent1.sinks.log-sink1.hdfs.rollSize = 102400000
这个就是文件大小

Flume中的HDFS Sink配置参数说明:
http://blog.sina.com.cn/s/blog_40d46ec20102wnz7.html
删除使用完的文件
agent.sources.apool.deletePolicy = immediate

六、介绍一些我当时使用的网址:

http://corejava2008.iteye.com/blog/2218123
http://www.aboutyun.com/thread-8917-1-1.html
http://www.cnblogs.com/yimiao/p/6125076.html
http://blog.csdn.net/strongyoung88/article/category/6502486
https://www.iteblog.com/archives/1034.html
HTTPSourceHandler 解析:
http://blog.csdn.net/fengyedeyanlei/article/details/52816637
http://www.aboutyun.com/thread-8917-1-1.html


你可能感兴趣的:(大数据)