从 firehose 迁移到输入源(input source)摄取(旧版)
Apache 在 0.17 版本中弃用了对 Druid firehose 的支持。在 26.0 版本中,已完全移除了对 firehose 摄取的支持。
Firehose 摄取无法在较新的 Druid 版本中运行,因此在升级之前,您必须使用定义了输入源的摄取规范(ingestion spec)。
从 firehose 摄取迁移到输入源
要从 firehose 摄取迁移,您可以使用 Druid 控制台更新摄取规范,也可以手动更新。
使用 Druid 控制台
要使用 Druid 控制台更新摄取规范,请打开控制台并将您的规范复制到数据加载器的 Edit spec(编辑规范)阶段。
Druid 会自动将该规范转换为定义了输入源的格式。例如,它会将下方的 firehose 摄取规范示例转换为迁移后的摄取规范示例。
如果您无法使用控制台,或者在使用控制台方法时遇到问题,可以选择手动更新摄取规范。
手动更新您的摄取规范
要手动更新摄取规范,请将现有规范复制到一个新文件中。有关 firehose 属性的说明,请参考使用 firehose 进行原生批量摄取(已弃用)。
按照以下步骤编辑新文件:
- 在
ioConfig组件中,将firehose定义替换为您所选输入源的inputSource定义。详情请参阅原生批量输入源。 - 将
timeStampSpec定义从parser.parseSpec移动到dataSchema组件中。 - 将
dimensionsSpec定义从parser.parseSpec移动到dataSchema组件中。 - 将
format定义从parser.parseSpec移动到ioConfig中的inputFormat定义里。 - 删除
parser定义。 - 保存文件。您可以根据下方的迁移示例检查新摄取文件的格式。
- 使用临时数据源测试新的摄取规范。
- 一旦使用新规范成功摄取了样本数据,即可停止 firehose 摄取并切换到新规范。
迁移完成后,您可以将 Druid 升级到最新版本。有关升级说明,请参阅 Druid 发行说明。
Firehose 摄取规范示例
Firehose 摄取规范示例如下:
{
"type" : "index",
"spec" : {
"dataSchema" : {
"dataSource" : "wikipedia",
"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" ]
},
"parser": {
"type": "string",
"parseSpec": {
"format": "json",
"timestampSpec" : {
"column" : "timestamp",
"format" : "auto"
},
"dimensionsSpec" : {
"dimensions": ["country", "page","language","user","unpatrolled","newPage","robot","anonymous","namespace","continent","region","city"],
"dimensionExclusions" : []
}
}
}
},
"ioConfig" : {
"type" : "index",
"firehose" : {
"type" : "local",
"baseDir" : "examples/indexing/",
"filter" : "wikipedia_data.json"
}
},
"tuningConfig" : {
"type" : "index",
"partitionsSpec": {
"type": "single_dim",
"partitionDimension": "country",
"targetRowsPerSegment": 5000000
}
}
}
}
迁移后的摄取规范示例
以下示例展示了将 firehose 摄取规范示例迁移为包含输入源的规范后的结果。
{
"type" : "index",
"spec" : {
"dataSchema" : {
"dataSource" : "wikipedia",
"timestampSpec" : {
"column" : "timestamp",
"format" : "auto"
},
"dimensionsSpec" : {
"dimensions": ["country", "page","language","user","unpatrolled","newPage","robot","anonymous","namespace","continent","region","city"],
"dimensionExclusions" : []
},
"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" : "index",
"inputSource" : {
"type" : "local",
"baseDir" : "examples/indexing/",
"filter" : "wikipedia_data.json"
},
"inputFormat": {
"type": "json"
}
},
"tuningConfig" : {
"type" : "index",
"partitionsSpec": {
"type": "single_dim",
"partitionDimension": "country",
"targetRowsPerSegment": 5000000
}
}
}
}
了解更多
更多信息,请参阅以下页面:
- 摄取(Ingestion):Druid 摄取流程概述。
- 原生批量摄取:所支持的原生批量索引任务说明。
- 摄取规范参考:摄取规范中各组件和属性的说明。