5-Druid数据摄入-2

Druid 笔记一 1Apache Druid简介及架构 1.1 Druid概述 1.1.1 什么是Druid 数据分析的基础架构可以分为以下几类: 使用Hadoop/Spark进行分析 将Hadoop/Spark的结果导入 RDBMS 中提供数据分析 将结果保存到容量更大的 NoSQL 数据库中,解决数据分析的存储瓶颈,例如:HBase 将数据源进行流式处理,对接流式计算框架(如Storm、Spark、Flink),结果保存到 RDBMS或NoSQL中 将数据源进行流式处理,对接分析数据库,例如:Dr... 阅读详情

5-Druid数据摄入-2

2017年11月19日 13:38:31

阅读数:1102

  •  一、Stream Ingestion

    可以通过Tranquility (a Druid-aware client,提供负载均衡,其他服务,缺点复杂)、或者indexing service 、单个的 Realtime nodes ( limitations.)

    Stream push

    将Tranquility嵌入到Tranquility,Tranquility和Storm and Samza stream processors结合,同时它含有提供直接被JVM-based program(such as Spark Streaming or a Kafka consumer.)使用的API,以Tranquility处理partitioning, replication, service discovery, and schema rollover,使用者是需要设计schema( Tranquility README.)

    主要Tranquility server 和 the indexing service来工作

    Stream pull

    使用 Realtime Node 从 Firehose 中获取数据, Firehose 来直接连接数据源,Druid有针对不同源(Kafka, RabbitMQ等)的内置Firehose

    主要是Realtime Node 来工作,Realtime nodes优于indexing service.

    More information

    push based approach see here.

    pull based approach, see here.

    二、Stream Push

     stream loading tutorial 入门

    Druid通过Tranquility push stream到Druid,Tranquility需要自行下载,github:Tranquility

    必须确定incoming data enough (within a configurable windowPeriodof the current time),对于旧数据不会实时处理,最好用batch ingestion.

    主要依赖Tranquility server 和 the indexing service

    Server

    Druid可用Tranquility Server,由Tranquility Server来向Druid发送数据而无需开发JVM app,可以运行被 Druid middleManagers、 historical processes托管的Tranquility server

    Tranquility server 启动:

     bin/tranquility server -configFile <path_to_config_file>/server.json
    

     自定义 Tranquility Server:

    • In server.json, 自定义 properties 和dataSources.
    • 如果有服务运行Tranquility, 需要ctr-c重启

    自定义server.json, 参考 Loading your own streams tutorial 和 Tranquility Server documentation.

    Kafka

    Tranquility Kafka 用于Kafka数据的导入,无需编码只需要一个 configuration file.

    启动Tranquility server :

     bin/tranquility kafka -configFile <path_to_config_file>/kafka.json
    

    参考single-machine quickstart中配置:

    • In kafka.json, 定义 properties and dataSources.
    • 若有,重启已有的Tranquility.

    更多参考:Tranquility Kafka documentation.

    JVM apps and stream processors

    可以library(github:Tranquility)形式将Tranquility嵌入到 JVM-based applications ,使用 Core API,或者使用Tranquility内嵌的connectors(支持such as Storm, Samza, Spark Streaming, and Flink)

    Concepts

    Task creation

    Tranquility 自动建立Druid realtime indexing tasks,来处理 partitioning, replication, service discovery, and schema rollover,具体Tranquility周期性的产生一些相对短时生命周期的tasks,每个task来处理一小部分 Druid segments,通过ZooKeeper协调这些tasks,更多管理tasks的细节 Tranquility overview

    segmentGranularity and windowPeriod

    segmentGranularity

    segments覆盖的时间粒度,例如segmentGranularity为"hour",tasks产生涵盖每个小时的数据的segments

    windowPeriod 

    是允许events 的slack松弛时间,例如windowPeriod(默认10分钟)表示timestamp在10分钟之前或者10分钟之后的数据将被丢掉不处理。

    这些决定着tasks存活时间,数据在推向historical nodes前在realtime system中逗留的时间,例如segmentGranularity "hour" and windowPeriod ten minutes,tasks一直检测 an hour and ten minutes 时段的事件events

    Append only

    Druid streaming ingestion是append-only,不支持摄入数据的update和delete,若需要,使用 batch reindexing process.  batch ingest .

    Guarantees

    Tranquility 不保证 exactly once. 在一些场景下回 drop or duplicate events:

    • windowPeriod之外的数据会dropped
    • Druid Middle Manager failures次数超过配置时,部分indexed 的数据可能丢失
    • 持续的与Druid indexing service 通信断开,重试次数超预设,或者时间超过windowPeriod吗,一些events会丢失
    • Tranquility得不到indexing service应答时,Tranquility会重试这批数据,导致events重复!!!!!
    • 使用 Storm or Samza内置的Tranquility,由于一些architectures 有at-least-once的设计,可能导致events重复!!!!!

    这些概率极小,若需要100%保证建议 hybrid batch/streaming architecture

    Tranquility documentation and Configuration

    Tranquility documentation  here.Tranquility configuration:here.Tranquility's tuningConfig: here

    三、Stream Pull Ingestion

    使用 Realtime Node 从 Firehose 中获取数据, Firehose 来直接连接数据源,Druid有针对不同源(Kafka, RabbitMQ等)的内置Firehose.quickstart中不包含如何建立standalone realtime nodes,但他们可以用来代替 Tranquility server 和 the indexing service, Realtime nodes优于indexing service.

    Realtime Node Ingestion

    Real-time Node information, see here.

    Real-time Node Configuration, see Realtime Configuration.

    如何写自己的plugins对接real-time node,see Firehose.

    Realtime "specFile"

    druid.realtime.specFile样例:

     [
      {
        "dataSchema" : {
          "dataSource" : "wikipedia",
          "parser" : {
            "type" : "string",
            "parseSpec" : {
              "format" : "json",
              "timestampSpec" : {
                "column" : "timestamp",
                "format" : "auto"
              },
              "dimensionsSpec" : {
                "dimensions": ["page","language","user","unpatrolled","newPage","robot","anonymous","namespace","continent","country","region","city"],
                "dimensionExclusions" : [],
                "spatialDimensions" : []
              }
            }
          },
          "metricsSpec" : [{
            "type" : "count",
            "name" : "count"
          }, {
            "type" : "doubleSum",
            "name" : "added",
            "fieldName" : "added"
          }, {
            "type" : "doubleSum",
            "name" : "deleted",
            "fieldName" : "deleted"
          }, {
            "type" : "doubleSum",
            "name" : "delta",
            "fieldName" : "delta"
          }],
          "granularitySpec" : {
            "type" : "uniform",
            "segmentGranularity" : "DAY",
            "queryGranularity" : "NONE"
          }
        },
        "ioConfig" : {
          "type" : "realtime",
          "firehose": {
            "type": "kafka-0.8",
            "consumerProps": {
              "zookeeper.connect": "localhost:2181",
              "zookeeper.connection.timeout.ms" : "15000",
              "zookeeper.session.timeout.ms" : "15000",
              "zookeeper.sync.time.ms" : "5000",
              "group.id": "druid-example",
              "fetch.message.max.bytes" : "1048586",
              "auto.offset.reset": "largest",
              "auto.commit.enable": "false"
            },
            "feed": "wikipedia"
          },
          "plumber": {
            "type": "realtime"
          }
        },
        "tuningConfig": {
          "type" : "realtime",
          "maxRowsInMemory": 75000,
          "intermediatePersistPeriod": "PT10m",
          "windowPeriod": "PT10m",
          "basePersistDirectory": "\/tmp\/realtime\/basePersist",
          "rejectionPolicy": {
            "type": "serverTime"
          }
        }
      }
    ]

    可以配置多个one realtime stream ,一般对于每一个realtime stream 需要2-threads: 1 thread for data consumption and aggregation, 1 thread for incremental persists and other background tasks

    配置文件主要包含3部分: dataSchema, IOConfig, tuningConfig .

    DataSchema

    This field is required.

    See Ingestion

    IOConfig

    This field is required.

    Field

    Type

    Description

    Required

    typeStringalways be 'realtime'.yes
    firehoseJSON Object数据源yes
    plumberJSON ObjectWhere the data is going.yes

    Firehose

    See Firehose for more information on various firehoses.

    Plumber

    Field

    Type

    Description

    Required

    typeStringalways be 'realtime'.no

    TuningConfig

    有默认配置可用,可以自行配置优化

    Field

    Type

    Description

    Required

    typeString'realtime'.no
    maxRowsInMemoryInteger

    persisting前聚合后的行数,控制所需 JVM heap size

    indexing所需Maximum heap memory= maxRowsInMemory * (2 + maxPendingPersists).

    no (default == 75000)
    windowPeriodISO 8601 Period String默认10分钟,详见上文segmentGranularity and windowPeriodno (default == PT10m)
    intermediatePersistPeriodISO8601 Period String

    intermediate persists 的周期

    no (default == PT10m)
    basePersistDirectoryString

    The directory to put things that need persistence.

    The plumber is responsible for the actual intermediate persists

    no (default == java tmp dir)
    versioningPolicyObjectHow to version segments.no (default == based on segment start time)
    rejectionPolicyObjectControls how data sets the data acceptance policy for creating and handing off segments. More on this below.no (default == 'serverTime')
    maxPendingPersistsInteger

    Maximum number of persists that can be pending, but not started.

    If this limit would be exceeded by a new intermediate persist, ingestion will block until the currently-running persist finishes.

    no (default == 0; meaning one persist can be running concurrently with ingestion, and none can be queued up)
    shardSpecObjectshard that is represented by this server.  sharded fashion.no (default == 'NoneShardSpec')
    buildV9DirectlyBooleanWhether to build a v9 index directly instead of first building a v8 index and then converting it to v9 format.no (default == true)
    persistThreadPriorityintIf -XX:+UseThreadPriorities is properly enabled, this will set the thread priority of the persisting thread to Thread.NORM_PRIORITY plus this value within the bounds of Thread.MIN_PRIORITY and Thread.MAX_PRIORITY. A value of 0 indicates to not change the thread priority.no (default == 0; inherit and do not override)
    mergeThreadPriorityint

    If -XX:+UseThreadPriorities is properly enabled, this will set the thread priority of the merging thread to Thread.NORM_PRIORITY plus this value within the bounds of Thread.MIN_PRIORITY and Thread.MAX_PRIORITY. A value of 0 indicates to not change the thread priority.

    Before enabling thread priority settings, users are highly encouraged to read the original pull request and other documentation about proper use of -XX:+UseThreadPriorities.

    no (default == 0; inherit and do not override)
    reportParseExceptionsBooleanIf true, exceptions encountered during parsing will be thrown and will halt ingestion. If false, unparseable rows and fields will be skipped. If an entire row is skipped, the "unparseable" counter will be incremented. If some fields in a row were parseable and some were not, the parseable fields will be indexed and the "unparseable" counter will not be incremented.no (default == false)
    handoffConditionTimeoutlongMilliseconds to wait for segment handoff. It must be >= 0, where 0 means to wait forever.no (default == 0)
    alertTimeoutlongMilliseconds timeout after which an alert is created if the task isn't finished by then. This allows users to monitor tasks that are failing to finish and give up the worker slot for any unexpected errors.no (default == 0)
    indexSpecObjectTune how data is indexed. See below for more information.no

     

    Rejection Policy

    • serverTime – The recommended policy for "current time" data, it is optimal for current data that is generated and ingested in real time. Uses windowPeriod to accept only those events that are inside the window looking forward and back.
    • messageTime – Can be used for non-"current time" as long as that data is relatively in sequence. Events are rejected if they are less than windowPeriod from the event with the latest timestamp. Hand off only occurs if an event is seen after the segmentGranularity and windowPeriod (hand off will not periodically occur unless you have a constant stream of data).
    • none – All events are accepted. Never hands off data unless shutdown() is called on the configured firehose.

    IndexSpec

    Field

    Type

    Description

    Required

    bitmapObjectCompression format for bitmap indexes. Should be a JSON object; see below for options.no (defaults to Concise)
    dimensionCompressionStringCompression format for dimension columns. Choose from LZ4, LZF, or uncompressed.no (default == LZ4)
    metricCompressionStringCompression format for metric columns. Choose from LZ4, LZF, or uncompressed.no (default == LZ4)

    Bitmap types

    For Concise bitmaps:

    Field

    Type

    Description

    Required

    typeStringMust be concise.yes

    For Roaring bitmaps:

    Field

    Type

    Description

    Required

    typeStringMust be roaring.yes
    compressRunOnSerializationBooleanUse a run-length encoding where it is estimated as more space efficient.no (default == true)

    Sharding

    Druid uses shards, or segments with partition numbers, to more efficiently handle large amounts of incoming data. In Druid, shards represent the segments that together cover a time interval based on the value of segmentGranularity. If, for example, segmentGranularity is set to "hour", then a number of shards may be used to store the data for that hour. Sharding along dimensions may also occur to optimize efficiency.

    Segments are identified by datasource, time interval, and version. With sharding, a segment is also identified by a partition number. Typically, each shard will have the same version but a different partition number to uniquely identify it.

    In small-data scenarios, sharding is unnecessary and can be set to none (the default):

         "shardSpec": {"type": "none"}
    

    However, in scenarios with multiple realtime nodes, none is less useful as it cannot help with scaling data volume (see below). Note that for the batch indexing service, no explicit configuration is required; sharding is provided automatically.

    Druid uses sharding based on the shardSpec setting you configure. The recommended choices, linear and numbered, are discussed below; other types have been useful for internal Druid development but are not appropriate for production setups.

    Keep in mind, that sharding configuration has nothing to do with configured firehose. For example, if you set partition number to 0, it doesn't mean that Kafka firehose will consume only from 0 topic partition.

    Linear

    This strategy provides following advantages:

    • There is no need to update the fileSpec configurations of existing nodes when adding new nodes.
    • All unique shards are queried, regardless of whether the partition numbering is sequential or not (it allows querying of partitions 0 and 2, even if partition 1 is missing).

    Configure linear under schema:

         "shardSpec": {
            "type": "linear",
            "partitionNum": 0
        }
    

    Numbered

    This strategy is similar to linear except that it does not tolerate non-sequential partition numbering (it will not allow querying of partitions 0 and 2 if partition 1 is missing). It also requires explicitly setting the total number of partitions.

    Configure numbered under schema:

         "shardSpec": {
            "type": "numbered",
            "partitionNum": 0,
            "partitions": 2
        }
    

    Scale and Redundancy

    The shardSpec configuration can be used to create redundancy by having the same partitionNum values on different nodes.

    For example, if RealTimeNode1 has:

         "shardSpec": {
            "type": "linear",
            "partitionNum": 0
        }
    

    and RealTimeNode2 has:

         "shardSpec": {
            "type": "linear",
            "partitionNum": 0
        }
    

    then two realtime nodes can store segments with the same datasource, version, time interval, and partition number. Brokers that query for data in such segments will assume that they hold the same data, and the query will target only one of the segments.

    shardSpec can also help achieve scale. For this, add nodes with a different partionNum. Continuing with the example, if RealTimeNode3 has:

         "shardSpec": {
            "type": "linear",
            "partitionNum": 1
        }
    

    then it can store segments with the same datasource, time interval, and version as in the first two nodes, but with a different partition number. Brokers that query for data in such segments will assume that a segment from RealTimeNode3 holds different data, and the query will target it along with a segment from the first two nodes.

    You can use type numbered similarly. Note that type none is essentially type linear with all shards having a fixed partitionNum of 0.

    Constraints

    intermediatePersistPeriod ≤ windowPeriod < segmentGranularity and queryGranularity ≤ segmentGranularity

    Name

    Effect

    Minimum

    Recommended

    windowPeriod窗口时间time jitter toleranceuse this to reject outliers
    segmentGranularityTime granularity (minute, hour, day, week, month) for loading data at query timeequal to indexGranularitymore than queryGranularity
    queryGranularityTime granularity (minute, hour, day, week, month) for rollupless than segmentGranularityminute, hour, day, week, month
    intermediatePersistPeriod把数据从 memory 推到 diskavoid excessive flushing期间可以存储的行数由maxRowsInMemory决定
    maxRowsInMemory

    把数据从 memory 推到 disk前内存中存储的数据的最大行数

    intermediatePersistPeriod周期内的行数intermediatePersistPeriod 防止期间内堆溢出

     

    Kafka

    Standalone realtime nodes use the Kafka high level consumer, which imposes a few restrictions.

    Druid 在 N nodes个节点上备份数据,若其中N–1 nodes 宕机,仍可提供查询。但是 standard Kafka consumer groups 时Kafka topic 需要多个consumer(because consumers in different consumer groups will split up the data differently)时失效(Druid 无法在 N nodes个节点上备份数据)

    具体原因:

    For example, let's say your topic is split across Kafka partitions 1, 2, & 3 and you have 2 real-time nodes with linear shard specs 1 & 2. Both of the real-time nodes are in the same consumer group. Real-time node 1 may consume data from partitions 1 & 3, and real-time node 2 may consume data from partition 2. Querying for your data through the broker will yield correct results.

    The problem arises if you want to replicate your data by creating real-time nodes 3 & 4. These new real-time nodes also have linear shard specs 1 & 2, and they will consume data from Kafka using a different consumer group. In this case, real-time node 3 may consume data from partitions 1 & 2, and real-time node 4 may consume data from partition 2. From Druid's perspective, the segments hosted by real-time nodes 1 and 3 are the same, and the data hosted by real-time nodes 2 and 4 are the same, although they are reading from different Kafka partitions. Querying for the data will yield inconsistent results.

    Is this always a problem? No. If your data is small enough to fit on a single Kafka partition, you can replicate without issues. Otherwise, you can run real-time nodes without replication.

    Locking

    结合batch ingestion 使用 stream pull ingestion,可能导致 data override issues.

    例如:hourly segments 产生今日数据,同时daily batch job处理今日数据。 batch job将产生比realtime ingestion更多的segments version, 如果batch job 正在索引今日未完全完成的数据batch job 产生的daily segment 将override,realtime nodes产生的recent segments 一部分数据将会丢失

    Schema changes

    Standalone realtime nodes需要重启来更新schema.

    Log management

    standalone realtime node 有各自的日志,诊断跨多个servers的多个 partitions,将很有难度

  •  

     四、Batch Data Ingestion

     

    可以从静态文件中摄入数据

    Hadoop-based Batch Ingestion

    Hadoop-based batch ingestion 通过Hadoop-ingestion task 调起 overlord完成.:

     

     {
      "type" : "index_hadoop",
      "spec" : {
        "dataSchema" : {
          "dataSource" : "wikipedia",
          "parser" : {
            "type" : "hadoopyString",
            "parseSpec" : {
              "format" : "json",
              "timestampSpec" : {
                "column" : "timestamp",
                "format" : "auto"
              },
              "dimensionsSpec" : {
                "dimensions": ["page","language","user","unpatrolled","newPage","robot","anonymous","namespace","continent","country","region","city"],
                "dimensionExclusions" : [],
                "spatialDimensions" : []
              }
            }
          },
          "metricsSpec" : [
            {
              "type" : "count",
              "name" : "count"
            },
            {
              "type" : "doubleSum",
              "name" : "added",
              "fieldName" : "added"
            },
            {
              "type" : "doubleSum",
              "name" : "deleted",
              "fieldName" : "deleted"
            },
            {
              "type" : "doubleSum",
              "name" : "delta",
              "fieldName" : "delta"
            }
          ],
          "granularitySpec" : {
            "type" : "uniform",
            "segmentGranularity" : "DAY",
            "queryGranularity" : "NONE",
            "intervals" : [ "2013-08-31/2013-09-01" ]
          }
        },
        "ioConfig" : {
          "type" : "hadoop",
          "inputSpec" : {
            "type" : "static",
            "paths" : "/MyDirectory/example/wikipedia_data.json"
          }
        },
        "tuningConfig" : {
          "type": "hadoop"
        }
      },
      "hadoopDependencyCoordinates": <my_hadoop_version>
    }
    
    propertydescriptionrequired?
    type"index_hadoop".yes
    specA Hadoop Index Spec. See Batch Ingestionyes
    hadoopDependencyCoordinates

    Hadoop dependency coordinates(JSON array),将会覆盖 default Hadoop coordinates,

    一旦配置Druid在ocation specified by druid.extensions.hadoopDependenciesDir中查找Hadoop dependencies

    no
    classpathPrefix

    Classpath that will be pre-appended for the peon process.

    druid自动计算hadoop job containers 的classpath,当出现hadoop和druid's dependencies冲突时,手动指定classpath,setting druid.extensions.hadoopContainerDruidClasspath , base druid configuration.

    no

     

    DataSchema

    This field is required. See Ingestion.

    IOConfig

    This field is required.

    FieldTypeDescriptionRequired
    typeString'hadoop'.yes
    inputSpecObjectA specification of where to pull the data in from. See below.yes
    segmentOutputPathStringThe path to dump segments into.yes
    metadataUpdateSpecObjectA specification of how to update the metadata for the druid cluster these segments belong to.yes

    InputSpec specification

    There are multiple types of inputSpecs:

    static

    A type of inputSpec where a static path to the data files is provided.

    FieldTypeDescriptionRequired
    pathsArray of StringA String of input paths indicating where the raw data is located.yes

    For example, static input paths:

     "paths" : "s3n://billy-bucket/the/data/is/here/data.gz, s3n://billy-bucket/the/data/is/here/moredata.gz, s3n://billy-bucket/the/data/is/here/evenmoredata.gz"
    

    granularity

    A type of inputSpec that expects data to be organized in directories according to datetime using the path format: y=XXXX/m=XX/d=XX/H=XX/M=XX/S=XX (where date is represented by lowercase and time is represented by uppercase).

    FieldTypeDescriptionRequired
    dataGranularityStringSpecifies the granularity to expect the data at, e.g. hour means to expect directories y=XXXX/m=XX/d=XX/H=XX.yes
    inputPathStringBase path to append the datetime path to.yes
    filePatternStringPattern that files should match to be included.yes
    pathFormatStringJoda datetime format for each directory. Default value is "'y'=yyyy/'m'=MM/'d'=dd/'H'=HH", or see Joda documentationno

    For example, if the sample config were run with the interval 2012-06-01/2012-06-02, it would expect data at the paths:

     s3n://billy-bucket/the/data/is/here/y=2012/m=06/d=01/H=00
    s3n://billy-bucket/the/data/is/here/y=2012/m=06/d=01/H=01
    ...
    s3n://billy-bucket/the/data/is/here/y=2012/m=06/d=01/H=23
    

    dataSource

    Read Druid segments. See here for more information.

    multi

    Read multiple sources of data. See here for more information.

    TuningConfig

    The tuningConfig is optional and default parameters will be used if no tuningConfig is specified.

    FieldTypeDescriptionRequired
    workingPathStringThe working path to use for intermediate results (results between Hadoop jobs).no (default == '/tmp/druid-indexing')
    versionStringThe version of created segments. Ignored for HadoopIndexTask unless useExplicitVersion is set to trueno (default == datetime that indexing starts at)
    partitionsSpecObjectA specification of how to partition each time bucket into segments. Absence of this property means no partitioning will occur. See 'Partitioning specification' below.no (default == 'hashed')
    maxRowsInMemoryIntegerThe number of rows to aggregate before persisting. Note that this is the number of post-aggregation rows which may not be equal to the number of input events due to roll-up. This is used to manage the required JVM heap size.no (default == 75000)
    leaveIntermediateBooleanLeave behind intermediate files (for debugging) in the workingPath when a job completes, whether it passes or fails.no (default == false)
    cleanupOnFailureBooleanClean up intermediate files when a job fails (unless leaveIntermediate is on).no (default == true)
    overwriteFilesBooleanOverride existing files found during indexing.no (default == false)
    ignoreInvalidRowsBooleanIgnore rows found to have problems.no (default == false)
    combineTextBooleanUse CombineTextInputFormat to combine multiple files into a file split. This can speed up Hadoop jobs when processing a large number of small files.no (default == false)
    useCombinerBooleanUse Hadoop combiner to merge rows at mapper if possible.no (default == false)
    jobPropertiesObjectA map of properties to add to the Hadoop job configuration, see below for details.no (default == null)
    indexSpecObjectTune how data is indexed. See below for more information.no
    buildV9DirectlyBooleanWhether to build a v9 index directly instead of first building a v8 index and then converting it to v9 format.no (default == true)
    numBackgroundPersistThreadsIntegerThe number of new background threads to use for incremental persists. Using this feature causes a notable increase in memory pressure and cpu usage but will make the job finish more quickly. If changing from the default of 0 (use current thread for persists), we recommend setting it to 1.no (default == 0)
    forceExtendableShardSpecsBooleanForces use of extendable shardSpecs. Experimental feature intended for use with the Kafka indexing service extension.no (default = false)
    useExplicitVersionBooleanForces HadoopIndexTask to use version.no (default = false)

    jobProperties field of TuningConfig

        "tuningConfig" : {
         "type": "hadoop",
         "jobProperties": {
           "<hadoop-property-a>": "<value-a>",
           "<hadoop-property-b>": "<value-b>"
         }
       }
    

    Hadoop's MapReduce documentation lists the possible configuration parameters.

    With some Hadoop distributions, it may be necessary to set mapreduce.job.classpath or mapreduce.job.user.classpath.firstto avoid class loading issues. See the working with different Hadoop versions documentation for more details.

    IndexSpec

    FieldTypeDescriptionRequired
    bitmapObjectCompression format for bitmap indexes. Should be a JSON object; see below for options.no (defaults to Concise)
    dimensionCompressionStringCompression format for dimension columns. Choose from LZ4, LZF, or uncompressed.no (default == LZ4)
    metricCompressionStringCompression format for metric columns. Choose from LZ4, LZF, uncompressed, or none.no (default == LZ4)
    longEncodingStringEncoding format for metric and dimension columns with type long. Choose from auto or longs. auto encodes the values using offset or lookup table depending on column cardinality, and store them with variable size. longs stores the value as is with 8 bytes each.no (default == longs)

    Bitmap types

    For Concise bitmaps:

    FieldTypeDescriptionRequired
    typeStringMust be concise.yes

    For Roaring bitmaps:

    FieldTypeDescriptionRequired
    typeStringMust be roaring.yes
    compressRunOnSerializationBooleanUse a run-length encoding where it is estimated as more space efficient.no (default == true)

    Partitioning specification

    Segments一般基于timestamp(granularitySpec)分区,也可以有其他的 partition type.如:

     "hashed" (based on the hash of all dimensions in each row),

    "dimension" (based on ranges of a single dimension).

    Hashed partitioning 建议使用优于dimension, 有利于 indexing 性能优化,建立相对于single-dimension partitioning更格式大小统一的segments.

    Hash-based partitioning

       "partitionsSpec": {
         "type": "hashed",
         "targetPartitionSize": 5000000
       }
    

    Hashed partitioning works by first selecting a number of segments, and then partitioning rows across those segments according to the hash of all dimensions in each row. The number of segments is determined automatically based on the cardinality of the input set and a target partition size.

    The configuration options are:

    FieldDescriptionRequired
    typeType of partitionSpec to be used."hashed"
    targetPartitionSizeTarget number of rows to include in a partition, should be a number that targets segments of 500MB~1GB.either this or numShards
    numShardsSpecify the number of partitions directly, instead of a target partition size. Ingestion will run faster, since it can skip the step necessary to select a number of partitions automatically.either this or targetPartitionSize
    partitionDimensionsThe dimensions to partition on. Leave blank to select all dimensions. Only used with numShards, will be ignored when targetPartitionSize is setno

    Single-dimension partitioning

       "partitionsSpec": {
         "type": "dimension",
         "targetPartitionSize": 5000000
       }
    

    Single-dimension partitioning works by first selecting a dimension to partition on, and then separating that dimension into contiguous ranges. Each segment will contain all rows with values of that dimension in that range. For example, your segments may be partitioned on the dimension "host" using the ranges "a.example.com" to "f.example.com" and "f.example.com" to "z.example.com". By default, the dimension to use is determined automatically, although you can override it with a specific dimension.

    The configuration options are:

    FieldDescriptionRequired
    typeType of partitionSpec to be used."dimension"
    targetPartitionSizeTarget number of rows to include in a partition, should be a number that targets segments of 500MB~1GB.yes
    maxPartitionSizeMaximum number of rows to include in a partition. Defaults to 50% larger than the targetPartitionSize.no
    partitionDimensionThe dimension to partition on. Leave blank to select a dimension automatically.no
    assumeGroupedAssume that input data has already been grouped on time and dimensions. Ingestion will run faster, but may choose sub-optimal partitions if this assumption is violated.no

    Remote Hadoop Cluster

    远程Hadoop cluster, Druid _commonconfiguration folder中包含configuration *.xml files(hadoop的)若有依赖版本冲突:these docs.

    Having Problems?

    对于首次使用出现的问题可以再此找到帮助  google groups page.

