0. 前言

本說明使用國網中心(nchc) 台灣杉(taiwania) 資源服務

1.安裝方式

此軟體不需要root權限,解壓縮檔案之後,執行程式與其搭配的設定檔,即可常駐一個專門在處理extract-load 的agent service。

  • 下載

wget http://www.apache.org/dyn/closer.lua/flume/1.8.0/apache-flume-1.8.0-bin.tar.gz

tar -zxvf apache-flume-1.8.0-bin.tar.gz

mv apache-flume* flume

cd flumg

2. 使用方式

撰寫一個flume.conf ,放在 conf/flume.conf

FileAgent.sources = tail
FileAgent.channels = Channel-2
FileAgent.sinks = HDFS
FileAgent.sources.tail.type = exec
FileAgent.sources.tail.command = tail -F /home/dataflair/access.log
FileAgent.sources.tail.channels = Channel-2
FileAgent.sinks.HDFS.type = hdfs
FileAgent.sinks.HDFS.hdfs.path = hdfs://localhost:9000/flume
FileAgent.sinks.HDFS.hdfs.fileType = DataStream
FileAgent.sinks.HDFS.channel = Channel-2
FileAgent.channels.Channel-2.type = memory

輸入指令將產生一個名稱為 FileAgent的 flume agent ,設定檔為 conf/flume.conf ,

bin/flume-ng agent --conf ./conf/ -f conf/flume.conf -n FileAgent

這個範例將會把 /home/dataflair/access.log 新append 的資料,傳到 hadoop HDFS

hdfs://localhost:9000/flume 中。

ps:要送到 hdfs 中,系統需要安裝 hadoop 。

3. 更多用法

更多 flume 用法,可以參考 以下連結

  • flume 官方使用教學

https://flume.apache.org/FlumeUserGuide.html

  • data flair 的教學,較淺白易懂

https://data-flair.training/blogs/apache-flume-installation-tutorial/

results matching ""

    No results matching ""