一、Fume-Taidir

Flume1.7.0加入了taildirSource作为agent的source。可以说是 Spooling Directory Source + Exec Source 的结合体。可以监控多个目录,并且使用正则表达式匹配该目录中的文件名进行实时收集,并记录每个文件最新消费位置,Agent进程重启后不会有重复消费的问题。

官方文档:https://flume.apache.org/FlumeUserGuide.html#taildir-source

Exec source:适用于监控一个实时追加的文件,但不能保证数据不丢失

Spooldir Source:能够保证数据不丢失,且能够实现断点续传,但延迟较高,不能实时监控

Taildir Source:既能够实现断点续传,又可以保证数据不丢失,还能够进行实时监控

Taildir Source 维护了一个 Json 格式的 positionFile,其会定期的往 positionFile 中更新每个文件读取到的最新的位置,因此能够实现断点续传。

[
{"inode":,"pos":,"file":"/tmp/upload/456.txt"},
{"inode":,"pos":,"file":"/tmp/upload/789.txt"},
{"inode":,"pos":,"file":"/tmp/upload/123.txt"}
]

配置文件示例:

agent1.sources = source1
agent1.channels = channel1
agent1.sinks = avroSink # describe/configure source1
agent1.sources.source1.type = TAILDIR
agent1.sources.source1.channels = channel1
agent1.sources.source1.channels.skipToEnd = True
# throught JSON format to record the inode, the absolute path and the last position of each tailing file.For to continual work
agent1.sources.source1.positionFile = ./taildir_position.json
# throught Space-separated list file dir which will been tail
agent1.sources.source1.filegroups = f1 f2
# define f1 info.
agent1.sources.source1.filegroups.f1 = /usr/local/tomcat/logs/ac/ac.log.*
agent1.sources.source1.headers.f1.headerKey1 = value1
agent1.sources.source1.filegroups.f2 = /usr/local/tomcat/logs/gi/gi.log.*
agent1.sources.source1.headers.f2.headerKey1 = value2
agent1.sources.source1.headers.f2.headerKey2 = value2-
agent1.sources.source1.fileHeader = true # use a channel which buffers events in memory
# type:memory or file is to temporary to save buffer data which is sink using
agent1.channels.channel1.type=memory
agent1.channels.channel1.capacity =
agent1.channels.channel1.transactionCapacity = agent1.sinks.avroSink.type = avro
agent1.sinks.avroSink.channel = channel1
agent1.sinks.avroSink.hostname = 192.168.216.201
agent1.sinks.avroSink.port =
agent1.sinks.avroSink.batch-size =

二、 Flume-ng与RocketMQ之间的消息接收和投递

Rocket-Flume:https://github.com/apache/rocketmq-externals/tree/master/rocketmq-flume

agent1.sources = source1
agent1.channels = channel1
agent1.sinks = sink1 agent1.sources.source1.type = TAILDIR
agent1.sources.source1.positionFile = /usr/local/apache-flume-1.9.-bin/db/taildir_position.json
agent1.sources.source1.filegroups = seqGenSrc
agent1.sources.source1.filegroups.seqGenSrc = /tmp/oss-yiruike-logs/raw/chaopai_push/.*txt
agent1.sources.source1.fileHeader = false
agent1.sources.source1.batchSize = agent1.channels.channel1.type = memory
agent1.channels.channel1.capacity =
agent1.channels.channel1.transactionCapacity =
agent1.channels.channel1.keep-alive = agent1.sinks.sink1.type = org.apache.rocketmq.flume.ng.sink.RocketMQSink
agent1.sinks.sink1.nameserver = 172.17.213.74:9876;172.17.213.75:9876;172.17.213.75:9876
agent1.sinks.sink1.producerGroup = MyProducerGroup_1
agent1.sinks.sink1.topic = ts-push-delineation agent1.sources.source1.channels = channel1
agent1.sinks.sink1.channel = channel1

启动Flume

# cd /usr/local/apache-flume-1.9.-bin ; nohup bin/flume-ng agent -c conf -f conf/flume.conf -n agent1 >/dev/null >& &

