flume

數(shù)據(jù)(日志)采集

數(shù)據(jù)從A服務(wù)器到B服務(wù)器?

簡單方式:

1)數(shù)據(jù)量小 ?命令 scp xxx

2)開發(fā)java/python代碼 實(shí)現(xiàn)日志收集,還需要寫監(jiān)控健壯性的代碼,麻煩

缺點(diǎn):場景變了,代碼需要改寫;監(jiān)控代碼

3)一般自己寫的代碼適合場景比較單一。

flume能實(shí)現(xiàn)的是:

把A服務(wù)器的數(shù)據(jù)收集到B,只需通過配置文件就可以了。


Flume的版本:

Flume OG 0.9

FLume NG 1.x(工作中使用的版本)

版本:flume-ng-1.5.0-cdh5.2.0.tar


Flume的組成:

sqoop,azkaban,kafka,flume--小工具,具體場景下還需研究

flume:Flume is a distributed, reliable, and available service for efficiently collecting, aggregating, and moving large amounts of log data.

flume是分布式高可用有效收集、聚合、移動大量日志數(shù)據(jù)的服務(wù)。

It uses a simple extensible data model that allows for online analytic application.

它使用一個簡單可擴(kuò)展的數(shù)據(jù)模型使得在線分析應(yīng)用程序可以被支持。

Flume的組成

Flume只有一個角色:Agent,類似于kafka中broker

Agent有三個部分:

source:用來采集數(shù)據(jù)(類似于kafka中producer)并發(fā)送數(shù)據(jù)到channel

sink:從channel中獲取數(shù)據(jù),并向HDFS寫數(shù)據(jù)

channel:信道,連接source和sink


flume集群

In order to flow the data across multiple agents or hops, the sink of the previous agent and source of the current hop need to be avro type with the sink pointing to the hostname (or IP address) and port of the source.

A very common scenario in log collection is a large number of log producing clients sending data to a few consumer agents that are attached to the storage subsystem. For example, logs collected from hundreds of web servers sent to a dozen of agents that write to HDFS cluster.


多臺flume收集數(shù)據(jù)并整合

This can be achieved in Flume by configuring a number of first tier agents with an avro sink, all pointing to an avro source of single agent (Again you could use the thrift sources/sinks/clients in such a scenario). This source on the second tier agent consolidates the received events into a single channel which is consumed by a sink to its final destination.


案例一:


flume業(yè)務(wù)場景下的配置和使用

具備監(jiān)控目錄功能的source:spooling dirctory

可以將數(shù)據(jù)展示在屏幕上的sink

配置文件后綴必須是properties

1、定義角色 a1 ?a1.sources ?a1.channels a1.sinks

2、配置一個spooldir類型的source

固定格式:a1.sources.r1.type=spooldir

3、配置channels

4、配置sink

首先配置logger sink 指定打印日志級別為打印到控制臺

5、組合三部分之間的關(guān)系

連接條件:channels channel?


運(yùn)行flume

bin/flume-ng agent --conf conf --conf-file conf/spooldir.properties --name a1 -Dflume.root.logger=INFO,console

--conf-file:指定我們的properties配置文件

--name a1:配置文件中的agent的名字

-Dflume.root.logger=INFO,console :表示打印到控制臺


問題:為什么有一個agent分為三個部分?

因?yàn)榉譃槿齻€部分,可以實(shí)現(xiàn)隨機(jī)組合。

比如:source可以監(jiān)控各種目錄

sink可以輸出數(shù)據(jù)到各種平臺

channel可以是內(nèi)存,也可以是磁盤


需求2:查看tomcat.log中最新的日志

tail -f tomcat.log

于是有exec source

必配三個參數(shù)

type:exec?

command :tail -F ?/home/hadoop/flume1705/tomcat.log

channel--配在最后

sink

type :hdfs

hdfs.path ? ? ?/bigdata/%y-%m-%d/%H%M

hdfs.filePrefix=aura-

目錄是否回滾:以下配置表示每10分鐘回滾一次

回滾即每個一段時間會合并和刪除一些日志。

hdfs.round=true?

hdfs.roundValue=10

hdfs.roundUnit=minute

每隔10分鐘新產(chǎn)生一個目錄,以時間結(jié)尾的目錄


回滾文件參數(shù)說明

hdfs.useLocalTimeStamp=true 使用本機(jī)時間

hdfs.fileType=DataStream 數(shù)據(jù)流


exec source的運(yùn)用

tail -F:關(guān)心的是文件名

tail -f:關(guān)心的是文件獨(dú)一無二的id號

日志回滾時文件id號不變,只是文件名的后綴時間變了,因此必須用tail -F

運(yùn)行

bin/flume-ng agent --conf conf --conf-file conf/tailcat.properties --name a1 -Dflume.root.logger=INFO,console


數(shù)據(jù)倉庫的分層

ODS DM DW


一個項(xiàng)目中所用技術(shù)和場合
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 博客原文 翻譯作品,水平有限,如有錯誤,煩請留言指正。原文請見 官網(wǎng)英文文檔 引言 概述 Apache Flume...
    rabbitGYK閱讀 11,694評論 13 34
  • Flume的官網(wǎng)地址:http://flume.apache.org/FlumeUserGuide.html#ex...
    24格的世界閱讀 975評論 0 1
  • 七月,開始了人生中第一次正經(jīng)的工作,卻一直拖到八月底才來回顧這段經(jīng)歷,想想從前的自己,每一天都有迫不及待想要記錄的...
    毛阿瑩閱讀 304評論 0 0
  • 自9日以來,沒有在凌晨一點(diǎn)前睡的。今早起來,哪哪都不舒服,尤其頭和胃:頭痛欲裂,胃疼,感覺里面有亂七八糟的柴草堆。...
    果菲的世界閱讀 595評論 0 0
  • 自古以來,不管是東方人還是西方人,都非常重視早餐。人們認(rèn)為,早餐是一天中第一餐,也是最重要的一餐。 然而,隨著經(jīng)濟(jì)...
    Zermatt閱讀 4,166評論 0 0

友情鏈接更多精彩內(nèi)容