Druid学习笔记(4)数据摄入总结 1. 概述Druid的数据摄入主要包括两大类: 1. 实时输入摄入:包括Pull,Push两种 - Pull:需要启动一个RealtimeNode节点,通过不同的Firehose摄取不同种类的数据源。 - Push:需要启动Tranquility或是Kafka索引服务。通过HTTP调用的方式进行数据摄入 2. 离线数据摄入:可以通过Realtime节点摄入,也可以通过索引节点启动任务摄入本文 阅读详情

相关推荐

Centos7服务器安装Apache Druid,以及文件数据摄入、kafka实时数据流摄入

1、Apache Druid简介 Apache Druid是一个实时分析型数据库,旨在对大型数据集进行快速的查询分析("OLAP"查询)。Druid最常被当做数据库来用以支持实时摄取、高性能查询和高稳定运行的应用场景,同时,Druid也通常被用来助力分析型应用的图形化界面,或者当做需要快速聚合的高并发后端API,Druid最适合应用于面向事件类型的数据。 Druid通常应用于以下场景: 点击流分析(Web端和移动端) 网络监测分析(网络性能监控) 服务指标存储 供应链分析(制造类指标) 应用性能指标分析

ytangdigl的博客 701

Spark与ApacheDruid集成与优化

1.背景介绍 1. 背景介绍 Apache Spark和Apache Druid是两个非常流行的大数据处理框架。Spark是一个通用的大数据处理框架,可以用于批处理、流处理和机器学习等多种任务。Druid则是一个高性能的实时数据分析框架,主要用于查询和分析大规模时间序列数据。 在实际应用中,我们可能需要将这两个框架结合使用,以充分发挥它们各自的优势。例如,我们可以将Spark用于数据预处理和...

