1.寫配置文件
(1)配置Source
(2)配置Channel
(3)配置Sink
(4)串聯三個組件
a1:agent的名稱
r1:source的名稱
k1:sink的名稱
c1:channel的名稱
#agent的定義
a1.sources = r1
a1.sinks=k1
a1.channels=c1
#描述、配置source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
#描述sink
a1.sinks.k1.type = logger
#配置channel
a1.channels.c1.type = memory
#串聯三個組件
a1.sources.r1.channels=c1
a1.sinks.k1.channel=c1
寫入example.conf中
2.啓動agent
$ bin/flume-ng agent --name a1 \ # agent 的名稱
--conf $FLUME_HOME/conf \ # 指定conf路徑
--conf-file $FLUME_HOME/conf/example.conf \ #指定自己寫的配置文件路徑
-Dflume.root.logger=INFO,console # 將信息打印在控制檯上
3.使用telnet進行測試,telnet localhost 44444
輸入hello world,在控制檯上就會顯示
Event是Flume數據傳輸的基本單元
Event= 可選的header+byte array