zoukankan      html  css  js  c++  java
  • 实时事件统计项目:优化flume:用file channel代替mem channel

    背景:利用kafka+flume+morphline+solr做实时统计

    solr从12月23号开始一直没有数据。查看日志发现,因为有一个同事加了一条格式错误的埋点数据,导致大量error。

    据推断,是因为使用mem channel占满,消息来不及处理,导致新来的数据都丢失了。

    image

    修改flume使用file channel:

    kafka2solr.sources = source_from_kafka
    kafka2solr.channels = file_channel
    kafka2solr.sinks = solrSink
    
    # For each one of the sources, the type is defined  
    kafka2solr.sources.source_from_kafka.type = org.apache.flume.source.kafka.KafkaSource
    kafka2solr.sources.source_from_kafka.channels = file_channel
    kafka2solr.sources.source_from_kafka.batchSize = 100
    kafka2solr.sources.source_from_kafka.useFlumeEventFormat=false
    kafka2solr.sources.source_from_kafka.kafka.bootstrap.servers= kafkanode0:9092,kafkanode1:9092,kafkanode2:9092
    kafka2solr.sources.source_from_kafka.kafka.topics = eventCount
    kafka2solr.sources.source_from_kafka.kafka.consumer.group.id = flume_solr_caller
    kafka2solr.sources.source_from_kafka.kafka.consumer.auto.offset.reset=latest
    
    # file channel  
    kafka2solr.channels.file_channel.type = file
    kafka2solr.channels.file_channel.checkpointDir = /var/log/flume-ng/checkpoint
    kafka2solr.channels.file_channel.dataDirs = /var/log/flume-ng/data
    
    
    kafka2solr.sinks.solrSink.type = org.apache.flume.sink.solr.morphline.MorphlineSolrSink
    kafka2solr.sinks.solrSink.channel = file_channel
    #kafka2solr.sinks.solrSink.batchSize = 1000
    #kafka2solr.sinks.solrSink.batchDurationMillis = 1000
    kafka2solr.sinks.solrSink.morphlineFile = morphlines.conf
    kafka2solr.sinks.solrSink.morphlineId=morphline1
    kafka2solr.sinks.solrSink.isIgnoringRecoverableExceptions=true

    使得数据持久化到磁盘不会丢失。

    如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】。
    如果,您希望更容易地发现我的新博客,不妨点击一下左下角的【关注我】。
    如果,您对我的博客所讲述的内容有兴趣,请继续关注我的后续博客,我是【Arli】。

    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    appium知识01-环境设置
    移动端测试基础知识02
    魔术方法和反射
    面向对象开发: 封装, 继承, 多态
    正则的用法
    内置方法, 第三方模块(math, random, pickle, json, time, os, shutil, zip, tarfile), 导入包
    推导式(列表, 集合, 字典), 生成器
    迭代器, 高阶函数(map, filter, reduce, sorted) , 递归函数
    函数globals和locals用法, LEGB原则, 闭包函数 , 匿名函数
    字符串, 列表, 元祖, 集合, 字典的相关操作和函数, 深浅copy
  • 原文地址:https://www.cnblogs.com/arli/p/6230310.html
Copyright © 2011-2022 走看看