久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

flume1.7 新特性是什么

229次閱讀
沒有評論

共計 3089 個字符,預計需要花費 8 分鐘才能閱讀完成。

丸趣 TV 小編給大家分享一下 flume1.7 新特性是什么,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

在 flume1.7 之前如果想要監控一個文件新增的內容,我們一般采用的 source 為 exec tail , 但是這會有一個弊端,就是當你的服務器宕機重啟后,此時數據讀取還是從頭開始,這顯然不是我們想看到的!在 flume1.7 沒有出來之前我們一般的解決思路為:當讀取一條記錄后,就把當前的記錄的行號記錄到一個文件中,宕機重啟時,我們可以先從文件中獲取到最后一次讀取文件的行數,然后繼續監控讀取下去。保證數據不丟失、不重復。
      具體配置文件修改為:
    a1.sources.r3.command = tail  -n +$(tail -n1 /root/nnn) -F /root/data/web.log | awk ARGIND==1{i=$0;next}{i++;if($0~/^tail/){i=0};print $0;print i /root/nnn fflush()} /root/nnn – 
其中 /root/data/web.log 為監控的文件,/root/nnn 為保存讀取記錄的文件。

而在 flume1.7 時新增了一個 source 的類型為 taildir, 它可以監控一個目錄下的多個文件,并且實現了實時讀取記錄保存的功能!功能更加強大!  先看看官網的介紹:
-Taildir Source
Note
 
This source is provided as a preview feature. It does not work on Windows.
Watch the specified files, and tail them in nearly real-time once detected new lines appended to the each files. If the new lines are being written, this source will retry reading them in wait for the completion of the write.
This source is reliable and will not miss data even when the tailing files rotate. It periodically writes the last read position of each files on the given position file in JSON format. If Flume is stopped or down for some reason, it can restart tailing from the position written on the existing position file.
In other use case, this source can also start tailing from the arbitrary position for each files using the given position file. When there is no position file on the specified path, it will start tailing from the first line of each files by default.
Files will be consumed in order of their modification time. File with the oldest modification time will be consumed first.
This source does not rename or delete or do any modifications to the file being tailed. Currently this source does not support tailing binary files. It reads text files line by line.

需求:實現 flume 監控一個目錄下的多個文件內容,實時的收集存儲到 hadoop 集群中。

配置案例:

a1.channels = ch2

a1.sources = s1

a1.sinks = hdfs-sink1

#channel
a1.channels.ch2.type = memory

a1.channels.ch2.capacity=100000

a1.channels.ch2.transactionCapacity=50000

#source
a1.sources.s1.channels = ch2

# 監控一個目錄下的多個文件新增的內容
a1.sources.s1.type = taildir

# 通過 json 格式存下每個文件消費的偏移量,避免從頭消費
a1.sources.s1.positionFile = /var/local/apache-flume-1.7.0-bin/taildir_position.json

a1.sources.s1.filegroups = f1 f2 f3

a1.sources.s1.filegroups.f1 = /root/data/access.log

a1.sources.s1.filegroups.f2 = /root/data/nginx.log

a1.sources.s1.filegroups.f3 = /root/data/web.log

a1.sources.s1.headers.f1.headerKey = access

a1.sources.s1.headers.f2.headerKey = nginx

a1.sources.s1.headers.f3.headerKey = web

a1.sources.s1.fileHeader  = true

##sink
a1.sinks.hdfs-sink1.channel = ch2

a1.sinks.hdfs-sink1.type = hdfs

a1.sinks.hdfs-sink1.hdfs.path =hdfs://master:9000/demo/data

a1.sinks.hdfs-sink1.hdfs.filePrefix = event_data

a1.sinks.hdfs-sink1.hdfs.fileSuffix = .log

a1.sinks.hdfs-sink1.hdfs.rollSize = 10485760

a1.sinks.hdfs-sink1.hdfs.rollInterval =20

a1.sinks.hdfs-sink1.hdfs.rollCount = 0

a1.sinks.hdfs-sink1.hdfs.batchSize = 1500

a1.sinks.hdfs-sink1.hdfs.round = true

a1.sinks.hdfs-sink1.hdfs.roundUnit = minute

a1.sinks.hdfs-sink1.hdfs.threadsPoolSize = 25

a1.sinks.hdfs-sink1.hdfs.useLocalTimeStamp = true

a1.sinks.hdfs-sink1.hdfs.minBlockReplicas = 1

a1.sinks.hdfs-sink1.hdfs.fileType =DataStream

a1.sinks.hdfs-sink1.hdfs.writeFormat = Text

a1.sinks.hdfs-sink1.hdfs.callTimeout = 60000

以上是“flume1.7 新特性是什么”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-16發表,共計3089字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 池州市| 宣威市| 南充市| 卢氏县| 新密市| 延吉市| 清远市| 滁州市| 寿宁县| 明水县| 宾阳县| 台江县| 屏南县| 西畴县| 腾冲县| 海城市| 沽源县| 阿坝| 石家庄市| 水城县| 光泽县| 江陵县| 揭东县| 贡觉县| 永顺县| 寿宁县| 洪泽县| 时尚| 三江| 留坝县| 信丰县| 礼泉县| 临洮县| 张北县| 嫩江县| 略阳县| 宜都市| 托里县| 资兴市| 昌平区| 沅陵县|