大數(shù)據(jù)技術(shù)之Flume_第1頁(yè)
大數(shù)據(jù)技術(shù)之Flume_第2頁(yè)
大數(shù)據(jù)技術(shù)之Flume_第3頁(yè)
大數(shù)據(jù)技術(shù)之Flume_第4頁(yè)
大數(shù)據(jù)技術(shù)之Flume_第5頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 大數(shù)據(jù)技術(shù)之標(biāo)題一、Flume簡(jiǎn)介1) Flume提供一個(gè)分布式的,可靠的,對(duì)大數(shù)據(jù)量的日志進(jìn)行高效收集、聚集、移動(dòng)的服務(wù),F(xiàn)lume只能在Unix環(huán)境下運(yùn)行。2) Flume基于流式架構(gòu),容錯(cuò)性強(qiáng),也很靈活簡(jiǎn)單。3) Flume、Kafka用來(lái)實(shí)時(shí)進(jìn)行數(shù)據(jù)收集,Spark、Storm用來(lái)實(shí)時(shí)處理數(shù)據(jù),impala用來(lái)實(shí)時(shí)查詢。二、Flume角色2.1、Source用于采集數(shù)據(jù),Source是產(chǎn)生數(shù)據(jù)流的地方,同時(shí)Source會(huì)將產(chǎn)生的數(shù)據(jù)流傳輸?shù)紺hannel,這個(gè)有點(diǎn)類似于Java IO部分的Channel。2.2、Channel用于橋接Sources和Sinks,類似于一個(gè)隊(duì)列。2.3

2、、Sink從Channel收集數(shù)據(jù),將數(shù)據(jù)寫到目標(biāo)源(可以是下一個(gè)Source,也可以是HDFS或者HBase)。2.4、Event傳輸單元,F(xiàn)lume數(shù)據(jù)傳輸?shù)幕締卧?,以事件的形式將?shù)據(jù)從源頭送至目的地。三、Flume傳輸過(guò)程source監(jiān)控某個(gè)文件或數(shù)據(jù)流,數(shù)據(jù)源產(chǎn)生新的數(shù)據(jù),拿到該數(shù)據(jù)后,將數(shù)據(jù)封裝在一個(gè)Event中,并put到channel后commit提交,channel隊(duì)列先進(jìn)先出,sink去channel隊(duì)列中拉取數(shù)據(jù),然后寫入到hdfs或者HBase中。四、Flume部署及使用4.1、文件配置flume-env.sh涉及修改項(xiàng):JAVA_HOME=/home/admin/mo

3、dules/jdk1.8.0_1214.2、案例4.2.1、案例一目標(biāo):Flume監(jiān)控一端Console,另一端Console發(fā)送消息,使被監(jiān)控端實(shí)時(shí)顯示。分步實(shí)現(xiàn):1) 創(chuàng)建Flume Agent配置文件flume-telnet.conf# Name the components on this agenta1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the sourcea1.sources.r1.type = netcata1.sources.r1.bind = localhosta1.sources.r1

4、.port = 44444# Describe the sinka1.sinks.k1.type = logger# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c12) 安裝te

5、lnet工具$ sudo rpm -ivh telnet-server-0.17-59.el7.x86_64.rpm $ sudo rpm -ivh telnet-0.17-59.el7.x86_64.rpm3) 判斷44444端口是否被占用$ netstat -an | grep 444444) 先開啟flume先聽端口$ bin/flume-ng agent -conf conf/ -name a1 -conf-file conf/flume-telnet.conf -Dflume.root.logger=INFO,console5) 使用telnet工具向本機(jī)的44444端口發(fā)送內(nèi)容$

6、telnet localhost 444444.2.2、案例二目標(biāo):實(shí)時(shí)監(jiān)控hive日志,并上傳到HDFS中分步實(shí)現(xiàn):1) 拷貝Hadoop相關(guān)jar到Flume的lib目錄下(要學(xué)會(huì)根據(jù)自己的目錄和版本查找jar包)$ cp share/hadoop/common/lib/hadoop-auth-2.5.0-cdh5.3.6.jar ./lib/$ cp share/hadoop/common/lib/commons-configuration-1.6.jar ./lib/$ cp share/hadoop/mapreduce1/lib/hadoop-hdfs-2.5.0-cdh5.3.6.

