簡述
在上篇文章中[Apache Druid 0.18.1 compact (合併,壓縮) segements] 說明了使用 compact 任務進行合併,壓縮segement。
基本上的合併任務compact都可以滿足。
但如果遇到比較複雜的需要時,例如需要根據維度,metrics 進行重建時,compact就無法滿足需要了。
hadoop 重建任務
{
"type":"index_hadoop",
"spec":{
"dataSchema":{
"dataSource":"loginlog_1h",
"parser":{
"type":"hadoopyString",
"parseSpec":{
"format":"json",
"timestampSpec":{
"column":"timeStamp",
"format":"auto"
},
"dimensionsSpec": {
"dimensions": [
"realm_id",
"app_id",
"team_id",
"sales_team",
"member_id",
"member_name"
],
"dimensionExclusions": [
"timeStamp",
"value"
]
}
}
},
"metricsSpec": [
{
"type": "count",
"name": "count"
}
],
"granularitySpec":{
"type":"uniform",
"segmentGranularity":"DAY",
"queryGranularity": "HOUR"
}
},
"ioConfig":{
"type":"hadoop",
"inputSpec":{
"type":"dataSource",
"ingestionSpec":{
"dataSource":"loginlog_1h",
"intervals":[
"2019-01-01/2020-01-01"
]
}
}
},
"tuningConfig":{
"type":"hadoop",
"maxRowsInMemory":500000,
"partitionsSpec":{
"type":"hashed",
"targetPartitionSize":5000000
},
"numBackgroundPersistThreads":1,
"forceExtendableShardSpecs":true,
"jobProperties":{
"mapreduce.job.local.dir":"/home/druid/mapred",
"mapreduce.cluster.local.dir":"/home/mapred",
"mapred.job.map.memory.mb":4300,
"mapreduce.reduce.memory.mb":4300
}
}
}
}
hadoop 任務 與compact 任務對比
在較小的任務,不涉及數據重建的情況下建議使用compact.如果數據量比較大則建議使用hadoop任務。
任務提交地址
http://overlord:port/druid/indexer/v1/task
參考資料
https://druid.apache.org/docs/latest/ingestion/hadoop.html