ElasticSearch: Unassigned Shards, how to fix?

前端 未结 24 1229
悲&欢浪女
悲&欢浪女 2020-12-04 05:03

I have an ES cluster with 4 nodes:

number_of_replicas: 1
search01 - master: false, data: false
search02 - master: true, data: true
search03 - master: false,          


        
24条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 05:28

    By default, Elasticsearch will re-assign shards to nodes dynamically. However, if you've disabled shard allocation (perhaps you did a rolling restart and forgot to re-enable it), you can re-enable shard allocation.

    # v0.90.x and earlier
    curl -XPUT 'localhost:9200/_settings' -d '{
        "index.routing.allocation.disable_allocation": false
    }'
    
    # v1.0+
    curl -XPUT 'localhost:9200/_cluster/settings' -d '{
        "transient" : {
            "cluster.routing.allocation.enable" : "all"
        }
    }'
    

    Elasticsearch will then reassign shards as normal. This can be slow, consider raising indices.recovery.max_bytes_per_sec and cluster.routing.allocation.node_concurrent_recoveries to speed it up.

    If you're still seeing issues, something else is probably wrong, so look in your Elasticsearch logs for errors. If you see EsRejectedExecutionException your thread pools may be too small.

    Finally, you can explicitly reassign a shard to a node with the reroute API.

    # Suppose shard 4 of index "my-index" is unassigned, so you want to
    # assign it to node search03:
    curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
        "commands": [{
            "allocate": {
                "index": "my-index",
                "shard": 4,
                "node": "search03",
                "allow_primary": 1
            }
        }]
    }'
    

提交回复
热议问题