AI天才研究院 1160

Druid数据摄入避坑大全:从Kafka集群配置到HDFS权限那些你容易踩的雷

本文详细解析了Druid数据摄入过程中常见的Kafka集群配置和HDFS权限管理问题,提供了从消费者组配置到Kerberos认证的实用解决方案。通过实战案例和配置示例,帮助开发者规避数据重复摄入、权限拒绝等典型错误,提升Druid数据处理的稳定性和效率。

weixin_33212799的博客 278

Apache Druid命令执行漏洞复现

CVE-2019-25646是由由阿里云安全发现的 Apache Druid 远程代码执行漏洞

weixin_53696027的博客 814

基于Druid的实时OLAP数据摄入与维度探索:Python大数据分析实战指南

在大数据实时分析领域,Apache Druid作为高性能OLAP引擎,凭借其卓越的亚秒级查询响应和强大的实时数据摄入能力,已成为众多企业构建数据洞察平台的首选。本文将从零开始,系统讲解如何使用Python生态工具对接Druid,实现实时数据流的摄入、存储优化与多维度探索分析。文章包含完整的代码示例、性能调优参数、常见问题解决方案,以及一个基于电商订单数据的端到端实战项目,帮助读者快速掌握Druid与Python结合的大数据分析技能。目录摘要1. 引言:实时OLAP的挑战与Druid的定位。

