Flume线上日志采集【模板】

预装软件

Java

HDFS

Lzo/Lzop

系统版本

Flume 1.5.0-cdh5.4.0

系统流程图

flume-env.sh配置文件

export JAVA_HOME=/usr/local/jdk1.7.0_55

export JAVA_OPTS="-Xms100m -Xmx2000m -Dcom.sun.management.jmxremote"

单机版写HDFS配置文件

[root@bs038 conf]# more flume_directHDFS.conf

#Define agent

agent1.channels=ch1

agent1.sources=avro-source1

agent1.sinks=log-sink1

#Defineamemorychannelcalledch1onagent1

agent1.channels.ch1.type=memory

agent1.channels.ch1.capacity=100000

agent1.channels.ch1.transactionCapacity=100000

agent1.channels.ch1.keep-alive=30

agent1.sources.avro-source1.interceptors = i1

agent1.sources.avro-source1.interceptors.i1.type = timestamp

#definesourcemonitorafile

agent1.sources.avro-source1.type=exec

agent1.sources.avro-source1.shell=/bin/bash -c

#agent1.sources.avro-source1.command=tail-n+0-F/home/storm/tmp/id.txt

agent1.sources.avro-source1.command=tail -F test.log

agent1.sources.avro-source1.channels=ch1

agent1.sources.avro-source1.threads=5

#Definealoggersinkthatsimplylogsalleventsitreceives

#andconnectittotheotherendofthesamechannel.

agent1.sinks.log-sink1.channel=ch1

agent1.sinks.log-sink1.type=hdfs

agent1.sinks.log-sink1.hdfs.path=/user/hadoop/cndns/flume/%Y%m%d%M

agent1.sinks.log-sink1.hdfs.writeFormat=Text

agent1.sinks.log-sink1.hdfs.filePrefix=cdns

agent1.sinks.log-sink1.hdfs.inUseSuffix=.tmp

#agent1.sinks.log-sink1.hdfs.fileType=DataStream

agent1.sinks.log-sink1.hdfs.fileType=CompressedStream

agent1.sinks.log-sink1.hdfs.codeC=lzop

agent1.sinks.log-sink1.hdfs.rollInterval=0

agent1.sinks.log-sink1.hdfs.rollSize=67108864

agent1.sinks.log-sink1.hdfs.rollCount=0

agent1.sinks.log-sink1.hdfs.batchSize=1000

agent1.sinks.log-sink1.hdfs.txnEventMax=1000

agent1.sinks.log-sink1.hdfs.callTimeout=60000

agent1.sinks.log-sink1.hdfs.appendTimeout=60000

终端配置文件

[root@bs038 conf]# more agent038.conf

agent1.sources = avro-source1

agent1.sinks = k1

agent1.channels = c1

agent1.sinks.k1.type = avro

agent1.sinks.k1.hostname = bs022.zx.nicx.cn

agent1.sinks.k1.port = 44444

#Defineamemorychannelcalledch1onagent1

agent1.channels.ch1.type=memory

agent1.channels.ch1.capacity=100000

agent1.channels.ch1.transactionCapacity=100000

agent1.channels.ch1.keep-alive=30

agent1.sources.avro-source1.interceptors = i1

agent1.sources.avro-source1.interceptors.i1.type = timestamp

agent1.sources.avro-source1.type=exec

agent1.sources.avro-source1.shell=/bin/bash -c

agent1.sources.avro-source1.command=tail -F test.log

agent1.sources.avro-source1.channels=ch1

agent1.sources.avro-source1.threads=5

agent1.channels.c1.type = file

agent1.channels.c1.checkpointDir = flume.checkpoint

agent1.channels.c1.dataDirs = flume.data

agent1.channels.c1.capacity = 200000000

agent1.channels.c1.keep-alive = 30

agent1.channels.c1.write-timeout = 30

agent1.channels.c1.checkpoint-timeout=600

agent1.sources.avro-source1.channels = c1

agent1.sinks.k1.channel = c1

中间传输流配置文件

agent2.sources = r2

agent2.sinks = k2

