2019-07-01 elasticsearch force merge 步骤 原创

  • elasticsearch版本5.6
  • 从索引的维度 , 使用cat api 查看每个索引shards , segment 的个数 . 这样就能查看出哪些索引需要做force merge.
    下面的以segment count为倒序查看所有索引的segment 和shards相关信息.
GET /_cat/indices/?s=segmentsCount:desc&v&h=index,segmentsCount,segmentsMemory,memoryTotal,mergesCurrent,mergesCurrentDocs,storeSize,p,r
image.png

上图看到的每个索引都有10个shards(5个主+5个副本),segementcount 个数上百个.

  • 对索引force merge
POST /${index_name}/_forcemerge?max_num_segments=1
  • 查看每台机器正在force_merge的线程个数
GET _cat/thread_pool/force_merge?v&s=name
image.png
  • 查看哪些索引正在被force_merge
GET /_cat/indices/?s=segmentsCount:desc&v&h=index,segmentsCount,segmentsMemory,memoryTotal,mergesCurrent,mergesCurrentDocs,storeSize,p,r
image.png
  • 使用task api 查看force merge
GET _tasks?detailed=true&actions=*forcemerge
image.png

refence

https://www.elastic.co/guide/en/elasticsearch/reference/5.6/indices-forcemerge.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/cat-indices.html

推荐阅读更多精彩内容