elasticsearch 寫入優化
阿新 • • 發佈:2018-11-13
hold dice cal cluster ast int 數據 pre ber 全量dump數據時,為優化性能,可做如下優化。
- 分片設置,不分片
http://localhost:9200/test_index/_settings/
{
"index": {
"number_of_replicas": 0
}
}
- 刷新設置,不刷新
http://localhost:9200/test_index/_settings/
{
"index": {
"refresh_interval": "-1"
}
}
- translog 大小設置,調大 默認512M
http://localhost:9200/test_index/_settings/ { "index.translog.flush_threshold_size": "1024mb" }
- 如果是SSD硬盤,修改段合並速率
http://localhost:9200/_cluster/settings/
{
"persistent": {
"indices.store.throttle.max_bytes_per_sec": "200mb"
}
}
http://localhost:9200/_cluster/settings/
{
"transient": {
"indices.store.throttle.type": "none"
}
}
全量dump後,再恢復一下
- 分片設置
http://localhost:9200/test_index/_settings/ { "index": { "number_of_replicas": 5 } }
- 刷新設置,不刷新
http://localhost:9200/test_index/_settings/
{
"index": {
"refresh_interval": "1s"
}
}
- translog 大小設置
http://localhost:9200/test_index/_settings/
{
"index.translog.flush_threshold_size": "512mb"
}
當然應該使用bulk模式, elasticsearch單次提交數據盡量在15M以內。
elasticsearch 寫入優化