Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
718 views
in Technique[技术] by (71.8m points)

elasticsearch - what to do with unassigned shards

my cluster is with yellow status because some shards are unassigned. what to do with this?

I tried set cluster.routing.allocation.disable_allocation = false to all indexes, but I think this don't work because I'm using version 1.1.1.

I also tried restarting all machines, but same happens.

Any idea?

EDIT :

  • Cluster stat :

    { 
      cluster_name: "elasticsearch",
      status: "red",
      timed_out: false,
      number_of_nodes: 5,
      number_of_data_nodes: 4,
      active_primary_shards: 4689,
      active_shards: 4689,
      relocating_shards: 0,
      initializing_shards: 10,
      unassigned_shards: 758
    }
    
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are many possible reason why allocation won't occur:

  1. You are running different versions of Elasticsearch on different nodes
  2. You only have one node in your cluster, but you have number of replicas set to something other than zero.
  3. You have insufficient disk space.
  4. You have shard allocation disabled.
  5. You have a firewall or SELinux enabled. With SELinux enabled but not configured properly, you will see shards stuck in INITIALIZING or RELOCATING forever.

As a general rule, you can troubleshoot things like this:

  1. Look at the nodes in your cluster: curl -s 'localhost:9200/_cat/nodes?v'. If you only have one node, you need to set number_of_replicas to 0. (See ES documentation or other answers).
  2. Look at the disk space available in your cluster: curl -s 'localhost:9200/_cat/allocation?v'
  3. Check cluster settings: curl 'http://localhost:9200/_cluster/settings?pretty' and look for cluster.routing settings
  4. Look at which shards are UNASSIGNED curl -s localhost:9200/_cat/shards?v | grep UNASS
  5. Try to force a shard to be assigned

    curl -XPOST -d '{ "commands" : [ {
      "allocate" : {
           "index" : ".marvel-2014.05.21", 
           "shard" : 0, 
           "node" : "SOME_NODE_HERE",
           "allow_primary":true 
         } 
      } ] }' http://localhost:9200/_cluster/reroute?pretty
    
  6. Look at the response and see what it says. There will be a bunch of YES's that are ok, and then a NO. If there aren't any NO's, it's likely a firewall/SELinux problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...