agent2.channels = c2

agent2.sources.r2.type = avro

agent2.sources.r2.bind = bs022.zx.nicx.cn

agent2.sources.r2.port = 44444

agent2.sinks.k2.type = avro

agent2.sinks.k2.hostname = bs042.zx.nicx.cn

agent2.sinks.k2.port = 55555

agent2.channels.c2.type = file

agent2.channels.c2.checkpointDir = flume.checkpoint

agent2.channels.c2.dataDirs = flume.data

agent2.channels.c2.capacity = 200000000

agent2.channels.c2.keep-alive = 30

agent2.channels.c2.write-timeout = 30

agent2.channels.c2.checkpoint-timeout=600

agent2.sources.r2.channels = c2

agent2.sinks.k2.channel = c2

写HDFS配置文件

[root@bs042 flume-ng-1.5.0-cdh5.4.0]# more conf/agent042.conf

#Define agent

agent1.channels=ch1

agent1.sources=avro-source1

agent1.sinks=log-sink1

#definesourcemonitorafile

agent1.sources.avro-source1.type = avro

agent1.sources.avro-source1.bind = bs042.zx.nicx.cn

agent1.sources.avro-source1.port = 55555

agent1.sources.avro-source1.interceptors = i1

agent1.sources.avro-source1.interceptors.i1.type = timestamp

#Definealoggersinkthatsimplylogsalleventsitreceives

#andconnectittotheotherendofthesamechannel.

agent1.sinks.log-sink1.channel=ch1

agent1.sinks.log-sink1.type=hdfs

agent1.sinks.log-sink1.hdfs.path=/user/hadoop/cndns/flume/%Y%m%d

agent1.sinks.log-sink1.hdfs.writeFormat=Text

agent1.sinks.log-sink1.hdfs.filePrefix=cdns

agent1.sinks.log-sink1.hdfs.inUseSuffix=.tmp

#agent1.sinks.log-sink1.hdfs.fileType=DataStream

agent1.sinks.log-sink1.hdfs.fileType=CompressedStream

agent1.sinks.log-sink1.hdfs.codeC=lzop

agent1.sinks.log-sink1.hdfs.rollInterval=0

agent1.sinks.log-sink1.hdfs.rollSize=67108864

agent1.sinks.log-sink1.hdfs.rollCount=0

agent1.sinks.log-sink1.hdfs.batchSize=1000

agent1.sinks.log-sink1.hdfs.txnEventMax=1000

agent1.sinks.log-sink1.hdfs.callTimeout=60000

agent1.sinks.log-sink1.hdfs.appendTimeout=60000

#Defineamemorychannelcalledch1onagent1

agent1.channels.ch1.type = file

agent1.channels.ch1.checkpointDir = flume.checkpoint

agent1.channels.ch1.dataDirs = flume.data

agent1.channels.ch1.capacity = 200000000

agent1.channels.ch1.keep-alive = 30

agent1.channels.ch1.write-timeout = 30

agent1.channels.ch1.checkpoint-timeout=600

agent1.sources.avro-source1.channels = ch1

agent1.sinks.log-sink1.channel = ch1

tail -F断点续传问题

tail -n +$(tail -n1 num) -F test.log 2>&1 | awk 'ARGIND==1{i=$0;next}{i++;if($0~/^tail/){i=0};print $0;print i >> "num";fflush("")}' num –

【注】