2201_76125261的博客 39

2、Druid的入门示例(使用三种不同的方式摄入数据和提交任务)

上述所有步骤就是了为得到该json,与上面通过postman执行的json是一样的(没有增加维度指标等参数,还是有些不同的)本文分为三部分,即简单示例1-通过命令和postman操作、示例2-通过druid操作和示例3-通过命令提交任务。使用Druid 分析(查询) 2022年5月8日 按照商品分类、商品区域的产品订单总额。本文主要介绍了Druid一个入门示例,使用三种不同的方式摄入数据和提交任务。以上,简单的介绍了druid的入门示例,即三种不同的方式摄入数据和提交任务。选择loca disk按钮。

alanchanchn的专栏 8万+

Druid大数据之存储和查询

Druid数据格式时间列(Timesatmp):表明每行数据的时间值,默认使用UTC时间格式并且精确到毫秒级别。这个列是数据聚合与范围查询的重要维度。维度列(Dimension):维度来自于OLAP的概念,用来标识数据行的各个类别信息。指标列(Metrics):指标对应于OLAP概念中的Fact,是用于计算和聚合的列。指标列通常是一些数字,计算操作通常包括Count,Sum,Mean等。从上表可知...

hellobabygogo3的专栏 1万+

金融行业软件测试面试题(含答案)

