博客
关于我
flume的TaildirSource介绍及升级改造
阅读量:634 次
发布时间:2019-03-14

本文共 1374 字,大约阅读时间需要 4 分钟。

Flume 1.7.0 中引入了 taildirSource 组件,能够监控指定目录下的文件,根据正则表达式筛选文件,并支持断点续传。然而,用户发现 CDH 版本的 Flume 1.6.0 也包含该组件,而 Apache 版本的 1.7.0 则缺少 TaildirMatcher.java 以及部分代码差异,显示出 Apache 版本的实现可能更为完善。

用户选择使用 CDH 版本的 Flume 1.6.0-cdh5.5.2-bin,因其现有环境中已有该版本,没有重装 Apache 1.7.0。为了满足需求,用户配置了 Flume taildir源,并测试了其工作情况。

配置文件如下:

a1.sources = r1a1.channels = c1a1.sinks = k1a1.sources.r1.type = taildira1.sources.r1.channels = c1a1.sources.r1.positionFile = /home/hadoop/hui/taildir_position.jsona1 sourced.r1.filegroups = f1 f2a1.sources.r1.filegroups.f1 = /home/hadoop/hui/test1/.*  #匹配除换行符 \n 之外的任何单字符。*匹配前面的子表达式零次或多次a1.sources.r1.filegroups.f2 = /home/hadoop/hui/test2/.*fileHeader = truefileHeaderKey = filea1.sinks.k1.type = file_rolla1.sinks.k1.sink.directory = /home/hadoop/huia1.sinks.k1.sink.rollInterval = 0 a1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 1000

测试文件结构:

.├── messages.1├── qiang├── hui.txt├── test1│   ├── hehe.txt│   └── messages.2└── test2    ├── messages.3    ├── messages.4    └── test1 → test2/test1        ├── hehe.txt        └── messages.2

运行 Flume:

bin/flume-ng agent -c . -f conf/taildir.conf -n a1 -Dflume.root.logger=INFO,console

启动后生成文件:

1489881718232-1 → hello world hehehello world 3hello world 4

进一步测试文件改名和新内容推送:

mv test2/test1/hehe.txt test2/haha.txtecho "hello china" >> test2/test1/hehe.txt

测试结果显示 Flune 正确处理文件改名和新内容。

转载地址:http://xynoz.baihongyu.com/

你可能感兴趣的文章
opencv27-轮廓发现
查看>>
opencv28-凸包
查看>>
opencv29-轮廓周围绘制矩形框和圆形框
查看>>
OpenCV3 install tutorial for Mac
查看>>
opencv3-Mat对象
查看>>
opencv30-图像矩
查看>>
opencv32-基于距离变换和分水岭的图像分割
查看>>
opencv4-图像操作
查看>>
opencv5-图像混合
查看>>
opencv6-调整图像亮度和对比度
查看>>
opencv9-膨胀和腐蚀
查看>>
OpenCV_ cv2.imshow()
查看>>
opencv——图像缩放1(resize)
查看>>
Opencv——模块介绍
查看>>
OpenCV与AI深度学习 | 2024年AI初学者需要掌握的热门技能有哪些?
查看>>
OpenCV与AI深度学习 | CIB-SE-YOLOv8: 优化的YOLOv8, 用于施工现场的安全设备实时检测 !
查看>>
OpenCV与AI深度学习 | OpenCV图像拼接--Stitching detailed使用与参数介绍
查看>>
OpenCV与AI深度学习 | OpenCV快速傅里叶变换(FFT)用于图像和视频流的模糊检测(建议收藏!)
查看>>
OpenCV与AI深度学习 | SAM2(Segment Anything Model 2)新一代分割一切大模型介绍与使用(步骤 + 代码)
查看>>
OpenCV与AI深度学习 | YOLO11介绍及五大任务推理演示(目标检测,图像分割,图像分类,姿态检测,带方向目标检测)
查看>>