通過一個通道將來源和接收器連接讨勤,需要列出源,接收器和通道晨另,為給定的代理悬襟,然后指向源和接收器及通道。一個源的實例可以指定多個通道拯刁,但只能指定一個接收器實例 脊岳。實時日志收集系統(tǒng)。
參考:https://blog.csdn.net/dongdong9223/article/details/81482722
Flume特點
Flume是一個分布式、可靠和高可用的海量日志采集割捅、聚合和傳輸?shù)南到y(tǒng)奶躯。支持在日志系統(tǒng)中定制各類數(shù)據(jù)發(fā)送方,用于收集數(shù)據(jù)亿驾。同時嘹黔,flume提供對數(shù)據(jù)進行簡單處理。并寫到各種數(shù)據(jù)接收方(比如文本莫瞬、HDFS儡蔓、hbase)的能力
Flume 的數(shù)據(jù)流是由Event(事件)貫穿始終的。Event是flume的基本數(shù)據(jù)單位疼邀,攜帶日志數(shù)據(jù)(字節(jié)數(shù)組形成)并且攜帶有頭信息喂江,這些Event由Agent外部的source生成,當(dāng)source捕獲事件后會進行特定的格式化旁振,然后source會把事件推入(單個或多個)Channel中获询。其實可以把Channel看成一個緩沖區(qū),將它將保存事件直到Sink處理完該事件拐袜。Sink負責(zé)持久化日志吉嚣,比如保存到文本、HDFS蹬铺、Hbase等尝哆,這是普通的Data flow model,如圖所示:
當(dāng)然Flume也支持Multiplexing the flow甜攀,也就是多元化的數(shù)據(jù)流较解,將數(shù)據(jù)推向更多的目的地,包括目的地是另一個Source赴邻,如圖所示:
參考wiki 部署:
https://cwiki.apache.org/confluence/display/FLUME/Getting+Started#space-menu-link-content
實例測試
使用arvo引入數(shù)據(jù)源
將文件寫入一個文本文件里印衔,使用arvo將其引入到source中。
新建agent配置文件
conf/flume.conf
配置如下:
agent1.sources = avro-source1
agent1.channels = ch1
agent1.sinks = log-sink1
# For each one of the sources, the type is defined
agent1.sources.avro-source1.type = avro
# The channel can be defined as follows.
agent1.sources.avro-source1.channels = ch1
agent1.sources.avro-source1.bind = 0.0.0.0
agent1.sources.avro-source1.port = 41414
# Each sink's type must be defined
agent1.sinks.log-sink1.type = logger
#Specify the channel the sink should use
agent1.sinks.log-sink1.channel = ch1
# Each channel's type is defined.
agent1.channels.ch1.type = memory
# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
agent1.channels.ch1.capacity = 100
新建文件并寫入內(nèi)容
echo 'Hello world2!' > ./test/log.00
啟動agent
bin/flume-ng agent --conf ./conf/ -f conf/flume.conf -Dflume.root.logger=INFO,console -n agent1
使用arvo-client發(fā)送文件
./bin/flume-ng avro-client -H localhost -p 41414 -F ../test/log.00
在agent終端輸出
其他相關(guān)案例可參考:
https://www.cnblogs.com/itdyb/p/6266789.html