---
title: "flume ng arc and configuration"
author: "ilnba"
date: "2013-03-22T16:11:09Z"
tags: []
categories: ["开源软件"]
slug: "flume-ng-arc-and-configuration"
draft: false
lastmod: "2013-03-22T16:12:37Z"
id: 1834917
url: "https://ilnba.iteye.com/blog/1834917"
---

Please ref flume user guide first

[http://flume.apache.org/FlumeUserGuide.html](http://flume.apache.org/FlumeUserGuide.html)

And the Cloudera flume blogs

[http://blog.cloudera.com/blog/category/flume/](http://blog.cloudera.com/blog/category/flume/)

 

**How to define JAVA\_HOME, java options and add our customized lib into flume-ng.**

All these information will be defined in FLUME\_CONFI\_DIR/flume-env.sh

Example like below.

JAVA\_HOME=/opt/java 

JAVA\_OPTS="-Xms200m -Xmx200m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=3669 -Dflume.called.from.service" 

FLUME\_CLASSPATH=/opt/sponge/flume/lib/*

 

**How start flume-ng as agent**

Please note we should name the flume collector name to hostname\_agent and this name will be used in the flume-conf-agent.properties

$/usr/lib/flume/bin/flume-ng agent --conf /opt/sponge/flume/config/   --conf-file /opt/sponge/flume/conf/flume-conf-agent.properties  --name hostname\_agent &

 

**How to start flume-en as collector**

Please note we should name the flume collector name to hostname\_collector and this name will be used in the flume-conf-collector.properties

     $/usr/lib/flume/bin/flume-ng agent --conf /opt/sponge/flume/config/   --conf-file /opt/sponge/flume/conf/flume-conf-collector.properties  --name hostname\_collector &

 

**How to define the flume agent and flume collector property file.**

I’ve already committed 2 different property files to https://svn.nam.nsroot.net:9050/svn/153299/elf/sponge-branches/2013-03-14-FlumeNG/sponge/myflumeng/config

Please ref flume-conf-agent.properties and flume-conf-collector.properties.

The basic name convention are

1)each agent name will be set as hostname\_agent

2)each collector name will be set as hostname\_collector

3)the source names will be source1, source2,source3…..

4)the sink name will be avroSink1, avroSink2, avroSink3….

5)each sink’s interceptor will be set as interceptor1, interceptor2, interceptor3 ….

6)all agent sinks will be AVRO sink.

7)the default collector source is AVRO source

8)agent sinks are load balanced as round robin

9)file channel is default for both agent and collector

 

**flume-conf-agent.properties**

hostname\_agent.sources = source1, source2

hostname\_agent.channels = fileChannel

hostname\_agent.sinks = avroSink1, avroSink2

 

\# For each one of the sources, the type is defined

hostname\_agent.sources.source1.type = exec

hostname\_agent.sources.source1.command = tail -F /var/log/audit/audit.log

hostname\_agent.sources.source1.channels = fileChannel

hostname\_agent.sources.source1.batchSize=10

 

hostname\_agent.sources.source2.type = exec

hostname\_agent.sources.source2.command = tail -F /var/log/flume/flume.log

hostname\_agent.sources.source2.channels = fileChannel

hostname\_agent.sources.source2.batchSize=10

 

\# For each one of the sources, the log interceptor is defined

hostname\_agent.sources.source1.interceptors = logIntercept1

hostname\_agent.sources.source1.interceptors.logIntercept1.type = com.citi.sponge.flume.sink.LogInterceptor$Builder

hostname\_agent.sources.source1.interceptors.logIntercept1.preserveExisting = false

hostname\_agent.sources.source1.interceptors.logIntercept1.hostName = hostname

hostname\_agent.sources.source1.interceptors.logIntercept1.env = PROD

hostname\_agent.sources.source1.interceptors.logIntercept1.logType = AUDIT\_LOG

hostname\_agent.sources.source1.interceptors.logIntercept1.appId = 111111

hostname\_agent.sources.source1.interceptors.logIntercept1.logFilePath = /var/log/audit

hostname\_agent.sources.source1.interceptors.logIntercept1.logFileName = audit.log

  

hostname\_agent.sources.source2.interceptors = logIntercept2

hostname\_agent.sources.source2.interceptors.logIntercept2.type = com.citi.sponge.flume.sink.LogInterceptor$Builder

hostname\_agent.sources.source2.interceptors.logIntercept2.preserveExisting = false

hostname\_agent.sources.source2.interceptors.logIntercept2.hostName = hostname

hostname\_agent.sources.source2.interceptors.logIntercept2.env = PROD

hostname\_agent.sources.source2.interceptors.logIntercept2.logType = FLUME

hostname\_agent.sources.source2.interceptors.logIntercept2.appId = 111111

hostname\_agent.sources.source2.interceptors.logIntercept2.logFilePath = /var/log/flume

hostname\_agent.sources.source2.interceptors.logIntercept2.logFileName = flume.log

 

 

#for each of the sink, type is defined

hostname\_agent.sinks.avroSink1.type = avro

hostname\_agent.sinks.avroSink1.hostname=collector1

hostname\_agent.sinks.avroSink1.port=1442

hostname\_agent.sinks.avroSink1.batchSize=10 

hostname\_agent.sinks.avroSink1.channel = fileChannel 

 

hostname\_agent.sinks.avroSink2.type = avro

hostname\_agent.sinks.avroSink2.hostname=collector2

hostname\_agent.sinks.avroSink2.port=1442

hostname\_agent.sinks.avroSink2.batchSize=10 

hostname\_agent.sinks.avroSink2.channel = fileChannel 

 

 

#Specify the load balance configurations for sinks

agent.sinkgroups = sinkGroup

agent.sinkgroups.sinkGroup.sinks = avroSink1 avroSink2

agent.sinkgroups.sinkGroup.processor.type = load\_balance

agent.sinkgroups.sinkGroup.processor.backoff = true

agent.sinkgroups.sinkGroup.processor.selector = round\_robin

agent.sinkgroups.sinkGroup.processor.selector.maxBackoffMillis=30000

 

 

\# Each channel's type is defined.

hostname\_agent.channels.fileChannel.type = file

hostname\_agent.channels.fileChannel.checkpointDir = /opt/sponge/file-channel/checkpoint

hostname\_agent.channels.fileChannel.dataDirs = /opt/sponge/file-channel/dataDirs

hostname\_agent.channels.fileChannel.transactionCapacity = 1000

hostname\_agent.channels.fileChannel.checkpointInterval = 30000

hostname\_agent.channels.fileChannel.maxFileSize = 2146435071

hostname\_agent.channels.fileChannel.minimumRequiredSpace = 524288000

hostname\_agent.channels.fileChannel.keep-alive = 5

hostname\_agent.channels.fileChannel.write-timeout = 5

hostname\_agent.channels.fileChannel.checkpoint-timeout = 600

 

**flume-collector.properties**

hostname\_collector.sources = source

hostname\_collector.channels = fileChannel

hostname\_collector.sinks = hbaseSink

 

 

\# For each one of the sources, the type is defined

hostname\_collector.sources.avroSource.channels = fileChannel

hostname\_collector.sources.avroSource.type = avro

hostname\_collector.sources.avroSource.bind = hostname

hostname\_collector.sources.avroSource.port = 1442 

 

hostname\_collector.sinks.hbaseSink.type=org.apache.flume.sink.hbase.HBaseSink

hostname\_collector.sinks.hbaseSink.table=spong\_flumeng\_log2

hostname\_collector.sinks.hbaseSink.columnFamily=content

hostname\_collector.sinks.hbaseSink.serializer=com.citi.sponge.flume.sink.LogHbaseEventSerializer

hostname\_collector.sinks.hbaseSink.timeout=120

hostname\_collector.sinks.hbaseSink.column=log

hostname\_collector.sinks.hbaseSink.batchSize=2

hostname\_collector.sinks.hbaseSink.channel=fileChannel

 

 

\# Each channel's type is defined.

hostname\_collector.channels.fileChannel.type = file

hostname\_collector.channels.fileChannel.checkpointDir = /opt/sponge/file-channel/checkpoint

hostname\_collector.channels.fileChannel.dataDirs = /opt/sponge/file-channel/dataDirs

hostname\_collector.channels.fileChannel.transactionCapacity = 1000

hostname\_collector.channels.fileChannel.checkpointInterval = 30000

hostname\_collector.channels.fileChannel.maxFileSize = 2146435071

hostname\_collector.channels.fileChannel.minimumRequiredSpace = 524288000

hostname\_collector.channels.fileChannel.keep-alive = 5

hostname\_collector.channels.fileChannel.write-timeout = 5

hostname\_collector.channels.fileChannel.checkpoint-timeout = 600