原文地址: https://blog.csdn.net/njpjsoftdev/article/details/52956508

我们在生产环境中使用Druid也遇到了很多问题,通过阅读官网文档、源码以及社区提问解决或部分解决了很多问题,现将遇到的问题、解决方案以及调优经验总结如下:

问题一:Hadoop batch ingestion失败,日志错误为“No buckets?…“

解决方案:这个问题当初困扰了我们大概一周的时间,对于大部分刚接触Druid人来说基本都会遇到时区问题。

其实问题很简单,主要在于集群工作时区与导入数据时区不一致。由于Druid是时间序列数据库,所以对时间非常敏感。Druid底层采用绝对毫秒数存储时间,如果不指定时区,默认输出为零时区时间,即ISO8601中yyyy-MM-ddThh:mm:ss.SSSZ。我们生产环境中采用东八区,也就是Asia/Hong Kong时区,所以需要将集群所有UTC时间调整为UTC+08:00;同时导入的数据的timestamp列格式必须为:yyyy-MM-ddThh:mm:ss.SSS+08:00

问题二:Druid与Hadoop在Jackson上出现版本冲突,日志错误信息: 

解决方案:当前版本的Druid是用Hadoop-2.3.0版本进行编译的,针对上述出现的问题,要么更换Hadoop版本为2.3.0(我们生产环境就是这么做的),要么按照该文章中的方法解决: 
https://github.com/druid-io/druid/blob/master/docs/content/operations/other-hadoop.md

问题三:Segment的建议大小在300-700MB之间,我们目前是一个小时聚合一次,每小时的原始数据大概在50G左右,生成的Segments数据在10G左右,Segments过大影响查询性能,该如何处理?

解决方案: 
目前有两种途径:

  1. 减小SegmentGranularity 
    按小时粒度聚合,可以考虑减少到分钟级别,比如20分钟。
  2. 在TunningConfig中增加partitionsSpec,官方解释如下: 

问题四:索引任务在handoff失败后很长时间内无法释放,同时一直waiting for handoff,错误日志信息如下: 
2016-05-26 22:05:25,805 ERROR i.d.s.r.p.CoordinatorBasedSegmentHandoffNotifier [coordinator_handoff_scheduled_0] Exception while checking handoff for dataSource[hm_flowinfo_analysis] Segment[SegmentDescriptor{interval=2016-05-26T21:00:00.000+0800/2016-05-26T22:00:00.000+0800, version=’2016-05-26T21:00:00.000+0800’, partitionNumber=0}], Will try again after [60000]secs

解决方案: 
这个问题在Druid使用中非常常见,在社区提问的相似问题也很多,问题原因主要集中在Historical Node没有内存去加载Segment。排查此类问题的方法总结如下:

  1. 首先引用开发者对该问题的解答 
    I guess due to the network storage the segment is not being pushed to deep storage at all. 
    Do you see a segment metadata entry in DB for above segment ? 
    If no, then check for any exception in the task logs or overlord logs related to segment publishing. 
    If the metadata entry is present in the db, make sure you have enough free space available on the historical nodes to load the segments and there are no exceptions in coordinator/historical while loading the segment.

  2. 以及对handoff阶段工作流的简单解释 
    The coordinator is the process that detects the new segment built by the indexing task and signals the historical nodes to load the segment. The indexing task will only complete once it gets notification that a historical has picked up the segment so it knows it can stop serving it. The coordinator logs should help determine whether or not the coordinator noticed the new segment, if it tried to signal a historical to load it but failed, if there were rules preventing it from loading, etc. Historical logs would show you if a historical received the load order but failed for some reason (e.g. out of memory).

  3. 所以,综合上述两方面,此问题的根本原因总结如下 
    Indexing task如果长时间没有释放,是因为没有收到Historical Nodes加载成功后的返回信息。CoordinatorBasedSegmentHandoffNotifier类主要负责注册等待Handoff的Segments以及检查待Handoff的Segments的状态。 
    注册等待Handoff的Segments主要使用内部的ConcurrentMap保存Segments的相关信息; 
    检查待Handoff的Segments的状态主要通过: 
    (1)首先通过Apache curator向Zookeeper上查询Coordinator实例; 
    (2)CoordinatorClient内部封装了一个HttpClient,向存活的Coordinator实例发送HttpGet请求,获取当前集群中所有Segments的load信息List; 
    (3)对比内部缓存的ConcurrentMap与List,成功Handoff则删除信息,失败则会打印出上述log,同时Coordinator会每隔一分钟去元信息库中同步已发布的Segments,所以Handoff失败也会每隔一分钟去重试。

