Elasticsearch常用命令

查看集群索引

curl 'http://172.10.58.20:9200/_cat/indices'

查看集群状态

curl 'http://172.10.58.20:9200/_cat/health'
curl 'http://172.10.58.20:9200/_cluster/health'

查看分片状态

curl -XGET 'http://172.10.58.20:9200/_cat/shards'

查看节点为master的节点唯一标识,node:下的一串值,类似 aqNkSAuaQBiOWuLVWNOdtw

curl 'http://172.10.58.20:9200/_nodes/process'

分片修复(es 2.x 及之前)

curl -XPOST 'http://172.10.58.20:9200/_cluster/reroute' -d '{
     "commands": [
        {
            "allocate": {
                "index": "索引名字",
                "shard": 分片序号,
                "node": "节点标识",
                "allow_primary": true
          }
        }
    ]
  }'

例如:修复节点为:aqNkSAuaQBiOWuLVWNOdtw;索引为:tweets;分片序号为:0   的节点

curl -XPOST 'http://172.10.58.20:9200/_cluster/reroute' -d '{
     "commands": [
        {
            "allocate": {
                "index": "tweets",
                "shard": 0,
                "node": "aqNkSAuaQBiOWuLVWNOdtw",
                "allow_primary": true
          }
        }
    ]
  }'

es 5.x 及之前,将 allocate 换成 allocate_replica 

原文地址:https://www.cnblogs.com/convict/p/14086531.html