flume use taildir, monitor multiple folders in multiple files

In flume1.6 and earlier, if you want to monitor multiple files in multiple directories, you can use Filelistener, after flume1.7, an increase of TAILDIR, mainly to monitor file changes
described below using taildir: the
first step : create a flume in conf configuration file is created in me: job file in the flume folder, job folder is used to store my custom conf configuration file:
/ opt / Module / flume / the Job / flume- file-kafka3.conf
reads as follows:

a1.sources = r1
a1.channels = c1

a1.sources.r1.type = TAILDIR
#偏移量文件
a1.sources.r1.positionFile = /opt/module/flume/data/taildir_position.json
#文件的组,可以定义多种
a1.sources.r1.filegroups = f1 f2
#第一组监控的是test1文件夹中的什么文件:.log文件
a1.sources.r1.filegroups.f1 = /opt/module/flume/data/test1/.*log
#下面这句可以不要
#a1.sources.r1.headers.f1.headerKey1 = value1
#第二组监控的是test2文件夹中的什么文件:以.txt结尾的文件
a1.sources.r1.filegroups.f2 = /opt/module/flume/data/test2/.*txt

#下面两句可以不要
#a1.sources.r1.headers.f2.headerKey1 = value2
#a1.sources.r1.headers.f2.headerKey2 = value2-2
#a1.sources.r1.fileHeader = true
#a1.sources.ri.maxBatchCount = 1000

a1.channels.c1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.c1.kafka.bootstrap.servers = myhadoop101:9092,myhadoop102:9092,myhadoop103:9092
a1.channels.c1.kafka.topic = taildir
a1.channels.c1.kafka.consumer.group.id = taildir-consumer

a1.sources.r1.channels = c1

Step two: create a good /opt/module/flume/data/test1/.*log both file and /opt/module/flume/data/test2/.*txt

The third step: open flume monitor command

bin/flume-ng agent --conf conf/ --name a1 --conf-file job/flume-file-kafka3.conf -Dflume.root.logger=INFO,console

I was the kafka as the channel use, so my profile is not set up on the sink

Step Four: You can open a consumer to obtain data from a specified topic, the works to detect whether taildir
Summary: Use taildir, flume can monitor multiple files in multiple folders at the same time

He published 189 original articles · won praise 13 · views 10000 +

Guess you like

Origin blog.csdn.net/NewBeeMu/article/details/103061014