7、jar ./lib/$ cp share/hadoop/common/hadoop-common-2.5.0-cdh5.3.6.jar ./lib/$ cp ./share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar ./lib/$ cp ./share/hadoop/hdfs/lib/commons-io-2.4.jar ./lib/尖叫提示:標(biāo)紅的jar為1.99版本flume必須引用的jar2) 創(chuàng)建flume-hdfs.conf文件# Name the components on this agenta2.sources = r2a

8、2.sinks = k2a2.channels = c2# Describe/configure the sourcea2.sources.r2.type = execmand = tail -F /home/admin/modules/apache-flume-1.7.0-bin/my_custom_logs.txta2.sources.r2.shell = /bin/bash -c# Describe the sinka2.sinks.k2.type = hdfsa2.sinks.k2.hdfs.path = hdfs:/linux01:8020/flume/%Y%m%d/%H#上傳文件的

9、前綴a2.sinks.k2.hdfs.filePrefix = logs-#是否按照時(shí)間滾動(dòng)文件夾a2.sinks.k2.hdfs.round = true#多少時(shí)間單位創(chuàng)建一個(gè)新的文件夾a2.sinks.k2.hdfs.roundValue = 1#重新定義時(shí)間單位a2.sinks.k2.hdfs.roundUnit = hour#是否使用本地時(shí)間戳a2.sinks.k2.hdfs.useLocalTimeStamp = true#積攢多少個(gè)Event才flush到HDFS一次a2.sinks.k2.hdfs.batchSize = 1000#設(shè)置文件類型,可支持壓縮a2.sinks.k2.

10、hdfs.fileType = DataStream#多久生成一個(gè)新的文件a2.sinks.k2.hdfs.rollInterval = 600#設(shè)置每個(gè)文件的滾動(dòng)大小a2.sinks.k2.hdfs.rollSize = 134217700#文件的滾動(dòng)與Event數(shù)量無(wú)關(guān)a2.sinks.k2.hdfs.rollCount = 0#最小冗余數(shù)a2.sinks.k2.hdfs.minBlockReplicas = 1# Use a channel which buffers events in memorya2.channels.c2.type = memorya2.channels.c2.c

11、apacity = 1000a2.channels.c2.transactionCapacity = 100# Bind the source and sink to the channela2.sources.r2.channels = c2a2.sinks.k2.channel = c23) 執(zhí)行監(jiān)控配置$ bin/flume-ng agent -conf conf/ -name a2 -conf-file conf/flume-hdfs.conf4.2.3、案例三目標(biāo):使用flume監(jiān)聽整個(gè)目錄的文件分步實(shí)現(xiàn):1) 創(chuàng)建配置文件flume-dir.confa3.sources = r3a

12、3.sinks = k3a3.channels = c3# Describe/configure the sourcea3.sources.r3.type = spooldira3.sources.r3.spoolDir = /home/admin/modules/apache-flume-1.7.0-bin/uploada3.sources.r3.fileHeader = true#忽略所有以.tmp結(jié)尾的文件,不上傳a3.sources.r3.ignorePattern = ( *.tmp)# Describe the sinka3.sinks.k3.type = hdfsa3.sinks

13、.k3.hdfs.path = hdfs:/linux01:8020/flume/upload/%Y%m%d/%H#上傳文件的前綴a3.sinks.k3.hdfs.filePrefix = upload-#是否按照時(shí)間滾動(dòng)文件夾a3.sinks.k3.hdfs.round = true#多少時(shí)間單位創(chuàng)建一個(gè)新的文件夾a3.sinks.k3.hdfs.roundValue = 1#重新定義時(shí)間單位a3.sinks.k3.hdfs.roundUnit = hour#是否使用本地時(shí)間戳a3.sinks.k3.hdfs.useLocalTimeStamp = true#積攢多少個(gè)Event才flush

14、到HDFS一次a3.sinks.k3.hdfs.batchSize = 1000#設(shè)置文件類型,可支持壓縮a3.sinks.k3.hdfs.fileType = DataStream#多久生成一個(gè)新的文件a3.sinks.k3.hdfs.rollInterval = 600#設(shè)置每個(gè)文件的滾動(dòng)大小a3.sinks.k3.hdfs.rollSize = 134217700#文件的滾動(dòng)與Event數(shù)量無(wú)關(guān)a3.sinks.k3.hdfs.rollCount = 0#最小冗余數(shù)a3.sinks.k3.hdfs.minBlockReplicas = 1# Use a channel which buffers events in memorya3.channels.c3.type = memorya3.channels.c3.capacity = 1000a3.channels.c3.transactionCapacity = 100# Bind the source and sink to the channela3.sources.r3.channels = c3a3.sinks.k3.cha

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論