大資料系列之Flume 一

2021-09-14 03:41:03 字數 1854 閱讀 2578

flume是乙個分布式的高可靠,可擴充套件的資料採集框架,在大資料工程中我們常常需要日誌進行分析獲取商業價值而flume就是採集多個不同的資料來源,交給資料處理程式同一執行。

flume event:乙個資料集,是flume傳輸資料的基本單位

source:接收來自外部的flume event,有很多不同的型別

channel:儲存flume event直到被sink消耗

sink:消耗channel中的flume event,並將其儲存在外部裝置中或者傳送給另乙個agent,也有很多不同的型別。

乙個agent由source,sink,channel三部分組成,source可接受外部資料來源或另乙個agent的sink,sink可向另乙個agent的source或外部儲存系統傳遞資料如hdfs。

兩個agent之間的傳輸

多個agent的合併

乙個agent設定多個channel,不同channel向不同地方傳遞資料
由上面我們知道flume的核心就是接收哪的資料和向哪傳輸資料,而這些資訊就寫在flume的配置檔案中,因此使用flume的核心就是配置檔案的書寫

conf下的lume-conf.properties.template檔案

# name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1

# describe/configure the source

a1.sources.r1.type = netcat

a1.sources.r1.bind = localhost

a1.sources.r1.port = 44444

# describe the sink

a1.sinks.k1.type = logger

# use a channel which buffers events in memory

a1.channels.c1.type = memory

# bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

可以看到配置分為兩步,分別定義agent的sink,source,channel型別,將sink,source,channel三個元件串連起來。使用的效果就是控制台(logger)實時輸出netcat輸入的資訊。

啟動命令:

$ bin/flume-ng agent -n $agent_name -c conf -f conf/flume-conf.properties.template
至此flume的基本流程我們已經清楚,實際開發中我們要根據具體需求選擇flume的架構以及各個flume source和sink的型別。

flume官方文件

大資料Flume特性

重要元件 1 channelselector channelselector 的作用就是選出 event 將要被發往哪個 channel。其共有兩種型別,分別是 replicating 複製 和 multiplexing 多路復用 replicatingselector 會將同乙個 event 發往...

大資料技術之Flume安裝記錄

202003 05這個還沒有安裝 將rpm軟體包 xinetd 2.3.14 40.el6.x86 64.rpm telnet 0.17 48.el6.x86 64.rpm和telnet server 0.17 48.el6.x86 64.rpm 拷入 opt software資料夾下面。執行rpm...

大資料技術之Flume(監控埠資料)

目標 flume監控一端console,另一端console傳送訊息,使被監控端實時顯示。分步實現 1 安裝telnet工具 2 建立flume agent配置檔案flume telnet.conf 定義agent a1.sources r1 a1.sinks k1 a1.channels c1 定...