宝贝腿开大点我添添你视频男男,中文字幕熟女人妻av一区二区三区,爱色成人网,大地资源高清播放在线观看在线电影在线观看 ,777米奇影视第四色

集團(tuán)站切換校區(qū)

驗(yàn)證碼已發(fā)送,請查收短信

復(fù)制成功
微信號:togogoi
添加微信好友, 詳細(xì)了解課程
已復(fù)制成功,如果自動(dòng)跳轉(zhuǎn)微信失敗,請前往微信添加好友
打開微信
圖標(biāo)

學(xué)習(xí)文章

當(dāng)前位置:首頁 > >學(xué)習(xí)文章 > >

{大數(shù)據(jù)}輔助系統(tǒng)

發(fā)布時(shí)間: 2018-02-08 02:42:18

?1.1 Flume介紹

1.1.1 概述u Flume是一個(gè)分布式、可靠、和高可用的海量日志采集、聚合和傳輸?shù)南到y(tǒng)。

Flume可以采集文件,socket數(shù)據(jù)包等各種形式源數(shù)據(jù),又可以將采集到的數(shù)據(jù)輸出到HDFS、hbase、hive、kafka等眾多外部存儲系統(tǒng)中

一般的采集需求,通過對flume的簡單配置即可實(shí)現(xiàn)

Flume針對特殊場景也具備良好的自定義擴(kuò)展能力,因此,flume可以適用于大部分的日常數(shù)據(jù)采集場景

1.1.2 運(yùn)行機(jī)制1、 Flume分布式系統(tǒng)中最核心的角色是agent,flume采集系統(tǒng)就是由一個(gè)個(gè)agent所連接起來形成

2、 每一個(gè)agent相當(dāng)于一個(gè)數(shù)據(jù)傳遞員,內(nèi)部有三個(gè)組件:

a) Source:采集源,用于跟數(shù)據(jù)源對接,以獲取數(shù)據(jù)

b) Sink:下沉地,采集數(shù)據(jù)的傳送目的,用于往下一級agent傳遞數(shù)據(jù)或者往最終存儲系統(tǒng)傳遞數(shù)據(jù)

c) Channel:angent內(nèi)部的數(shù)據(jù)傳輸通道,用于從source將數(shù)據(jù)傳遞到sink


1.1.4 Flume采集系統(tǒng)結(jié)構(gòu)圖 

1. 簡單結(jié)構(gòu)單個(gè)agent采集數(shù)據(jù)

?

2. 復(fù)雜結(jié)構(gòu)多級agent之間串聯(lián)

?

1.2 Flume實(shí)戰(zhàn)案例1.2.1 Flume的安裝部署1、Flume的安裝非常簡單,只需要解壓即可,當(dāng)然,前提是已有hadoop環(huán)境

上傳安裝包到數(shù)據(jù)源所在節(jié)點(diǎn)上

然后解壓  tar -zxvf apache-flume-1.8.0-bin.tar.gz

配置環(huán)境變量 vi /etc/profile

?
HIVE_HOME=/home/hadoop/apps/hive

HBASE_HOME=/home/hadoop/apps/hbase

ZOOKEEPER_HOME=/home/hadoop/apps/zookeeper

HADOOP_HOME=/home/hadoop/apps/hadoop-2.8.1

JAVA_HOME=/opt/jdk1.8.0_121

FLUME_HOME=/home/hadoop/apps/flume

PATH=$FLUME_HOME/bin:$HIVE_HOME/bin:$HBASE_HOME/bin:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH

export FLUME_HOME HIVE_HOME HBASE_HOME ZOOKEEPER_HOME HADOOP_HOME JAVA_HOME PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

?

然后進(jìn)入flume的目錄,修改conf下的flume-env.sh,在里面配置JAVA_HOME

export JAVA_HOME=/opt/jdk1.8.0_121


2、根據(jù)數(shù)據(jù)采集的需求配置采集方案,描述在配置文件中(文件名可任意自定義)