最终解决方案总结如下

  1. 检查元信息库是否已注册此Segment的信息,如果没有,那么检查task logs(Middle Manager)或者Overlord关于此Segment发布时的log,是否有异常抛出;

  2. 如果元信息库中已注册该Segment,那么检查Coordinator是否已检测到此Segments已生成,如果Coordinator试图通知Historical Nodes去加载但是失败了,检查是否有rules 阻止加载此Segments等;以及检查在Coordinator中通知load此Segment的Historical Nodes在加载该Segment的过程中是否出现了异常。

问题五:在0.9.1.1版本中新引入的Kafka Indexing Service,如果设置了过短的Kafka Retention时间,同时Druid消费速度又小于Retention速率,那么会出现offset过期,即还未来得及消费的数据已经被Kafka删除了,在Peon日志会一直出现offsetOutofRangeException,并且后续的所有任务全部失败。

解决方案: 
这个问题出现的情况比较极端,由于我们使用场景数据量大,同时集群带宽资源不足,所有Kafka Retention时间设置为2小时,不过Kafka提供auto.offset.reset这个策略已应对offset过期的问题,但是在spec文件中配置了{“auto.offset.reset” : “latest” },表示如果offset过期则自动rewind到最新的offset,通过跟踪Overlord日志以及Peon日志发现,Overlord日志中该配置项已生效,但是在Peon日志中该配置项被设置为“None”,“None”表示offset过期不作任何处理,只抛出异常,即offsetOutofRangeException。在Peon中不生效是因为在代码中写死了该项,主要是为了满足Exactly-once Semantics,不过开发者在写死的同时,并未考虑到如何解决这种死循环的问题。

对于该问题,开发者给出的回答如下: 
Because of your 2 hour data retention, I guess you’re hitting a case where the Druid Kafka indexing tasks are trying to read offsets that have already been deleted. This causes problems with the exactly-once transaction handling scheme, which requires that all offsets be read in order, without skipping any. The Github issue https://github.com/druid-io/druid/issues/3195 is about making this better – basically you would have an option to reset the Kafka indexing to latest (this would involve resetting the ingestion metadata Druid stores for the datasource). 
In the meantime, maybe it’s possible to make this happen less often by either extending your Kafka retention, or by setting your Druid taskDuration lower than the default of 1 hour.

所以,对于此问题,目前并没有彻底的解决方案,不过以下方案可以部分或暂时性解决:

    1. 尽量增大Kafka Retention时间,我们设置2小时确实过于极端

    2. 减少taskDuration;

    3. 在上述两个都无法彻底解决问题的情况下,可以清空元信息库中druid_dataSource表,这张表中记录了所有消费的Kafka topic对应的partition以及offset信息,同时重启MiddleManager节点。 
      不过,在0.9.2-milestone版本中,该特性应该会进一步改进,以下引入自Github : 
      The Kafka indexing service can get into a stuck state where it is trying to read the Kafka offset following the last one recorded in the dataSource metadata table but can’t read it because Kafka’s retention period has elapsed and that message is no longer available. We probably don’t want to automatically jump to a valid Kafka offset since we would have missed events and would no longer have ingested each message exactly once, so currently we start throwing exceptions and the user needs to acknowledge what happened by removing the last committed offset from the dataSource table. 
      It would be nice to include an API that will help them by either removing the dataSource table entry or setting it to a valid Kafka offset, but would still require a manual action/acknowledgment by the user.

