1. 程式人生 > >elasticsearch 寫入優化

elasticsearch 寫入優化

hold dice cal cluster ast int 數據 pre ber

全量dump數據時,為優化性能,可做如下優化。

  1. 分片設置,不分片
http://localhost:9200/test_index/_settings/
{
  "index": {
    "number_of_replicas": 0
  }
}
  1. 刷新設置,不刷新
http://localhost:9200/test_index/_settings/
{
  "index": {
    "refresh_interval": "-1"
  }
}
  1. translog 大小設置,調大 默認512M
http://localhost:9200/test_index/_settings/
{
  "index.translog.flush_threshold_size": "1024mb"
}
  1. 如果是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後,再恢復一下

  1. 分片設置
http://localhost:9200/test_index/_settings/
{
  "index": {
    "number_of_replicas": 5
  }
}
  1. 刷新設置,不刷新
http://localhost:9200/test_index/_settings/
{
  "index": {
    "refresh_interval": "1s"
  }
}
  1. translog 大小設置
http://localhost:9200/test_index/_settings/
{
  "index.translog.flush_threshold_size": "512mb"
}

當然應該使用bulk模式, elasticsearch單次提交數據盡量在15M以內。

elasticsearch 寫入優化