大資料協作框架之flume詳解
1、下載
2、加壓
$tar zxf /sourcepath/ -C /copypath
3、配置flumu-env.sh檔案
exprt JAVA_HOME=/jdkpath
4、啟動
$bin/flume-ng help/version
flume的使用
常用命令
一般使用的命令
$bin/flume-ng agent --conf conf/ --name a1 --conf-file conf/flume-telnet.conf -Dflume.root.logger=INFO,console
**-c或--conf 後面跟配置目錄
**-f或—-conf-file 後面跟具體的配置檔案
**-n或—-name 指定Agent的名稱
案例1、
使用flume監控某個埠,把埠寫入的資料輸出為logger
配置檔名稱:flum-telnet.conf
==================agent a1=======================
# Name the components on this agent
#定義一個source
a1.sources = r1
#定義一個sinks
a1.sinks = k1
#定義一個channel
a1.channels = c1
# Describe/configure the source
#指定source型別
a1.sources.r1.type = netcat
#指定監控主機ip
a1.sources.r1.bind = 192.168.242.128
#指定監控主機埠
a1.sources.r1.port = 44444
# Describe the sink
#sinks通過logger輸出
a1.sinks.k1.type = logger
# Use a channel which buffers events in memory
#設定channel的型別:memory
a1.channels.c1.type = memory
#設定channel中evens最大有個數
a1.channels.c1.capacity = 1000
#設定sink從channel獲取的個數
a1.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
#把source和channl建立連結
a1.sources.r1.channels = c1
#把channel和sink建立連結
a1.sinks.k1.channel = c1
準備工作:
telnet:是基於tcp協議的一個登陸訪問遠端機器的服務
yum -y install telnet
檢視埠是否佔用
netstat -an|grep 44444
telnet使用埠
telnet 192.168.242.128 44444
啟動flum的agent
$bin/flume-ng
**flume的agent
agent
**flumed配置檔案目錄
--conf conf/
**配置檔案的agent的名稱
--name a1
**flume中agent的具體配置檔案
--conf-file conf/flume-telnet.conf
**在控制檯輸出info級別的日誌
-Dflume.root.logger=INFO,console
案例2、
** 企業常用
** 日誌檔案 --> 新新增[追加]
使用flume去監控某個檔案,將新新增進檔案的內容抽取到其他地方[HDFS]
=======================agent(flume-apache.conf)=========================
# Name the components on this agent
a2.sources = r2
a2.channels = c2
a2.sinks = k2
# define sources
#設定source為命令型別(exec)
a2.sources.r2.type = exec
#執行的命令
a2.sources.r2.command = tail -F /var/log/httpd/access_log
#執行方式(shell)
a2.sources.r2.shell = /bin/bash -c
# define channels
#設定channel的快取型別為memory
a2.channels.c2.type = memory
a2.channels.c2.capacity = 1000
a2.channels.c2.transactionCapacity = 100
# define sinks
#設定sink為寫入目標為hdfs
a2.sinks.k2.type = hdfs
#設定寫入的ip,並且定義檔案為日期格式的二級目錄結構
a2.sinks.k2.hdfs.path=hdfs://192.168.242.128:8020/flume/%Y%m%d/%H%M
#定義存放在hdfs上的檔名稱字首
a2.sinks.k2.hdfs.filePrefix = accesslog
#啟用日期檔案命名格式
a2.sinks.k2.hdfs.round=true
#設定建立檔案目錄結構的時間間隔以及單位
a2.sinks.k2.hdfs.roundValue=5
a2.sinks.k2.hdfs.roundUnit=minute
#設定使用本地時間戳
a2.sinks.k2.hdfs.useLocalTimeStamp=true
#設定批處理的大小
a2.sinks.k2.hdfs.batchSize=1000
#設定檔案型別
a2.sinks.k2.hdfs.fileType=DataStream
#設定檔案格式
a2.sinks.k2.hdfs.writeFormat=Text
# bind the sources and sinks to the channels
a2.sources.r2.channels = c2
a2.sinks.k2.channel = c2
準備工作
安裝apache,並且啟動服務
$su - root
$yum -y install httpd
$service httpd start
在apache中建立可以訪問的html頁面
$vi /var/www/html/index.html
檢視日誌
$tail -f /var/log/httpd/access_log
[
tail: 無法開啟"/var/log/httpd/access_log" 讀取資料: 許可權不夠
一般使用者可以讀取/var/log/httpd下檔案
$su - root
$chmod 755 /var/log/httpd
啟動
bin/flume-ng agent --conf conf/ --name a2 --conf-file conf/flume-apache.conf -Dflume.root.logger=INFO,console
java.lang.NoClassDefFoundError: org/apache/hadoop/io/SequenceFile$CompressionType
at org.apache.flume.sink.hdfs.HDFSEventSink.configure(HDFSEventSink.java:251)
at org.apache.flume.conf.Configurables.configure(Configurables.java:41)
at org.apache.flume.node.AbstractConfigurationProvider.loadSinks(AbstractConfigurationProvider.java:413)
at org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(AbstractConfigurationProvider.java:98)
at org.apache.flume.node.PollingPropertiesFileConfigurationProvider$FileWatcherRunnable.run(PollingPropertiesFileConfigurationProvider.java:140)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.SequenceFile$CompressionType
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 12 more
flume往目標hdfs上寫檔案,flume相當於hadoop hdfs的一個客戶端,也就需要在flumelib下匯入hadoop jar,如下四個:
hadoop-hdfs-2.5.0-cdh5.3.6.jar
hadoop-common-2.5.0-cdh5.3.6.jar
hadoop-auth-2.5.0-cdh5.3.6.jar
commons-configuration-1.6.jar
解決flume檔案過多過小的問題
#設定解決檔案過多過小問題
#每600秒生成一個檔案
a2.sinks.k2.hdfs.rollInterval=600
#當達到128000000bytes時,建立新檔案 127*1024*1024
#實際環境中如果按照128M回顧檔案,那麼這裡設定一般設定成127M
a2.sinks.k2.hdfs.rollSize=128000000
#設定檔案的生成不和events數相關
a2.sinks.k2.hdfs.rollCount=0
#設定成1,否則當有副本複製時就重新生成檔案,上面三條則沒有效果
a2.sinks.k2.hdfs.minBlockReplicas=1
案例3:
利用flume監控某個目錄[/var/log/httpd],把裡面回滾好的檔案
實時抽取到HDFS平臺。
# Name the components on this agent
a3.sources = r3
a3.channels = c3
a3.sinks = k3
# define sources
#設定監控的型別,檔案目錄
a3.sources.r3.type = spooldir
#設定目錄
a3.sources.r3.spoolDir = /home/beifeng/logs
#設定忽略目錄中的檔案
a3.sources.r3.ignorePattern = ^.*\_log$
# define channels
#設定channel快取資料的型別(file)
a3.channels.c3.type = file
#設定檢測點目錄
a3.channels.c3.checkpointDir = /opt/modules/apache-flume-1.5.0-cdh5.3.6-bin/checkpoint
#檔案快取位置
a3.channels.c3.dataDirs = /opt/modules/apache-flume-1.5.0-cdh5.3.6-bin/checkdata
# define sinks
a3.sinks.k3.type = hdfs
a3.sinks.k3.hdfs.path=hdfs://192.168.17.129:8020/flume2/%Y%m%d/%H
a3.sinks.k3.hdfs.filePrefix = accesslog
a3.sinks.k3.hdfs.round=true
a3.sinks.k3.hdfs.roundValue=1
a3.sinks.k3.hdfs.roundUnit=hour
a3.sinks.k3.hdfs.useLocalTimeStamp=true
a3.sinks.k3.hdfs.batchSize=1000
a3.sinks.k3.hdfs.fileType=DataStream
a3.sinks.k3.hdfs.writeFormat=Text
#設定解決檔案過多過小問題
#每600秒生成一個檔案
a3.sinks.k3.hdfs.rollInterval=600
#當達到128000000bytes時,建立新檔案 127*1024*1024
#實際環境中如果按照128M回顧檔案,那麼這裡設定一般設定成127M
a3.sinks.k3.hdfs.rollSize=128000000
#設定檔案的生成不和events數相關
a3.sinks.k3.hdfs.rollCount=0
#設定成1,否則當有副本複製時就重新生成檔案,上面三條則沒有效果
a3.sinks.k3.hdfs.minBlockReplicas=1
# bind the sources and sinks to the channels
a3.sources.r3.channels = c3
a3.sinks.k3.channel = c3
相關推薦
大資料協作框架之flume詳解
flume的安裝配置 1、下載 2、加壓 $tar zxf /sourcepath/ -C /copypath 3、配置flumu-env.sh檔案 exprt JAVA_HOME=/jdkpath 4、啟動 $bin/flume
大資料協作框架之Flume
一、概述 Flume是Cloudera提供的一個高可用的,高可靠的,分散式的海量日誌採集、聚合和傳輸的系統,Flume支援在日誌系統中定製各類資料傳送方,用於收集資料;同時,Flume提供對資料進行簡單處理,並寫到各種資料接受方(可定製)的能力。
大資料協作框架之Oozie
一、配置: 1、下載並解壓: http://archive.cloudera.com/cdh5/cdh/5/oozie-4.1.0-cdh5.14.2.tar.gz tar -zxvf oozie-4.1.0-cdh5.14.2.tar.gz -C /opt/cdh5.14.2/
大資料協作框架之Sqoop
一、概述: 1、Sqoop:SQL-to-Hadoop 2、連線傳統關係型資料庫和Hadoop的橋樑: a、把關係型資料庫的資料匯入到Hadoop與其相關的系統中(如Hive,Hbase)
hadoop大資料平臺架構之DKhadoop詳解
大資料的時代已經來了,資訊的爆炸式增長使得越來越多的行業面臨這大量資料需要儲存和分析的挑戰。Hadoop作為一個開源的分散式並行處理平臺,以其高拓展、高效率、高可靠等優點越來越受到歡迎。這同時也帶動了hadoop商業版的發行。這裡就通過大快DKhadoop為大家詳細介紹一下h
Django框架 之 querySet詳解
int 框架 子句 cell cts syn 重復執行 span pytho 瀏覽目錄 可切片 可叠代 惰性查詢 緩存機制 exists()與iterator()方法 QuerySet 可切片 使用Python 的切片語法來限制查詢集記錄的數目
web前端開之網站搭建框架之vue詳解
網站搭建框架之vue Vue是web前端快速搭建網站的框架之一。它與jQuery有所不同,是以資料驅動web介面(以操作資料改變頁面,而jQuery是以操作節點來改變頁面),同時,vue還實現了資料的雙向繫結,可及時響應使用者的輸入。最主要的是vue的寫法簡單,容易掌握,元件形式可以大大提高工作效率。 對
大資料處理框架之:Storm + Kafka + zookeeper 叢集
Storm kafka zookeeper 叢集 我們知道storm的作用主要是進行流式計算,對於源源不斷的均勻資料流流入處理是非常有效的,而現實生活中大部分場景並不是均勻的資料流,而是時而多時而少的資料流入,這種情況下顯然用批量處理是不合適的,如果使用storm做實時計算的話可能因為資
空間資料視覺化之ArcLayer詳解
deck-overlay中 首先使用d3中的scaleQuantile將資料進行分類,scaleQuantile方法是d3中的一種資料分類方法(https://www.cnblogs.com/kidsitcn/p/7182274.html)https://raw.githubusercontent.co
大資料學習筆記之flume----日誌收集系統
一、flume基本概念 Flume是Cloudera提供的一個高可用的,高可靠的,分散式的海量日誌採集、聚合和傳輸的系統; Flume支援在日誌系統中定製各類資料傳送方,用於收集資料; Flume提供對資料進行簡單處理,並寫到各種資料接受方(可定製)的能力。 總結:f
spark大資料架構初學入門基礎詳解
Spark是什麼 a) 是一種通用的大資料計算框架 b) Spark Core 離線計算 Spark SQL 互動式查詢 Spark Streaming 實時流式計算 Spark MLlib 機器學習 Spark GraphX 圖計算 c) 特點:
帶你看懂大資料採集引擎之Flume&採集目錄中的日誌
歡迎關注大資料和人工智慧技術文章釋出的微信公眾號:清研學堂,在這裡你可以學到夜白(作者筆名)精心整理的筆記,讓我們每天進步一點點,讓優秀成為一種習慣! 帶你看懂大資料採集引擎之Flume&採集目錄中的日誌 一、Flume的介紹: Flume由Clo
大資料求索(15): Redis事務詳解
大資料求索(15): Redis事務詳解 一、什麼是事務 事務是一個單獨的隔離操作:事務中的所有命令都會序列化、按順序執行。事務在執行的過程中,不會被其他客戶端傳送來的命令請求打斷。 事務是一個原子操作:事務中的命令要麼全部被執行,要麼全部都不執行。 二、
大資料協作框架——sqoop學習權威指南
大資料協作框架“大資料協作框架”其實是一個統稱,實際上就是Hadoop 2.x生態系統中幾個輔助Hadoop 2.x框架。在此,主要是以下四個框架:資料轉換工具Sqoop檔案收集庫框架Flume任務排程框架Oozie大資料WEB工具Hue選擇CDH5.3.x版本框架Cloud
【大資料演算法】:apriori演算法詳解,非常清晰
Apriori演算法例項 交易ID 商品ID列表 T100 I1,I2,I5 T200 I2,I4 T300 I2,I3 T400 I1,I2,I4 T500 I1,I3 T600 I2,I3 T700 I1
Spring MVC學習總結(14)——SpringMVC測試框架之mockMVC詳解
SpringMVC測試框架 基於RESTful風格的SpringMVC的測試,我們可以測試完整的Spring MVC流程,即從URL請求到控制器處理,再到檢視渲染都可以測試。 一 MockMvcBuilder MockMvcBuilder是用來構造MockMvc的構造器,其主要有兩個實現:Standalone
許可權框架之Shiro詳解
文章大綱 一、許可權框架介紹二、Shiro基礎介紹三、Spring Boot整合Shiro程式碼實戰四、專案原始碼與資料下載五、參考文章 一、許可權框架介紹 1. 什麼是許可權管理 許可權管理屬於系統安全的範疇,許可權管理實
大資料開發-Spark Join原理詳解
資料分析中將兩個資料集進行 Join 操作是很常見的場景。在 Spark 的物理計劃階段,Spark 的 Join Selection 類會根 據 Join hints 策略、Join 表的大小、 Join 是等值 Join 還是不等值以及參與 Join 的 key 是否可以排序等條件來選擇最 終的 Join
大資料之hdfs詳解之三:put許可權剖析與常用命令
–無論是對於hdfs的讀和寫,對於使用者來說都是無感知的、透明的操作,使用者並不關心資料如何讀出來如何寫進去的,只要返回一個結果告訴使用者資料讀出來了或寫進去了,至於怎麼讀怎麼寫,使用者並不關心 補充: 讀:hdfs dfs -ls / = hdfs dfs
大資料環境搭建之Kafka完全分散式環境搭建步驟詳解
文章目錄 環境準備 解壓安裝 配置檔案 服務啟動 1、啟動分散式叢集的zookeeper 2、啟動Kafka服務 偽分散式搭建完畢之後,只要稍作修改就