download
Fromhttp://flume.apache.org/download.htmlDownload binary version
Installation
tar zvxf apache-flume-1.6.0-bin.tar.gz
directory structure
-
Bin-contains startup scripts
-
Conf-Contains Profile Templates
-
Docs-include documents
-
Lib-dependent jar package
-
Tools-Implementation with log4j appender
Configuration file structure
1) Main structure
2) Top layer
<agent-name>.sources=<source> <source>
<agent-name>.channels=<channel> <channel>
<agent-name>.sinks=<sink> <sink>
3) bottom layer
<agent-name>.<component-type>.<component-name>.<configuration-parameter>=<value>
4) instance single-node-demo.properties
a1.sources=src1
a1.sinks=sink1
a1.channels=ch1
# Configure the source
a1.sources.src1.type=netcat
a1.sources.src1.bind=localhost
a1.sources.src1.port=51000
# Sink Configuration
a1.sinks.sink1.type=logger
# Channel configuration
a1.channels.ch1.type=memory
a1.channels.ch1.capacity=1000
a1.channels.ch1.transactionCapacity=100
# Link stuff together
a1.sources.src1.channels=ch1
a1.sinks.sink1.channel=ch1
Start agent
$bin/flume-ng agent
--conf-file conf/single-node-demo.properties
--name a1
--conf ./conf/
-Dflume.root.logger=INFO,console
It can also be abbreviated as
bin/flume-ng agent
-c conf/single-node-demo.properties
-n a1
-f ./conf/
-Dflume.root.logger=INFO,console
-
-c is equivalent to –conf-file
-
-f is equivalent to –conf
-
-n is equivalent to –name.
Netcat sends a message
nc localhost 51000
hello
OK
world
OK
Look at flume’s output
2016-01-12 22:11:20,603 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:94)] Event: { headers:{} body: 68 65 6C 6C 6F hello }
2016-01-12 22:11:20,603 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:94)] Event: { headers:{} body: 77 6F 72 6C 64 world }