flume-ng安裝、配置和使用
flume中文手冊
http://www.tuicool.com/articles/q2umQb
用戶手冊
http://flume.apache.org/FlumeUserGuide.html
一、背景說明:
Flume是apache基金會下的一個分佈式、可靠、和高可用的海量日誌聚合的系統,支持在系統中定製各類數據發送方,用於收集數據;同時,Flume提供對數據進行簡單處理,並寫到各種數據接受方(可定製)的能力。
一、安裝:
# wget http://mirror.bit.edu.cn/apache/flume/1.4.0/apache-flume-1.4.0-bin.tar.gz
# tar -zxvf apache-flume-1.4.0-bin.tar.gz
# mv apache-flume-1.4.0-bin /usr/local/flume-1.4.0
# vi /etc/profile //在該文件中添加 FLUME_HOME=/usr/local/flume-1.4.0 變量,並將 $FLUME_HOME/bin 添加到PATH變量中
# source /etc/profile
二、配置,參考官網https://cwiki.apache.org/confluence/display/FLUME/Getting+Started 的 Configuration 塊的說明,裏邊已經說得非常詳細
啓動
bin/flume-ng agent --conf ./conf/ -f conf/flume.conf -Dflume.root.logger=DEBUG,console -n agent1 &
三、使用:
# cd $FLUME_HOME
# ./bin/flume-ng agent -n access_log -c conf -f conf/access_log_kafka.properties -Dflume.root.logger=DEBUG,console
參考資料:
1、官網wiki: https://cwiki.apache.org/confluence/display/FLUME/Getting+Started
2、官網:http://flume.apache.org/
Flume是一個分佈式、可靠、和高可用的海量日誌聚合的系統,支持在系統中定製各類數據發送方,用於收集數據;同時,Flume提供對數據進行簡單處理,並寫到各種數據接受方(可定製)的能力。
用戶可以根據需要添加自己的agent,collector或者storage。此外,Flume自帶了很多組件,包括各種agent(file, syslog等),collector和storage(file,HDFS等)。
(1) agent
agent的作用是將數據源的數據發送給collector。
Flume自帶了很多直接可用的數據源(source),如:
text(“filename”):將文件filename作爲數據源,按行發送
tail(“filename”):探測filename新產生的數據,按行發送出去
fsyslogTcp(5140):監聽TCP的5140端口,並且接收到的數據發送出去
tailDir("dirname"[, fileregex=".*"[, startFromEnd=false[, recurseDepth=0]]]):監聽目錄中的文件末尾,使用正則去選定需要監聽的文件(不包含目錄),recurseDepth爲遞歸監聽其下子目錄的深度
更多可參見這位朋友的整理:http://www.cnblogs.com/zhangmiao-chp/archive/2011/05/18/2050465.html
同時提供了很多sink,如:
console[("format")] :直接將將數據顯示在consolr上
text(“txtfile”):將數據寫到文件txtfile中
dfs(“dfsfile”):將數據寫到HDFS上的dfsfile文件中
syslogTcp(“host”,port):將數據通過TCP傳遞給host節點
agentSink[("machine"[,port])]:等價於agentE2ESink,如果省略,machine參數,默認使用flume.collector.event.host與flume.collector.event.port作爲默認collecotr
agentDFOSink[("machine" [,port])]:本地熱備agent,agent發現collector節點故障後,不斷檢查collector的存活狀態以便重新發送event,在此間產生的數據將緩存到本地磁盤中
agentBESink[("machine"[,port])]:不負責的agent,如果collector故障,將不做任何處理,它發送的數據也將被直接丟棄
agentE2EChain:指定多個collector提高可用性。 當向主collector發送event失效後,轉向第二個collector發送,當所有的collector失敗後,它會非常執着的再來一遍
更多可參見這位朋友的整理:http://www.cnblogs.com/zhangmiao-chp/archive/2011/05/18/2050472.html
(2) collector
collector的作用是將多個agent的數據彙總後,加載到storage中。
它的source和sink與agent類似。
數據源(source),如:
collectorSource[(port)]:Collector source,監聽端口匯聚數據
autoCollectorSource:通過master協調物理節點自動匯聚數據
logicalSource:邏輯source,由master分配端口並監聽rpcSink
sink,如:
collectorSink( "fsdir","fsfileprefix",rollmillis):collectorSink,數據通過collector匯聚之後發送到hdfs, fsdir 是hdfs目錄,fsfileprefix爲文件前綴碼
customdfs("hdfspath"[, "format"]):自定義格式dfs
(3) storage
storage是存儲系統,可以是一個普通file,也可以是HDFS,HIVE,HBase,分佈式存儲等。
(4) Master
Master是管理協調agent和collector的配置等信息,是flume集羣的控制器。