1. 程式人生 > >Flume實戰案例一,從指定網路埠採集資料輸出到控制檯

Flume實戰案例一,從指定網路埠採集資料輸出到控制檯

flume新建任務就是在寫配置檔案

配置example.conf

  在conf下新建檔案example.conf

  加入

# example.conf: A single-node Flume configuration
需要配置agent a1
source r1
channel k1
sinks c1
然後將source,channel,sinks關聯起來
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
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
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

5.啟動agent

flume-ng agent --name a1 --conf $FLUME_HOME/conf  --conf-file $FLUME_HOME/conf/example.conf -Dflume.root.logger=INFO.console

6.Flume監聽一個埠

a1.sources.r1.bind = localhost

a1.sources.r1.port = 44444

所以監聽的是本地的44444埠,

新開一個本地視窗telnet localhost 44444 之後輸入資訊之後 flume就可以打印出來資訊了(-Dflume.root.logger配置的是在控制檯輸出資訊)