6、假如发现了一个BUG,跟开发本身没什么关系,涉及到理念,需求问题,如何解决?11、假如要你测试6个月期限的p2p借款产品,你应该怎么设计案例,说出测试点。17、如果京东有一个购物网页给你,你要怎么进行测试?31、我们公司自动化测试用的语言是Java,Java你不会,该怎么办?23、你们测试用的测试环境是谁给的?24、如果领导分配你的任务超出负荷,领导高估了你的能力,怎么办。26、给你一个模块测试,只有一个星期的时间你如何有效率地完成?29、如果你组长的用例写错了,但他认为是对的,你怎么处理?

crhnb的博客 918

【Druid】(六)Apache Druid 数据摄入

文章目录一、数据格式二、配置2.1 DataSchema2.1.1 parser2.1.2 metricsSpec2.1.3 GranularitySpec2.2 ioConfig2.3 tuningConfig三、从 Hadoop 加载数据3.1 加载数据3.2 查询数据四、从 kafka 加载数据4.1 准备kafka4.2 启动索引服务4.3 加载历史数据4.4 加载实时数据4.5 加载自定义kafka 主题数据 一、数据格式 摄入规范化数据:JSON、CSV、TSV 自定义格式 其他格式 二、

云祁QI 1772

APO的全面进化之路(2):走向IBP、建设端到端供应链计划体系

