从 firehose 迁移到输入源摄取(旧版)
Apache 在 0.17 版本中弃用了对 Druid firehose 的支持,并在 26.0 版本中移除了对 firehose 摄取的支持。
firehose 摄取在较新的 Druid 版本中无法工作,因此在升级之前,你必须改用定义了输入源的摄取规范。
从 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 摄取规范示例如下:
json
{
"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 摄取规范示例迁移为使用输入源的规范后的结果:
json
{
"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
}
}
}
}了解更多
更多信息请参阅以下页面: