日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

大数据(9) - Flume的安装与使用

發(fā)布時間:2025/3/15 编程问答 11 豆豆
生活随笔 收集整理的這篇文章主要介紹了 大数据(9) - Flume的安装与使用 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Flume簡介 --(實時抽取數(shù)據(jù)的工具)

1) Flume提供一個分布式的,可靠的,對大數(shù)據(jù)量的日志進行高效收集、聚集、移動的服務(wù),Flume只能在Unix環(huán)境下運行。

2) Flume基于流式架構(gòu),容錯性強,也很靈活簡單。

3) Flume、Kafka用來實時進行數(shù)據(jù)收集,Spark、Storm用來實時處理數(shù)據(jù),impala用來實時查詢。

?

Flume角色

1、Source

用于采集數(shù)據(jù),Source是產(chǎn)生數(shù)據(jù)流的地方,同時Source會將產(chǎn)生的數(shù)據(jù)流傳輸?shù)紺hannel,這個有點類似于Java IO部分的Channel。

2、Channel

用于橋接Sources和Sinks,類似于一個隊列。

3、Sink

從Channel收集數(shù)據(jù),將數(shù)據(jù)寫到目標(biāo)源(可以是下一個Source,也可以是HDFS或者HBase)。

4、Event

?

傳輸單元,Flume數(shù)據(jù)傳輸?shù)幕締卧?#xff0c;以事件的形式將數(shù)據(jù)從源頭送至目的地。

?

Flume傳輸過程

source監(jiān)控某個文件或數(shù)據(jù)流,數(shù)據(jù)源產(chǎn)生新的數(shù)據(jù),拿到該數(shù)據(jù)后,將數(shù)據(jù)封裝在一個Event中,并put到channel后commit提交,channel隊列先進先出,sink去channel隊列中拉取數(shù)據(jù),然后寫入到HDFS中。

Flume部署及使用

1.下載并解壓到指定目錄

$ tar -zxf ~/softwares/installtions/apache-flume-1.7.0-bin.tar.gz -C ~/modules/

  

2.重命名文件,且修改配置文件。

cd /home/admin/modules/apache-flume-1.7.0-bin/conf將所有帶有template的文件去掉template修改配置文件 flume-env.sh (只需修改你對應(yīng)的java安裝路徑即可)export JAVA_HOME=/home/admin/modules/jdk1.8.0_131

  

使用案例

案例一 :端口數(shù)據(jù)監(jiān)控

1.先安裝telnet,telnet rpm包 下載

$ sudo rpm -ivh xinetd-2.3.14-40.el6.x86_64.rpm $ sudo rpm -ivh telnet-0.17-48.el6.x86_64.rpm $ sudo rpm -ivh telnet-server-0.17-48.el6.x86_64.rpm

  

2.創(chuàng)建案例一的文件夾,與配置文件

在Flume的根目錄創(chuàng)建對應(yīng)的文件夾mkdir -p jobs/job1

  

3.創(chuàng)建項目對應(yīng)的配置文件

cd /home/admin/modules/apache-flume-1.7.0-bin/jobs/job1vim flume-telnet.conf# 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 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

  

4.判斷44444端口是否被占用

?

$ sudo netstat -tunlp | grep 44444

?

  

5.先開啟flume先聽端口

?

在Flume的根目錄下$ bin/flume-ng agent --conf conf/ --name a1 --conf-file jobs/job1/flume-telnet.conf -Dflume.root.logger==INFO,console

?

  

6.使用telnet工具向本機的44444端口發(fā)送內(nèi)容

?

克隆會話$ telnet localhost 44444然后隨便輸入點東西看Flume是否能夠監(jiān)看到發(fā)送的內(nèi)容

?

  

案例二 :hive日志監(jiān)控

?

?1.下載并將hadoop jar包拉到flume的lib目錄下

http://flume.apache.org/ 官方文檔

?

cp ~/softwares/installtions/flume-hadoop-jar/* ~/modules/apache-flume-1.7.0-bin/lib/

?

  

2.創(chuàng)建項目二的文件夾與配置文件

?

?

mkdir jobs/job2vim jobs/job2/flume-hdfs.conf# Name the components on this agent a2.sources = r2 a2.sinks = k2 a2.channels = c2 # Describe/configure the source a2.sources.r2.type = exec a2.sources.r2.command = tail -F /home/admin/modules/apache-hive-1.2.2-bin/hive.log a2.sources.r2.shell = /bin/bash -c# Describe the sink a2.sinks.k2.type = hdfs a2.sinks.k2.hdfs.path = hdfs://linux01:8020/flume/%Y%m%d/%H #上傳文件的前綴 a2.sinks.k2.hdfs.filePrefix = logs- #是否按照時間滾動文件夾 a2.sinks.k2.hdfs.round = true #多少時間單位創(chuàng)建一個新的文件夾 a2.sinks.k2.hdfs.roundValue = 1 #重新定義時間單位 a2.sinks.k2.hdfs.roundUnit = hour #是否使用本地時間戳 a2.sinks.k2.hdfs.useLocalTimeStamp = true #積攢多少個Event才flush到HDFS一次 a2.sinks.k2.hdfs.batchSize = 1000 #設(shè)置文件類型,可支持壓縮 a2.sinks.k2.hdfs.fileType = DataStream #多久生成一個新的文件 a2.sinks.k2.hdfs.rollInterval = 600 #設(shè)置每個文件的滾動大小 a2.sinks.k2.hdfs.rollSize = 134217700 #文件的滾動與Event數(shù)量無關(guān) a2.sinks.k2.hdfs.rollCount = 0 #最小副本數(shù) a2.sinks.k2.hdfs.minBlockReplicas = 1# Use a channel which buffers events in memory a2.channels.c2.type = memory a2.channels.c2.capacity = 1000 a2.channels.c2.transactionCapacity = 100# Bind the source and sink to the channel a2.sources.r2.channels = c2 a2.sinks.k2.channel = c2

  

3.修改hive log 日志上傳目錄

vim /home/admin/modules/apache-hive-1.2.2-bin/conf/hive-log4j.properties hive.log.dir=/home/admin/modules/apache-hive-1.2.2-bin/logs在hive的根目錄創(chuàng)建logs文件夾mkdir logs

  

4.啟動案例2的flume任務(wù)

bin/flume-ng agent --conf conf/ --name a2 --conf-file jobs/job2/flume-hdfs.conf

  

5.新開會話,在新會話中啟動hive。成功的話,hive的日志已經(jīng)存到了hdfs上面的flume文件夾里面了

?

轉(zhuǎn)載于:https://www.cnblogs.com/shifu204/p/9644872.html

總結(jié)

以上是生活随笔為你收集整理的大数据(9) - Flume的安装与使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。