简介
Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统。
Flume是一种分布式、可靠和可用的服务,用于高效地收集、聚合和移动大量日志数据。它具有基于流数据流的简单灵活的体系结构。它具有鲁棒性和容错性,具有可调的可靠性机制和多种故障转移和恢复机制。它使用了一个简单的、可扩展的数据模型,允许在线分析应用程序。

安装配置
(1)下载
http://flume.apache.org/download.html
(2)配置
进入conf目录
1、配置JDK
flume-env.sh(配置JDK环境变量)
2、自定义配置文件
添加a4.conf,配置如下:
①hdfs
进入hadoop安装目录的lib下
拷贝hadoop-common-2.2.0.jar、commons-configuration-1.6.jar、hadoop-auth-2.2.0.jar、hadoop-hdfs-2.2.0.jar 到flume的lib目录下
#定义agent名, source、channel、sink的名称
a4.sources = r1
a4.channels = c1
a4.sinks = k1
#具体定义source 监听的目录
a4.sources.r1.type = spooldir
a4.sources.r1.spoolDir = /home/hadoop/logs
#具体定义channel
a4.channels.c1.type = memory
a4.channels.c1.capacity = 10000
a4.channels.c1.transactionCapacity = 100
#定义拦截器,为消息添加时间戳
a4.sources.r1.interceptors = i1
a4.sources.r1.interceptors.i1.type = org.apache.flume.interceptor.TimestampInterceptor$Builder
#具体定义sink 数据传输到hdfs
a4.sinks.k1.type = hdfs
a4.sinks.k1.hdfs.path = hdfs://ns1/flume/%Y%m%d
a4.sinks.k1.hdfs.filePrefix = events-
a4.sinks.k1.hdfs.fileType = DataStream
#不按照条数生成文件
a4.sinks.k1.hdfs.rollCount = 0
#HDFS上的文件达到128M时生成一个文件
a4.sinks.k1.hdfs.rollSize = 134217728
#HDFS上的文件达到60秒生成一个文件
a4.sinks.k1.hdfs.rollInterval = 60
#组装source、channel、sink
a4.sources.r1.channels = c1
a4.sinks.k1.channel = c1
运行:flume-ng agent -n a4 -c conf -f conf/a4.conf -Dflume.root.logger=INFO,console
②日志文件
#定义agent名, source、channel、sink的名称
a2.sources = r1
a2.channels = c1
a2.sinks = k1
#具体定义source 监听某个log文件
a2.sources.r1.type = exec
a2.sources.r1.command = tail -F /home/hadoop/a.log
#具体定义channel
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100
#具体定义sink 输出到日志
a2.sinks.k1.type = logger
#组装source、channel、sink
a2.sources.r1.channels = c1
a2.sinks.k1.channel = c1
运行:bin/flume-ng agent -n a2 -f /home/hadoop/a2.conf -c conf -Dflume.root.logger=INFO,console
③netcat 192.168.237.131 8888 向flume实时发送数据,输出到日志
#定义agent名, source、channel、sink的名称
a1.sources = r1
a1.channels = c1
a1.sinks = k1
#具体定义source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 8888
#具体定义channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
#具体定义sink
a1.sinks.k1.type = logger
#组装source、channel、sink
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
663

被折叠的 条评论
为什么被折叠?



