標籤:採集 檔案 add address connect roo local ted log
一、日誌採集:從網路連接埠接收資料,下沉到logger
檔案netcat-logger.conf:
1 # Name the components on this agent 2 #給那三個組件取個名字 3 a1.sources = r1 4 a1.sinks = k1 5 a1.channels = c1 6 7 # Describe/configure the source 8 #類型, 從網路連接埠接收資料,在本機啟動, 所以localhost, type=spoolDir採集目錄源,目錄裡有就采 9 a1.sources.r1.type = netcat10 a1.sources.r1.bind = localhost11 a1.sources.r1.port = 4444412 13 # Describe the sink14 a1.sinks.k1.type = logger15 16 # Use a channel which buffers events in memory17 #下沉的時候是一批一批的, 下沉的時候是一個個eventChannel參數解釋:18 #capacity:預設該通道中最大的可以儲存的event數量19 #trasactionCapacity:每次最大可以從source中拿到或者送到sink中的event數量20 a1.channels.c1.type = memory21 a1.channels.c1.capacity = 100022 a1.channels.c1.transactionCapacity = 10023 24 # Bind the source and sink to the channel25 a1.sources.r1.channels = c126 a1.sinks.k1.channel = c1
啟動命令:
#告訴flum啟動一個agent,指定配置參數, --name:agent的名字,
flume-ng agent --conf conf --conf-file conf/netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console
傳入資料:
[[email protected] ~]# telnet localhost 44444Trying ::1...telnet: connect to address ::1: Connection refusedTrying 127.0.0.1...Connected to localhost.Escape character is ‘^]‘.hello world!^H^H^H^H^H^H^H^H^H^H^H^H^H^HOKtianjun2012!OK
控制台看到的資料
2017-05-08 13:41:35,766 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:94)] Event: { headers:{} body: 68 65 6C 6C 6F 20 77 6F 72 6C 64 21 08 08 08 08 hello world!.... }2017-05-08 13:41:40,153 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:94)] Event: { headers:{} body: 74 69 61 6E 6A 75 6E 32 30 31 32 21 0D tianjun2012!. }
Flume總結(1)