根据需求,首先定义以下3大要素
采集源,即source——监控文件内容更新 :  exec  ‘tail -F file’
下沉目标,即sink——HDFS文件系统  :  hdfs sink
Source和sink之间的传递通道——channel,可用file channel 也可以用 内存channel
 
agent1.sources = source1
agent1.sinks = sin k1
agent1.channels = channel1
 
# Describe/configure tail -F source1
agent1.sources.source1.type = exec
agent1.sources.source1.command = tail -f /root/flumedata/logs/text.txt
agent1.sources.source1.channels = channel1
 
#configure host for source
agent1.sources.source1.interceptors = i1
agent1.sources.source1.interceptors.i1.type = host
agent1.sources.source1.interceptors.i1.hostHeader = hostname
 
# Describe sink1
agent1.sinks.sink1.type = hdfs
#a1.sinks.k1.channel = c1
agent1.sinks.sink1.hdfs.path =hdfs://hadoop01:9000/weblog/flume-collection/%y-%m-%d/%H-%M
agent1.sinks.sink1.hdfs.filePrefix = access_log
agent1.sinks.sink1.hdfs.maxOpenFiles = 5000
agent1.sinks.sink1.hdfs.batchSize= 10
agent1.sinks.sink1.hdfs.fileType = DataStream
agent1.sinks.sink1.hdfs.writeFormat =Text
agent1.sinks.sink1.hdfs.rollSize = 10
agent1.sinks.sink1.hdfs.rollCount = 100
agent1.sinks.sink1.hdfs.rollInterval = 6
agent1.sinks.sink1.hdfs.round = true
agent1.sinks.sink1.hdfs.roundValue = 1
agent1.sinks.sink1.hdfs.roundUnit = minute
agent1.sinks.sink1.hdfs.useLocalTimeStamp = true
 
# Use a channel which buffers events in memory
agent1.channels.channel1.type = memory
agent1.channels.channel1.keep-alive = 120
agent1.channels.channel1.capacity = 500000
agent1.channels.channel1.transactionCapacity = 600
 
# Bind the source and sink to the channel
agent1.sources.source1.channels = channel1
agent1.sinks.sink1.channel = channel1
 
然后往:/root/flumedata/logs/text.txt 这个文件中追加日期
while true
do
date >> /root/flumedata/logs/text.txt
done
 
tail -f 和 tail -F的区别:
tail -f 当文件变了,不会再输出
tail -F当文件变了,还会再输出 
 
所以,我们可以利用tail -F实现断点续传的功能:
a1.sources.r2.command=
tail  -n +$(tail -n1 /root/log) -F /root/data/nginx.log | awk 'ARGIND==1{i=$0;next}{i++;if($0~/^tail/){i=0};print $0;print i >> "/root/log";fflush("")}' /root/log- 
 
如果有多个source,那必须要配置多个:a1.sources.r2.command
 

Flume的断点续传解决的更多相关文章

  1. flume-ng version出现错误Error: Could not find or load main class org.apache.flume.tools.GetJavaPrope的解决办法

    错误: 找不到或无法加载主类 org.apache.flume.tools.GetJavaProperty或者Error: Could not find or load main class org. ...

  2. 即将上线的flume服务器面临的一系列填坑笔记

      即将上线的flume服务器面临的一系列填坑笔记 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.   一.flume缺少依赖包导致启动失败! 报错信息如下: 2018-10-17 ...

  3. log4j2 输入日志到flume

    最近想将服务的运行日志收集起来,首先了解到flume技术栈 采用flume方案定了之后有两种方式实现 1: 在应用中,log4j2直接发送日志信息到flume , 2: 通过监控log4j2 产生的日 ...

  4. Error: Could not find or load main class org.apache.flume.tools.GetJavaProperty

    问题: [root@master conf]# flume-ng version Error: Could not find or load main class org.apache.flume.t ...

  5. SparkStreaming整合Flume的pull报错解决方案

    先说下版本情况: Spark 2.4.3 Scala 2.11.12 Flume-1.6.0 Flume配置文件: simple-agent.sources = netcat-source simpl ...

  6. cdh5.47 上配置flume

    flume 配置文件 # Define a memory channel called ch1 on agent1agent1.channels.ch1.type = memoryagent1.cha ...

  7. 使用 Unity 3D 开发游戏的架构设计难点

    Unity 3D 引擎对于开发者来说,入手非常快,因为它采用的是 C# 作为开发语言,这也大大降低了开发者的门槛.但凡只要懂一门编程语言的人都能使用 Unity 3D 引擎开发,另外 Unity 3D ...

  8. zookeeper集群迁移方案

    后来问同事是怎么做的迁移:先启动一套新的集群,然后关闭老的集群,同时在老集群的一个IP:2181起了一个haproxy代理新集群以为这样,可以做到透明迁移=.=,其实是触发了ZK的bug-832导致不 ...

  9. flume file channel 异常解决

    1. 错误提示 -- ::, (SinkRunner-PollingRunner-DefaultSinkProcessor) [ERROR - org.apache.flume.SinkRunner$ ...

随机推荐

  1. P1880石子合并

    1995年的noi区间dp题,这道题AC耗时达到了数月. 有一道题叫做果子合并,也是求合并的最小花费,但是那个题是可以随便合并两堆,但是这个题只能合并相邻的两堆,并且是一个环.对于环的问题,我们一般可 ...

  2. Tarjan水题系列(5):最大半连通子图 [ZJOI2007 luogu P2272]

    题目 大意: 缩点后转为求最长链的长度和最长链的个数 思路: 看懂题就会做系列 长度和个数都可以拓扑排序后DP求得 毕竟是2007年的题 代码: 如下 #include <cstdio> ...

  3. 在linux下和Mac下如何实现快捷方式连接SSH远程服务器

    其实特别简单 在本地命令执行目录/usr/local/bin 下新建一个shell脚本 比如 #vim ssh1 写入要执行的内容连接SSH #!/usr/bin/expect -f set user ...

  4. Python 入门之 内置模块 -- collections模块

    Python 入门之 内置模块 -- collections模块 1.collections -- 基于Python自带的数据类型之上额外增加的几个数据类型 from collections ​ 在内 ...

  5. Android 开源项目及库汇总(2)

    Android 开源项目及库汇总(2) ListenToCode 2.7 2018.10.10 15:43 字数 8527 阅读 1001评论 0喜欢 29 地图 百度地图– Android百度地图 ...

  6. mybatis动态sql详情

    mybatis动态拼装sql详情 MyBatis的动态SQL是基于OGNL表达式的,它可以帮助我们方便的在SQL语句中实现某些逻辑. MyBatis中用于实现动态SQL的元素主要有: if choos ...

  7. Git小结---So far.......

    基本的: 1. 在配置了SSH Key的情况下,clone项目时使用:git clone git@github.com/用户名/仓库名.git  使用这种方式而不使用https的方式的好处在于,在pu ...

  8. easyUI解析原理

    easyUI通过parser解析器,对页面中的html元素进行查找, 如果查找到class名以easyui-开头的标签,就调用easyui对应的组件,将该标签封装成easyui的组件

  9. Bashed -- hack the box

    Introduction Target: 10.10.10.68 (OS: Linux) Kali linux: 10.10.16.44 Information Enumeration Firstly ...

  10. 浅谈XXE

    转自FReeBUF 0×00. 介绍 现在越来越多主要的web程序被发现和报告存在XXE(XML External Entity attack)漏洞,比如说facebook.paypal等等. 举个例 ...