Linux flume安装与配置

背景:

Flume是Cloudera提供的一个高可用的,高可靠的,分布式的海量日志采集、聚合和传输的系统,Flume支持在日志系统中定制各类数据发送方,用于收集数据;同时,Flume提供对数据进行简单处理,并写到各种数据接受方(可定制)的能力。

flume版本: apache-flume-1.5.0.1-bin.tar.gz

一:安装

tar -zxvf apache-flume-1.5.0.1-bin.tar.gz -C /usr/local/flume1.5.1

系统参数配置
vi /etc/profile
export FLUME_HOME=/usr/local/flume1.5.1/
export FLUME_CONF_DIR=/usr/local/flume1.5.1/conf
export PATH=$PATH:$FLUME_HOME/bin
source /etc/profile

二:参数配置

cp flume-conf.properties.template  flume.conf
vi flume.conf

# The configuration file needs to define the sources, 
# the channels and the sinks.
# Sources, channels and sinks are defined per agent, 
# in this case called 'agent'


a1.sources = r1
a1.sinks = k1
a1.channels = c1


# For each one of the sources, the type is defined
a1.sources.r1.type = exec
a1.sources.r1.bind = localhost
a1.sources.r1.port = 5858
a1.sources.r1.shell = /bin/bash -c
a1.sources.r1.command = tail -F /tomcat_app/nohup.out
a1.sources.r1.restartThrottle = 300000
a1.sources.r1.restart = true
a1.sources.r1.logStdErr = false
a1.soources.r1.batchSize = 5


# The channel can be defined as follows.
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
a1.channels.c1.keep-alive = 30
a1.channels.c1.byteCapacityBufferPercentage = 80%
a1.channels.c1.byteCapacity = 1024000000


# Each sink's type must be defined
a1.sinks.k1.type = logger


a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

三:flume启动内存配置

cp flume-env.sh.template flume-env.sh
JAVA_OPTS="-Xms1024m -Xmx1024m -Dcom.sun.management.jmxremote"

四:启动

cd /usr/local/flume1.5.1

nohup bin/flume-ng agent --conf conf --conf-file conf/flume.conf --name a1 -Dflume.root.logger=INFO,console &

五:flume参数配置说明

source

数据的源端,负责产生数据;也可以接收其他程序或者agent发来的数据。目前的已经支持的常用的source包括:

flume支持的source介绍

source

source.type

简介

avro source

avro

提供一个基于avro协议的serverbind到某个端口上,等待
avro协议客户端发过来的消息;一般在agent之间传输数据时,可以配置为avro

thrift source

thrift

同上,不过传输协议为thrift

exec source

exec

执行一个unix command,以其std out作为数据源;
命令可以通过..command配置,如:
tail -f /var/log/mesg。支持对命令或者脚本的自动重启

netcat source

netcat

监控指定端口,每一行作为一个event传输;认为输入的数据为text的,每一行
的数据最大长度可配置(
max-line-length)默认为512

http source

http

支持httppostgetget仅仅用于测试)

scribe source

org.apache.flume.source.scribe.ScribeSource

scribe的兼容

syslog source

syslogtcp
syslogudp

监听syslog,支持tcp或者udp

sequence source

seq

用于测试,自动产生编号自增的数据

spooling directory source

监控某个目录下的所有文件,将其新加入的文件作为数据源传输走;
每传输玩一个文件后,会被rename成其他名字(表示已经传输过)或者删掉;
默认监控目录下的文件具有:immutableuniquely-named属性,否则会出错;

jms source

jms

从消息队列获取数据。active mq


用户也可以自己实现source,继承与类AbstractSource即可。配置时,type配置为类的全称。

channel

channel

type

简介

memory channel

memory

消息放在内存中,提供高吞吐,但不提供可靠性;
可能丢失数据

file channel

file

对数据持久化;但是配置较为麻烦,需要配置数据目录和checkpoint目录;
不同的file channel均需要配置一个checkpoint 目录;
By default the File Channel uses paths for checkpoint
 and data directories that are within the user home 
as specified above. As a result if you have more than 
one File Channel instances active within the agent, 
only one will be able to lock the directories and cause 
the other channel initialization to fail.

jdbc channel

jdbc

内置的derb数据库,对event进行了持久化,提供高可靠性;
看来是取代同样具有持久特性的file channel

sinks

sinks,负责处理source来的数据,常用的如下:

flume支持的sink

type

简介

hdfs sink

hdfs

将数据写到hdfs上;
可以配置目录(支持转义%Y-%m-%d;

logger sink

logger

采用loggerlogger可以配置(可以直接输出到控制台,也可输出到文件);
注意:loggereventbody长度有限制,超过限制会截断;

avro sink

avro

发送给另外一个avrosource(当然也可以不是flumesource,可以是自己
开发的基于avroserver

thift sink

thrift

发送给另外一个thriftsource

IRC sink

irc

Internet Relay Chat

file roll sink

file_roll

本地file,支持rotate(可配置大小、时间、event count来进行rotate);

null sink

null

丢弃,等同于scribenull store

hbase sink

hbase
asynchbase

写到hbase中;需要配置hbasetablecolumnFamily等信息;
比较扯淡的是,到底写入到哪一个hbase,取决于flumeclasspath中碰到的第一个
hbase-site.xml
The Hbase configuration is picked up from the first hbase-site.xml
encountered in the classpath.
asynchbase支持可配置的hbase(配置zookeperznode path

morphline solr sink

org.apache.flume.sink.solr.morphline.MorphlineSolrSink

Solr是一个基于Lucene java库的企业级搜索服务器。
transforms it, and loads it in near-real-time into Apache Solr servers, 
which in turn serve queries to end users or search applications.

elastic search sink

org.apache.flume.sink.elasticsearch.ElasticSearchSink

类似的同上,换成了elasticsearch cluster

custom sink

$FQCN

full qualified class name

 






来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28624388/viewspace-1289937/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28624388/viewspace-1289937/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值