flume常用配置4_taildir.source_memory.channel_hdfs.sink
以下配置基於版本apache-flume-1.8.0-bin
我們假定已經對flume有一定了解,並且對flume 的各個元件有一定了解。
我們演示乙個基本的
source 為 taildir源
channel 為 memory
sink 為 hdfs 型別
的配置示例:
上乙個配置中,我們對spooldir 源進行了簡單的講解,也提出了spooldir 中存在的問題,這一章我們對 1.8新推出的
taildir 進行下講解,taildir 可以完美解決 spooldir 中存在的問題。
我們對taildir的原理進行下簡單的介紹,
taildir 對乙個目錄進行監測,目錄不支援 正則,等表示式,
會生成乙個json檔案,其中記錄了每個檔案的消費偏移量。
1. 宕機後,會從偏移量繼續消費 ,所以一般不存在資料重**送的問題。
但是該功能為 1.8 的實驗性功能,目前只支援linux 環境,下面是示例配置
我們在解壓好的目錄下建立 2個子目錄 my-conf, my-bin
my-conf 存放了 對 agent (source, sink, channel) 的配置
my-bin 存放了 agent 的啟動指令碼
配置檔案
my-conf/flume-taildir-memory-hdfs.properties
# example.conf: a single-node flume configuration
# name the components on this agent
hdfs_agent.sources = r1
hdfs_agent.sinks = k1
hdfs_agent.channels = c1
# describe/configure the source
hdfs_agent.sources.r1.type = taildir
hdfs_agent.sources.r1.filegroups = f1
hdfs_agent.sources.r1.filegroups.f1 = /tmp/logs/taildir/.*\.log
hdfs_agent.sources.r1.positionfile = /tmp/logs/taildir/.flume/taildir_position.json
# describe the sink
hdfs_agent.sinks.k1.type = hdfs
hdfs_agent.sinks.k1.hdfs.path = hdfs:
hdfs_agent.sinks.k1.hdfs.rollinterval = 3600
hdfs_agent.sinks.k1.hdfs.rollsize = 1048576
hdfs_agent.sinks.k1.hdfs.rollcount = 20
hdfs_agent.sinks.k1.hdfs.fileprefix = log_%y%m%d_%h
hdfs_agent.sinks.k1.hdfs.filesuffix = .txt
hdfs_agent.sinks.k1.hdfs.filetype = datastream
hdfs_agent.sinks.k1.hdfs.uselocaltimestamp = true
# use a channel which buffers events in memory
hdfs_agent.channels.c1.type = memory
hdfs_agent.channels.c1.capacity = 1000
hdfs_agent.channels.c1.transactioncapacity = 100
# bind the source and sink to the channel
hdfs_agent.sources.r1.channels = c1
hdfs_agent.sinks.k1.channel = c1
執行指令碼
my-bin/start_taildir_memory_hdfs.sh
#!/bin/bash
root_path=$(dirname $(dirname $(readlink -f $0)))
cd $root_path
bin/flume-ng agent --conf ./conf/ -f my-conf/flume-taildir-memory-hdfs.properties -dflume.root.logger=info,console -n hdfs_agent
flume常用採集靜態檔案配置
定義三大元件的名稱 採集靜態檔案 啟動命令 bin flume ng agent c conf f dir hdfs.conf n ag1 dflume.root.logger info,console 將日誌列印在控制台,實際情況中將其放入黑洞中 配置如下 ag1.sources source1 ...
flume常用採集動態檔案配置
tail hdfs.conf 這個是解決動態檔案,檔案裡,邊放邊採集 用tail命令獲取資料,下沉到hdfs 啟動命令 bin flume ng agent c conf f tail hdfs.conf n ag1 dflume.root.logger info,console 定義三大元件的名稱...
Flume 生產配置
1.flume安裝位置 10.96.183.54 home hadoop flume 1.7.0 2.配置文件 aoi.properties aoi.channels c1 aoi.sources r1 aoi.sinks k1 aoi.sources.r1.type spooldir aoi.so...