1.netcat和exec source方式

1.使用官方的組件, 搭配一個 從 netcat source -> memory channel -> logger sink 的 demo

啓動agent:

]# ./bin/flume-ng agent --conf conf --conf-file ./conf/1.flume_netcat.conf --name a1 -Dflume.root.logger=INFO,console

發數據:

]# telnet master 44444

flume_netcat.conf文件內容如下

a1.sources = r1

a1.sinks = k1

a1.channels = c1

 

# Describe/configure the source

a1.sources.r1.type = netcat

a1.sources.r1.bind = master

a1.sources.r1.port = 44444

 

# 定義sink,輸出到logger日誌中

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

2.使用官方的組件, 搭配一個 從 exec source -> memory channel -> logger sink 的 demo

啓動agent:

]# ./bin/flume-ng agent --conf conf --conf-file ./conf/2.flume_exec.conf --name a1 -Dflume.root.logger=INFO,console

tail -f /root/Data/10.flume-lt/test_data/1.log監控文件,有新內容就採集

發數據:

]# echo 'abcabc123' >> 1.log

2.flume_exec.conf 配置文件內容:

# Name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1

 

# Describe/configure the source

a1.sources.r1.type = exec

a1.sources.r1.command = tail -f /root/Data/10.flume-lt/test_data/1.log

 

# 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章