3、指定采集方案配置文件,在相應(yīng)的節(jié)點(diǎn)上啟動(dòng)flume agent


先用一個(gè)最簡單的例子來測試一下程序環(huán)境是否正常

1、先在flume的conf目錄下新建一個(gè)文件

vi   netcat-logger.conf

?

# 定義這個(gè)agent中各組件的名字

a1.sources = r1

a1.sinks = k1

a1.channels = c1


# 描述和配置source組件:r1

a1.sources.r1.type = netcat

a1.sources.r1.bind = localhost

a1.sources.r1.port = 44444


# 描述和配置sink組件:k1

a1.sinks.k1.type = logger


# 描述和配置channel組件,此處使用是內(nèi)存緩存的方式

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100


# 描述和配置source  channel   sink之間的連接關(guān)系

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1


?2、啟動(dòng)agent去采集數(shù)據(jù)

?bin/flume-ng agent -c conf -f conf/netcat-logger.conf -n a1  -Dflume.root.logger=INFO,console

?

c conf   指定flume自身的配置文件所在目錄

-f conf/netcat-logger.con  指定我們所描述的采集方案

-n a1  指定我們這個(gè)agent的名字

1、測試

先要往agent采集監(jiān)聽的端口上發(fā)送數(shù)據(jù),讓agent有數(shù)據(jù)可采

隨便在一個(gè)能跟agent節(jié)點(diǎn)聯(lián)網(wǎng)的機(jī)器上

telnet anget-hostname  port   (telnet localhost 44444)

如果telnet命令找不到,則用以下方式安裝

[root@hdp08 ~]# yum install telnet

?


1.2.2 采集案例

1、采集指定目錄下的日志文件

# Name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1


# Describe/configure the source

#監(jiān)聽目錄,spoolDir指定目錄, fileHeader要不要給文件夾前墜名

a1.sources.r1.type = spooldir

a1.sources.r1.spoolDir = /home/hadoop/flumespool

a1.sources.r1.fileHeader = true


# Describe the sink

a1.sinks.k1.type = logger


# Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100


# Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1


??

啟動(dòng)命令:  

bin/flume-ng agent -c ./conf -f ./conf/spool-logger.conf -n a1 -Dflume.root.logger=INFO,console


?

2、采集目錄到HDFS采集需求:某服務(wù)器的某特定目錄下,會(huì)不斷產(chǎn)生新的文件,每當(dāng)有新文件出現(xiàn),就需要把文件采集到HDFS中去

根據(jù)需求,首先定義以下3大要素

l 采集源,即source——監(jiān)控文件目錄 :  spooldir

l 下沉目標(biāo),即sink——HDFS文件系統(tǒng)  :  hdfs sink

l source和sink之間的傳遞通道——channel,可用file channel 也可以用內(nèi)存channel


配置文件編寫:

?

# Name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1


# Describe/configure the source

#監(jiān)聽目錄,spoolDir指定目錄, fileHeader要不要給文件夾前墜名

a1.sources.r1.type = spooldir

a1.sources.r1.spoolDir = /home/hadoop/flumespool

a1.sources.r1.fileHeader = true


# Describe the sink

a1.sinks.k1.type = hdfs

a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/

a1.sinks.k1.hdfs.filePrefix = events-

a1.sinks.k1.hdfs.round = true

a1.sinks.k1.hdfs.roundValue = 10

a1.sinks.k1.hdfs.roundUnit = minute

a1.sinks.k1.hdfs.rollInterval = 3

a1.sinks.k1.hdfs.rollSize = 20

a1.sinks.k1.hdfs.rollCount = 5

a1.sinks.k1.hdfs.batchSize = 1

a1.sinks.k1.hdfs.useLocalTimeStamp = true

#生成的文件類型,默認(rèn)是Sequencefile,可用DataStream,則為普通文本

a1.sinks.k1.hdfs.fileType = DataStream

# Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100


# Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1


?

Channel參數(shù)解釋:

capacity:默認(rèn)該通道中較大的可以存儲的event數(shù)量