前一篇记录阐述了在供应链计划(Supply Chain Planning)领域里SAP的关键产品APO的不断进化之路,即部分产品从APO进化到S/4HANA,本篇将继续阐述进化之路上的另一大中坚产品力量SAP-IBP(Integrated Business Planning)。作为SAP数字化供应链(Digital Supply Chain)中供应链计划SCP的左膀右臂,S/4HANA与IBP共同完善了计划域的完整闭环。本篇作为收尾,在先谈对IBP产品的个人认知之前,特别是在当今这个IT产品迭代多、技术革新

ChampaignWolf的专栏 5233

SONiC (6) - SONiC 源码框架分析

https://github.com/sonic-net/sonic-utilitieshttps://github.com/sonic-net/sonic-snmpagenthttps://github.com/sonic-net/sonic-linux-kernelhttps://github.com/sonic-net/sonic-platform-commonhttps://github.com/sonic-net/sonic-platform-daemons以下是在 SONiC 中运行的容器列表:

qq_49477505的博客 1339

快速学习-Druid数据摄入之Tranquility

第7章 Druid数据摄入之Tranquility 在上面的内容中,我们学习了如何通过索引服务器摄取数据,然而索引服务器的API太过底层,运用起来比较麻烦。Tranquility对索引服务的API进行了封装,可以方便创建任务,处理分片,复制、服务器发现以及无缝的数据结构调整。 向Druid发送数据,需将Tranquility库依赖到程序中。 地址:https://github.com/druid-...