Druid.io系列(六):问题总结的更多相关文章

  1. Druid.io系列(一):简介

    原文链接: https://blog.csdn.net/njpjsoftdev/article/details/52955676 Druid.io(以下简称Druid)是面向海量数据的.用于实时查询与 ...

  2. Druid.io系列(九):数据摄入

    1. 概述 Druid的数据摄入主要包括两大类: 1. 实时输入摄入:包括Pull,Push两种 - Pull:需要启动一个RealtimeNode节点,通过不同的Firehose摄取不同种类的数据源 ...

  3. Druid.io系列(五):查询过程

    原文链接: https://blog.csdn.net/njpjsoftdev/article/details/52956194 Druid使用JSON over HTTP 作为底层的查询语言,不过强 ...

  4. Druid.io系列(七):架构剖析

    1. 前言 Druid 的目标是提供一个能够在大数据集上做实时数据摄入与查询的平台,然而对于大多数系统而言,提供数据的快速摄入与提供快速查询是难以同时实现的两个指标.例如对于普通的RDBMS,如果想要 ...

  5. Druid.io系列(八):部署

    介绍 前面几个章节对Druid的整体架构做了简单的说明,本文主要描述如何部署Druid的环境 Imply提供了一套完整的部署方式,包括依赖库,Druid,图形化的数据展示页面,SQL查询组件等.本文将 ...

  6. Druid.io系列(三): Druid集群节点

    原文链接: https://blog.csdn.net/njpjsoftdev/article/details/52955937 1 Historical Node Historical Node的职 ...

  7. Druid.io系列(二):基本概念与架构

    原文链接:  https://blog.csdn.net/njpjsoftdev/article/details/52955788 在介绍Druid架构之前,我们先结合有关OLAP的基本原理来理解Dr ...

  8. Druid.io系列(四):索引过程分析

    原文链接: https://blog.csdn.net/njpjsoftdev/article/details/52956083 Druid底层不保存原始数据,而是借鉴了Apache Lucene.A ...

  9. Netty4.x中文教程系列(六) 从头开始Bootstrap

    Netty4.x中文教程系列(六) 从头开始Bootstrap 其实自从中文教程系列(五)一直不知道自己到底想些什么.加上忙着工作上出现了一些问题.本来想就这么放弃维护了.没想到有朋友和我说百度搜索推 ...

随机推荐

  1. c# DataTable行转列

    /// <summary> /// datatable行转列 /// </summary> /// <param name="dtSrc">来源 ...

  2. nginx Linux 开启自启

    编辑  /etc/init.d/nginx  添加一下内容   根据路劲修改. 添加可执行权限  chmod +x /etc/init.d/nginx 开启自启  chkconfig nginx on ...

  3. GridView 控制默认分页页码间距 及字体大小

    GridView 控制默认分页页码间距 及字体大小 PagerCss TD A:hover { WIDTH: 20px; COLOR: black; padding-left: 4px; paddin ...

  4. Http权威指南(cookie以及web认证机制)

    其实对于cookie,想必大家都不陌生,cookie目前主要用于客户端的识别技术. 说到客户端识别技术,就不得不说一个登录态的问题了.登录态顾名思义,用于验证用户的登录与否. 1.登录态 对于PC端网 ...

  5. java android 读写西门子PLC数据,包含S7协议和Fetch/Write协议,s7支持200smart,300PLC,1200PLC,1500PLC

    本文将使用一个gitHub开源的组件技术来读写西门子plc数据,使用的是基于以太网的TCP/IP实现,不需要额外的组件,读取操作只要放到后台线程就不会卡死线程,本组件支持超级方便的高性能读写操作 gi ...

  6. http协议知识整理

    HTTP 协议 作为web开发人员,了解一些http协议的知识很有必要.本文简单介绍了HTTP协议的知识,若有错误的地方,望大家指正. 1.HTTP协议是什么? http协议是一个应用层的协议.规定了 ...

  7. Uva12230Crossing Rivers (数学期望)

    问题: You live in a village but work in another village. You decided to follow the straight path betwe ...

  8. IOS SEL (@selector) 原理及使用总结(一)

    SEL 类成员方法的指针 可以理解 @selector()就是取类方法的编号,他的行为基本可以等同C语言的中函数指针,只不过C语言中,可以把函数名直接赋给一个函数指针,而Object-C的类不能直接应 ...

  9. CCF 集合竞价

    题目: 问题描述 某股票交易所请你编写一个程序,根据开盘前客户提交的订单来确定某特定股票的开盘价和开盘成交量. 该程序的输入由很多行构成,每一行为一条记录,记录可能有以下几种: 1. buy p s ...

  10. python模块--os模块的用法

    os.getcwd() 获取当前工作的目录,即当前python脚本工作的目录路径 os.phdir("dirname") 改变当前脚本的工作目录:相当于shell下cd os.cu ...