原创大约 3 分钟
调优建议
原创大约 2 分钟
基本概念
-
Source Interceptor可以指定一个或者多个拦截器,让Source按先后顺序依次对采集到的数据进行处理。
-
Channel Selectors可以指定一个或者多个选择器,让Source可以控制发往多个Channel的数据的策略。
-
Sink Processors可以指定一个或者多个处理器,让 Sink可以设置发送数据的策略。
原创大约 9 分钟
上传本地文件
首先创建Flume的配置文件。
> cd /home/work/flume-1.11.0/conf
> vi upload-file-to-hdfs.conf
# 指定source和sink到channel
b1.sources = r1
b1.channels = c1
b1.sinks = k1
# 配置source
b1.sources.r1.type = spoolDir
b1.sources.r1.spoolDir = /home/work/flume-1.11.0/test
# 配置channel
b1.channels.c1.type = file
b1.channels.c1.checkpointDir = /home/work/flume-1.11.0/checkpoint
b1.channels.c1.dataDirs = /home/work/flume-1.11.0/data
# 配置sink
b1.sinks.k1.type = hdfs
b1.sinks.k1.hdfs.path = hdfs://hadoop:9000/flume/events
b1.sinks.k1.hdfs.filePrefix = fe-
b1.sinks.k1.hdfs.writeFormat = Text
b1.sinks.k1.hdfs.fileType = DataStream
b1.sinks.k1.hdfs.rollInterval = 3600
b1.sinks.k1.hdfs.rollSize = 134217728
b1.sinks.k1.hdfs.rollCount = 0
# 绑定source和sink到channel
b1.sources.r1.channels = c1
b1.sinks.k1.channel = c1
原创大约 3 分钟