ITPub博客

首页 > 应用开发 > IT综合 > Linux flume安装与配置

Linux flume安装与配置

原创 IT综合 作者:百联达 时间:2014-10-06 11:43:10 0 删除 编辑
背景:

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协议的server,bind到某个端口上,等待
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

支持http的post和get(get仅仅用于测试)

scribe source

org.apache.flume.source.scribe.ScribeSource

对scribe的兼容

syslog source

syslogtcp
syslogudp

监听syslog,支持tcp或者udp;

sequence source

seq

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

spooling directory source

监控某个目录下的所有文件,将其新加入的文件作为数据源传输走;
每传输玩一个文件后,会被rename成其他名字(表示已经传输过)或者删掉;
默认监控目录下的文件具有:immutable、uniquely-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

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

avro sink

avro

发送给另外一个avro的source(当然也可以不是flume的source,可以是自己
开发的基于avro的server)

thift sink

thrift

发送给另外一个thrift的source

IRC sink

irc

Internet Relay Chat

file roll sink

file_roll

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

null sink

null

丢弃,等同于scribe的null store

hbase sink

hbase
asynchbase

写到hbase中;需要配置hbase的table,columnFamily等信息;
比较扯淡的是,到底写入到哪一个hbase,取决于flume的classpath中碰到的第一个
hbase-site.xml
;
The Hbase configuration is picked up from the first hbase-site.xml
encountered in the classpath.
asynchbase支持可配置的hbase(配置zookeper,znode 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博客 ” ,链接:https://blog.itpub.net/28624388/viewspace-1289937/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Redis 主从配置
请登录后发表评论 登录
全部评论
15年以上互联网经验,先后从事过制造业,证券业,物业行业和物流行业信息系统和互联网产品的设计落地实施,8年系统架构经验。最近关注企业数字化转型、财务数字化服务共享、大语言模型、Kubernetes微服务架构和Istio微服务治理框架。

注册时间:2013-02-05

  • 博文量
    332
  • 访问量
    1265622