1.安裝
Java 安裝
Flume配置文件解析
Flume Agent啟動(dòng)
(1)Flume 配置文件(Agent的配置)主要包括以下四部分配置:
--》Agent 連接的Source 段磨、Sink、Channel名稱配置镇防;
--》Agent Source 的相關(guān)配置;
--》Agent Sink 的相關(guān)配置凹蜈;
--》Agent Channel 的相關(guān)配置
其中,在Source 和 Sink 中可以配置序列化器(Serializer)來訂制序列化方式,可以配置攔截器(Interceptor )來過濾指定的數(shù)據(jù)
(2)啟動(dòng)步驟:
--》解壓apache-flume-1.6.0-bin.tar.gz到指定目錄 池颈;
--》配置flume-conf.properties 文件怀薛;
--》使用如下命令啟動(dòng)Flume Agent:
bin/flume-ng agent --conf ./conf/ -f conf/flume-conf.properties -Dflume.root.logger=INFO,console -n a1 &
(3)下載flume1.6.0
http://shinyfeather.com/flume/1.6.0/apache-flume-1.6.0-bin.tar.gz
2.flume 配置文件
# example.conf: A single-node Flume configuration
# Name the components on this agent
#a1是agent的名字刺彩,r1,k1,c1也是名字
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
#綁定的數(shù)據(jù)源的類型
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
# Describe the sink
#輸出源的類型
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
#channel選擇存儲(chǔ)在內(nèi)存隊(duì)列里面
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
啟動(dòng)
./bin/flume-ng agent --conf ./conf/ -f conf/flume-conf.properties -Dflume.root.logger=INFO,console -n a1 &
發(fā)送數(shù)據(jù)
$ telnet localhost 44444
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Hello world! <ENTER>
OK
展示
12/06/19 15:32:19 INFO source.NetcatSource: Source starting
12/06/19 15:32:19 INFO source.NetcatSource: Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/127.0.0.1:44444]
12/06/19 15:32:34 INFO sink.LoggerSink: Event: { headers:{} body: 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 0D Hello world!. }