trasactionCapacity:每次較大可以從source中拿到或者送到sink中的event數(shù)量

keep-alive:event添加到通道中或者移出的允許時(shí)間


?

3、采集文件到HDFS采集需求:比如業(yè)務(wù)系統(tǒng)使用log4j生成的日志,日志內(nèi)容不斷增加,需要把追加到日志文件中的數(shù)據(jù)實(shí)時(shí)采集到hdfs


根據(jù)需求,首先定義以下3大要素

l 采集源,即source——監(jiān)控文件內(nèi)容更新 :  exec  ‘tail -F file’

l 下沉目標(biāo),即sink——HDFS文件系統(tǒng)  :  hdfs sink

l Source和sink之間的傳遞通道——channel,可用file channel 也可以用 內(nèi)存channel


配置文件編寫:

?

# Name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1


# Describe/configure the source

a1.sources.r1.type = exec

a1.sources.r1.command = tail -F /home/hadoop/log/test.log

a1.sources.r1.channels = c1


# Describe the sink

a1.sinks.k1.type = hdfs

a1.sinks.k1.channel = c1

a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/

a1.sinks.k1.hdfs.filePrefix = events-

a1.sinks.k1.hdfs.round = true

a1.sinks.k1.hdfs.roundValue = 10

a1.sinks.k1.hdfs.roundUnit = minute

a1.sinks.k1.hdfs.rollInterval = 3

a1.sinks.k1.hdfs.rollSize = 20

a1.sinks.k1.hdfs.rollCount = 5

a1.sinks.k1.hdfs.batchSize = 1

a1.sinks.k1.hdfs.useLocalTimeStamp = true

#生成的文件類型,默認(rèn)是Sequencefile,可用DataStream,則為普通文本

a1.sinks.k1.hdfs.fileType = DataStream


# Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100


# Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1


啟動(dòng)命令:

bin/flume-ng agent -c conf -f conf/tail-hdfs.conf -n a1 -Dflume.root.logger=INFO,console

?

4、采集文件發(fā)到另一個(gè)agent

?

從tail命令獲取數(shù)據(jù)發(fā)送到avro端口

另一個(gè)節(jié)點(diǎn)可配置一個(gè)avro源來中繼數(shù)據(jù),發(fā)送外部存儲

##################

# Name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1


# Describe/configure the source

a1.sources.r1.type = spooldir

a1.sources.r1.spoolDir = /home/hadoop/flumespool

a1.sources.r1.fileHeader = true


# Describe the sink

a1.sinks = k1

a1.sinks.k1.type = avro

a1.sinks.k1.channel = c1

a1.sinks.k1.hostname = hdp09

a1.sinks.k1.port = 4141

a1.sinks.k1.batch-size = 2


# Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100


# Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

?

從avro端口接收數(shù)據(jù),下沉到logger


采集配置文件,avro-hdfs.conf


# Name the components on this agent

a1.sources = r1

a1.sinks = k1

a1.channels = c1


# Describe/configure the source

a1.sources.r1.type = avro

a1.sources.r1.channels = c1

a1.sources.r1.bind = 0.0.0.0

a1.sources.r1.port = 4141


# Describe the sink

a1.sinks.k1.type = logger


# Use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactionCapacity = 100


# Bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1


發(fā)送數(shù)據(jù):

$ bin/flume-ng avro-client -H localhost -p 4141 -F /usr/logs/log.10

?

1.3 更多source和sink組件

?

Flume支持眾多的source和sink類型,詳細(xì)手冊可參考官方文檔

http://flume.apache.org/FlumeUserGuide.html?

上一篇: {大數(shù)據(jù)}sqoop數(shù)據(jù)遷移

下一篇: {大數(shù)據(jù)}HBase開發(fā)

十九年老品牌
微信咨詢:gz_togogo 咨詢電話:18127429208 咨詢網(wǎng)站客服:在線客服

相關(guān)課程推薦

在線咨詢 ×

您好,請問有什么可以幫您?我們將竭誠提供最優(yōu)質(zhì)服務(wù)!