使用Flume-Taildir和rocketmq-flume与RocketMQ的结合的更多相关文章

  1. Flume(一)Flume原理解析

    前言 最近有一点浮躁,遇到了很多不该发生在我身上的事情.没有,忘掉这些.好好的学习,才是正道! 一.Flume简介 flume 作为 cloudera 开发的实时日志收集系统,受到了业界的认可与广泛应 ...

  2. 分布式实时日志系统(二) 环境搭建之 flume 集群搭建/flume ng资料

    最近公司业务数据量越来越大,以前的基于消息队列的日志系统越来越难以满足目前的业务量,表现为消息积压,日志延迟,日志存储日期过短,所以,我们开始着手要重新设计这块,业界已经有了比较成熟的流程,即基于流式 ...

  3. 大数据技术之_09_Flume学习_Flume概述+Flume快速入门+Flume企业开发案例+Flume监控之Ganglia+Flume高级之自定义MySQLSource+Flume企业真实面试题(重点)

    第1章 Flume概述1.1 Flume定义1.2 Flume组成架构1.2.1 Agent1.2.2 Source1.2.3 Channel1.2.4 Sink1.2.5 Event1.3 Flum ...

  4. Flume(一)Flume的基础介绍与安装

    一.背景 Hadoop业务的整体开发流程: 从Hadoop的业务开发流程图中可以看出,在大数据的业务处理过程中,对于数据的采集是十分重要的一步,也是不可避免的一步. 许多公司的平台每天会产生大量的日志 ...

  5. flume jetty 进程关系 flume jetty 跨域问题 jetty 源码分析

    flume  jetty  跨域问题 13481 httpSource的端口进程号 = flume 启动后的进程号 [root@c log]# netstat -atp Active Internet ...

  6. Flume 学习笔记之 Flume NG概述及单节点安装

    Flume NG概述: Flume NG是一个分布式,高可用,可靠的系统,它能将不同的海量数据收集,移动并存储到一个数据存储系统中.轻量,配置简单,适用于各种日志收集,并支持 Failover和负载均 ...

  7. 【Flume学习之一】Flume简介

    环境 apache-flume-1.6.0 Flume是分布式日志收集系统.可以将应用产生的数据存储到任何集中存储器中,比如HDFS,HBase:同类工具:Facebook Scribe,Apache ...

  8. RocketMQ之一:RocketMQ整体介绍

    常用MQ介绍及对比--<MQ详解及四大MQ比较> RocketMQ环境搭建--<RocketMQ之三:RocketMQ集群环境搭建> RocketMQ物理部署结构 Rocket ...

  9. Flume1 初识Flume和虚拟机搭建Flume环境

    前言:       工作中需要同步日志到hdfs,以前是找运维用rsync做同步,现在一般是用flume同步数据到hdfs.以前为了工作简单看个flume的一些东西,今天下午有时间自己利用虚拟机搭建了 ...

  10. flume ng系列之——flume安装

    flume版本:1.5.0 1.下载安装包: http://www.apache.org/dyn/closer.cgi/flume/1.5.0/apache-flume-1.5.0-bin.tar.g ...

随机推荐

  1. 虚拟机-VMware小结

    1.网卡的3种模式 桥接模式:虚拟机=物理机器,连接物理网卡,虚拟ip设置物理网卡的网段和网管.可上网. NAT模式:虚拟机把物理机器当做路由器,虚拟ip网段ip自动获取.可上网. https://w ...

  2. Linux搭建MySQL主从

    实现目标 搭建两台MySQL服务器(一主一从),一台作为主服务器,一台作为从服务器,主服务器进行写操作,从服务器进行读操作. 工作流程概述 主服务器: 开启二进制日志 配置唯一的server-id 获 ...

  3. ajax加载验证码这样不断刷新的文件无法刷新问题

    看了很多网站,在前端不设置缓存,这样会把需要缓存的数据漏掉 觉得欺骗浏览器的方式很不错,方式如下 为了在所有浏览器上都能实现点击验证码的刷新功能,我们可以在上述代码中添加随机参数,对浏览器进行欺骗. ...

  4. SpringMVC使用@Valid注解进行数据验证

    SpringMVC使用@Valid注解进行数据验证   from:https://blog.csdn.net/zknxx/article/details/52426771 我们在做Form表单提交的时 ...

  5. Flutter 数据存储之 shared_preferences

    资源名称 网址 github https://github.com/flutter/plugins/tree/master/packages/shared_preferences Flutter 数据 ...

  6. 我的洛谷签名——Pale Blue Dot

    We succeeded in taking that picture [from deep space], and, if you look at it, you see a dot. That's ...

  7. What is Babel?---JSX and React

    Babel is a JavaScript compiler Babel is a toolchain that is mainly used to convert ECMAScript 2015+ ...

  8. 无向图边双联通分量 tarjan 模板

    #include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXM = 500005 ...

  9. JavaScript基础11——ES5和ES6

    ES5↓↓↓ bind方法/this关键字     bind()方法会创建一个新函数,称为绑定函数,当调用这个绑定函数时,绑定函数会以创建它时传入bind()方法的第一个参数作为this,传入 bin ...

  10. 异常0xc000041d的抛出过程

    为了说明这个过程,我们必须写一个示例程序,如下: #include "stdafx.h" #include <tchar.h> #include <stdio.h ...