Flume线上日志采集【模板】的更多相关文章

  1. 研发流程 接口定义&开发&前后端联调 线上日志观察 模型变动

    阿里等大厂的研发流程,进去前先了解一下_我们一起进大厂 - SegmentFault 思否 https://segmentfault.com/a/1190000021831640 接口定义 测试用例评 ...

  2. Nodejs线上日志部署

    Nodejs 被越来越多的使用到线上系统中,但线上系统没有日志怎么行呢. 一.forever记录日志 我的线上系统使用forever来启动服务,最开始就直接使用了forever来记录 forever ...

  3. 线上日志集中化可视化管理:ELK

    本文来自网易云社区 作者:王贝 为什么推荐ELK: 当线上服务器出了问题,我们要做的最重要的事情是什么?当需要实时监控跟踪服务器的健康情况,我们又要拿什么去分析?大家一定会说,去看日志,去分析日志.是 ...

  4. 从线上日志统计接口访问量QPS

    这一阵子在面试,连续遇到好几家(大小厂都有)问我的项目线上qps的情况了,说实话,我作为一个大头兵,本来没关注过这个数据,只能含混地给个"大概.也许"的回答. 回来之后,我决定对业 ...

  5. 查看线上日志利器less

    less实用命令 搜索 很多关于命令的解释有点令人困惑,因为前字,forward是向前,before也是前面. 上表示backward 下表示forward 向下搜索 / - 使用一个模式进行搜索,并 ...

  6. 记一次ArrayList产生的线上OOM问题

    前言:本以为(OutOfMemoryError)OOM问题会离我们很远,但在一次生产上线灰度的过程中就出现了Java.Lang.OutOfMemoryError:Java heap space异常,通 ...

  7. Java架构师线上问题排查,这些命令程序员一定用得到!

    Java架构师线上问题排查,这些命令程序员一定用得到! 线上问题排查,以下场景,你遇到过吗? 一.了解机器连接数情况 问题:1.2.3.4的sshd的监听端口是22,如何统计1.2.3.4的sshd服 ...

  8. 原创 记录一次线上Mysql慢查询问题排查过程

    背景 前段时间收到运维反馈,线上Mysql数据库凌晨时候出现慢查询的报警,并把原始sql发了过来: --去除了业务含义的sql update test_user set a=1 where id=1; ...

  9. 基于Flume+LOG4J+Kafka的日志采集架构方案

    本文将会介绍如何使用 Flume.log4j.Kafka进行规范的日志采集. Flume 基本概念 Flume是一个完善.强大的日志采集工具,关于它的配置,在网上有很多现成的例子和资料,这里仅做简单说 ...

随机推荐

  1. VMware ESXi 5.5无法与Windows 2012 NTP Server同步时间

    这次笔者需要面对的环境对时间的同步有比较高的要求, 而虚拟化的环境中时间是比较容易出问题的, 您可以参考上一篇博文为什么Domain controller上的time synchronization非 ...

  2. C#-MessageBox全部函数重载形式及举例

    Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.D ...

  3. 【云计算】使用privilege权限对Docker内核参数进行定制

    探讨Docker容器中修改系统变量的方法 探讨完Docker对共享内存状态持久化的支持状况后,我将遗留产品build到一个pre-production image中,测试启动是否OK.很显然,我过于乐 ...

  4. Windows Server 2012 R2如何编辑hosts文件

    在我的Windows Server 2012 R2系统里编辑hosts文件则会出现没有无法保存的问题,原因是权限不足 错误信息:" Unable to save C:\Windows\Sys ...

  5. Cognos权限认证CJP方式之用户密码加密

    在项目开发过程中,用户往往对系统的安全都有明确的要求,下面针对cognos门户认证用户密码如何加密来提供一个简单的wf 1Cognos权限认证方式:CJP 2Cognos用户数据库类型:Oracle ...

  6. [Node.js] 4. Modules

    4.2 Missing Exports Notice the two different files: high_five.js on the left side andapp.js on the r ...

  7. [AngularJS] Angular 1.3 ng-model-options - getterSetter

    getterSetter:  boolean value which determines whether or not to treat functions bound to ngModel as ...

  8. sql分页性能测试结果

    --方案一: declare @d datetime set @d = getdate() ID from Info order by ID) order by ID select [not in方法 ...

  9. Android Api Component---翻译任务和回退栈(Tasks and Back Stack)

    一个应用程序通常包括多个activity.每个activity应当环绕一个指定的用户能够运行的而且能够开启其他activity的动作种类被设计. 比如,一个emali应用程序或许有一个activity ...

  10. gem 更新源设置,ruby安装

    gem sources --remove http://rubygems.org/ gem sources -a http://ruby.taobao.org/ gem sources -l 结果只有 ...