逍遥云恋 1125

自动化学报Ctex+texstudio配置方法

自动化学报Latex的模板win10使用方法(CTEX+texstudio)

zxy15924462502的博客 7379

Druid实战--数据摄入案例

Durid摄入数据的方式 通过imply的UI界面配置摄入数据规范Ingestion Spec 手动创建摄入数据规范Ingestion Spec,通过http请求执行 说明:下面以摄入kafka的数据为例进行步骤解析,kafka的数据格式json {"current_timestamp":"1560321490664","age12":"22","name":"wan...

阿华田的博客 1720

MiniMax H3 + ComfyUI 工作流搭建指南:从整合包到视频生成

AI视频生成正成为内容创作的新基础设施,而ComfyUI作为可视化工作流引擎,将复杂的模型推理过程拆解为节点与连线,让本地视频生成变得可复用、可批量。理解这一原理后,用户无需编写代码,只需掌握模型加载、提示词控制、采样与解码的基本链路,即可搭建出稳定的视频生产管线。MiniMax H3作为前沿视频生成模型,在ComfyUI中通过权重文件和自定义节点落地,配合整合包可大幅降低环境配置门槛。从硬件评估、目录结构到节点连接与参数调优,本文系统性梳理了从零跑通一条视频生成工作流的完整路径,帮助用户在批量素材生成、风

weixin_29057065的博客 417

从‘全步’到‘微步’:一张图看懂步进电机细分控制,选对模式让你的项目更丝滑

本文深入解析步进电机细分控制技术,从全步到微步的演进过程,帮助工程师根据项目需求选择最优控制模式。通过对比不同细分等级的性能特点和应用场景,提供3D打印、实验室自动化等领域的黄金配置方案,实现更精准、平稳的电机控制效果。

weixin_29290259的博客 471

Druid实战--摄入数据规范Ingestion Spec

简介 Schema的定义,Druid摄入数据规范的核心是dataSchema,dataSchema定义了如何解析输入的数据,并将数据存储到Druid中。ingestion spec 由三个部分组成: { "dataSchema" : {...}, "ioConfig" : {...}, "tuningConfig" : {...} } 字段 类型...

阿华田的博客 1285

coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?

🏆本文收录于《优快云问答解惑-专业版》专栏,主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!!

**My Coding Family** 2670

用 Lucky 内网穿透三步搞定:在家外的任何地方访问内网服务

Lucky 是一款面向软硬路由的公网管理工具,集成端口转发、动态域名(DDNS)、反向代理、网络唤醒(WOL)等核心功能。本文带你走完"部署、登录、配好第一条转发规则"三步,把家里的 NAS 和内网服务安全地暴露到公网,并用白名单控制谁能访问。 你在公司里,想看看家里 NAS 上的照片,打开浏览器却只能访问内网 IP,外网根本连不上。这是很常见的困扰:路由器拦截外部连接、家庭宽带公网 IP 经常

gitblog_00361的博客 995

v86.01 鸿蒙内核源码分析 (静态分配篇) | 很简单的一位小朋友 | 百篇博客分析 OpenHarmony 源码

相比动态分配,静态内存池的分配就是个小弟弟,非常的简单,两个结构体 + 一张图 就能说明白。

日拱一卒,力出一孔 775

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

用 CesiumJS 体素渲染在浏览器里展示体积数据:接入、调参、排障一次讲清

CesiumJS 体素渲染让你在浏览器中直接渲染 CT、MRI、地震波之类的三维体积数据,不用预先生成表面网格。本文基于仓库内真实 API,讲清数据怎么从原始文件走到 `VoxelPrimitive`、哪两个参数直接决定帧率,以及常见问题怎么排查。 ## 一、为什么在 Web 里画体积数据这么难 传统 WebGL 管线只擅长画三角形:把数据转成表面网格再渲染。但体积数据的核心信息在"内部"——

gitblog_00139的博客 757

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

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

时间:2018-06-11 21:57:58      阅读:36      评论:0      收藏:0      [点我收藏+]标签:file   pre   ash   ons   replica   topic   datetime   数据源   query   1. 概述Druid的数据摄入主要包括两大类: 1. 实时输入摄入:包括Pull,Push两种 - Pull:需要启动一个Re...

大JAVA解决方案 1460

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Druid Kafka indexing service (Druid 导入 Kafka 数据)

druid配置kafka

祥哥 330

大数据Druid部署、Push数据摄入实例

Druid 单机部署 有很多文章都介绍了Druid,大数据实时分析,在此我就不多说了。本文主要描述如何部署Druid的环境,Imply提供了一套完整的部署方式,包括依赖库,Druid,图形化的数据展示页面,SQL查询组件等,Push摄入数据Tranquility Server配置。 一、环境安装前准备: Java 8 https://download.oracle.com/otn-pub/jav...

liruizi的博客 2056
上一篇: Druid提供了两类截止作为Cache和查询组件
下一篇: Druid学习笔记(4)数据摄入总结
王树民
博客等级 码龄10年 912粉丝 560原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值