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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Flume实战采集文件内容存入HDFS

發布時間:2025/3/11 编程问答 9 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Flume实战采集文件内容存入HDFS 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、flume安裝目錄下新建文件夾 example?

2、在example下新建文件?

log-hdfs.conf

內容如下:

# Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1#exec 指的是命令 # Describe/configure the source a1.sources.r1.type = exec #F根據文件名追中, f根據文件的nodeid追中 a1.sources.r1.command = tail -F /home/hadoop/testdata/testflume.log a1.sources.r1.channels = c1# Describe the sink #下沉目標 a1.sinks.k1.type = hdfs a1.sinks.k1.channel = c1 #指定目錄, flum幫做目的替換 a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/ #文件的命名, 前綴 a1.sinks.k1.hdfs.filePrefix = events-#10 分鐘就改目錄(創建目錄), (這些參數影響/flume/events/%y-%m-%d/%H%M/) a1.sinks.k1.hdfs.round = true a1.sinks.k1.hdfs.roundValue = 10 a1.sinks.k1.hdfs.roundUnit = minute #目錄里面有文件 #------start----兩個條件,只要符合其中一個就滿足--- #文件滾動之前的等待時間(秒) a1.sinks.k1.hdfs.rollInterval = 3 #文件滾動的大小限制(bytes) a1.sinks.k1.hdfs.rollSize = 500 #寫入多少個event數據后滾動文件(事件個數) a1.sinks.k1.hdfs.rollCount = 20 #-------end-----#5個事件就往里面寫入 a1.sinks.k1.hdfs.batchSize = 5#用本地時間格式化目錄 a1.sinks.k1.hdfs.useLocalTimeStamp = true#下沉后, 生成的文件類型,默認是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
3、shell命令不斷寫數據到文件

[hadoop@nbdo3 testdata]$ while true; do echo "hello ningbo do" >> testflume.log ; sleep 0.5; done


4、在新窗口用tail 命令查看到 testflume.log文件內容不斷增加

[hadoop@nbdo3 testdata]$ tail -f testflume.log?
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do
hello ningbo do


5、啟動hadoop


6、啟動flume

flume-ng agent -c ../conf -flog-hdfs.conf ?-n a1 -Dflume.root.logger=INFO,console



7、瀏覽器進入hadoop管理界面。






總結

以上是生活随笔為你收集整理的Flume实战采集文件内容存入HDFS的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。