Flume使用案例之实时读取目录到HDFS

楼高2年前技术文章559

目标:使用flume监听整个目录的文件

分步实现

1. 创建配置文件flume-dir.conf

#1 Agent

a3.sources = r3

a3.sinks = k3

a3.channels = c3

 

#2 source

a3.sources.r3.type = spooldir

a3.sources.r3.spoolDir = /opt/module/flume1.8.0/upload

a3.sources.r3.fileSuffix = .COMPLETED

a3.sources.r3.fileHeader = true

#忽略所有以.tmp结尾的文件,不上传

a3.sources.r3.ignorePattern = ([^ ]*\.tmp)

 

# 3 sink

a3.sinks.k3.type = hdfs

a3.sinks.k3.hdfs.path = hdfs://dtstack_hdfs:9000/flume/%H

#上传文件的前缀

a3.sinks.k3.hdfs.filePrefix = upload-

#是否按照时间滚动文件夹

a3.sinks.k3.hdfs.round = true

#多少时间单位创建一个新的文件夹

a3.sinks.k3.hdfs.roundValue = 1

#重新定义时间单位

a3.sinks.k3.hdfs.roundUnit = hour

#是否使用本地时间戳

a3.sinks.k3.hdfs.useLocalTimeStamp = true

#积攒多少个EventflushHDFS一次

a3.sinks.k3.hdfs.batchSize = 100

#设置文件类型,可支持压缩

a3.sinks.k3.hdfs.fileType = DataStream

#多久生成一个新的文件

a3.sinks.k3.hdfs.rollInterval = 600

#设置每个文件的滚动大小大概是128M

a3.sinks.k3.hdfs.rollSize = 134217700

#文件的滚动与Event数量无关

a3.sinks.k3.hdfs.rollCount = 0

#最小副本数

a3.sinks.k3.hdfs.minBlockReplicas = 1

 

# Use a channel which buffers events in memory

a3.channels.c3.type = memory

a3.channels.c3.capacity = 1000

a3.channels.c3.transactionCapacity = 100

 

# Bind the source and sink to the channel

a3.sources.r3.channels = c3

a3.sinks.k3.channel = c3

2. 执行测试:执行如下脚本后,请向upload文件夹中添加文件试试

/opt/module/flume1.8.0/bin/flume-ng agent \

--conf /opt/module/flume1.8.0/conf/ \

--name a3 \

--conf-file /opt/module/flume1.8.0/jobconf/flume-dir.conf

提示: 在使用Spooling Directory Source

1) 不要在监控目录中创建并持续修改文件

2) 上传完成的文件会以.COMPLETED结尾

3) 被监控文件夹每500毫秒扫描一次文件变动

相关文章

Redis Sentinel与Cluster安装部署(三)

4.3redis-cluster-resharding重新分配槽1、查看当前集群节点状态信息 # redis-cli --cluster check 172.32.1.59:7000 -a dt20...

tomcat目录和配置文件介绍

一、tomcat目录说明tomcat主目录bin:命令,存放不同平台上启动或关闭的脚本BUILDING.txt&RUNNING.txt:使用文档,告诉用户如何搭建conf:各种全局配置文件,最...

trino容器设置污点(六)

trino容器设置污点(六)

前提:本文前提已经部署了trino容器和k8s集群。容器设置污点1、在k8s节点中设置污点kubectl taint nodes  dm04.dtstack.com dps=1:NoSchedule2...

DG概念与机制

1. 相关概念1.1 什么是DG  DG全称Data Guard,官方给出的定义是“Oracle Data Guard ensures high availability, data protecti...

Kubernetes 网络插件

Kubernetes 自身并不提供网络解决方案,允许托管使用第三方的网络解决方案。flannelcalicocanelkube-router......各种 CNI 插件的解决方案: 虚拟网桥(bri...

oracle 回退db补丁31718723报错ins_emagent.mk:113: warning: overriding recipe for target `nmosudo'

报错内容如下:ins_emagent.mk:113: warning: overriding recipe for target `nmosudo'原因:该补丁的readme有说明该报错如下图参考mo...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。