問題
Apache druid 中 的實時任務 默認一個小時生成一個segement (如果是老版本,一個小時生成的數量與Kafka 的partition 數量有關),會導致集羣產生大量的 segements.根據druid 的建議 每個 segement大小 300M-700M. 有時需要進行compact
向 overlord節點提交任務地址
http://overlord:port/druid/indexer/v1/task
任務內容
保持原有granularity
{
"type": "compact",
"dataSource": "call_record_test_2",
"interval": "2015-04-01/2020-09-01",
"tuningConfig" : {
"type" : "index_parallel",
"maxRowsPerSegment" : 5000000,
"maxRowsInMemory" : 25000
}
}
修改 granularity
{
"type": "compact",
"dataSource": "compaction-tutorial",
"interval": "2015-09-12/2015-09-13",
"segmentGranularity": "DAY",
"tuningConfig" : {
"type" : "index_parallel",
"maxRowsPerSegment" : 5000000,
"maxRowsInMemory" : 25000,
"forceExtendableShardSpecs" : true
}
}
清理深度存儲文件
經過 compact 操作的segements 只是將元數據中的 segements used 標記爲 0. 不在加載數據,但數據在深度存儲中依然存在。
需要另行清除。
深度存儲清理任務
{
"type":"kill",
"dataSource":"call_record_test_2",
"interval":"2020-01-01/2020-04-01"
}
此任務將會進行兩個操作。
刪除元數據表:druid_segments 中used 爲 0的 segements .
清理深度存儲中對應的文件.
總結
druid 中還提供了一個hadoop的方式進行合併任務。這種Hadoop方式將更加的靈活,基本上的操作在hadoop中 將數據重新按照新的規則重新寫入。
hadoop任務的方式將會更加複雜些。
以後在整理相關的文章。