我的群集处于黄色状态,因为某些分片未分配.该怎么办?
我尝试设置cluster.routing.allocation.disable_allocation = false
所有索引,但我认为这不起作用,因为我使用的是1.1.1版本.
我也尝试重新启动所有机器,但同样的情况发生了.
任何的想法?
编辑:
群集统计:
{ 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 }
Alcanzar.. 108
分配不会发生的原因有很多:
您在不同的节点上运行不同版本的Elasticsearch
您的群集中只有一个节点,但您将副本数设置为零以外的其他节点.
您没有足够的磁盘空间.
您已禁用分片分配.
您启用了防火墙或SELinux.启用SELinux但未正确配置后,您将看到分片永久停留在INITIALIZING或RELOCATING中.
作为一般规则,您可以解决以下问题:
查看集群中的节点:curl -s 'localhost:9200/_cat/nodes?v'
.如果您只有一个节点,则需要设置number_of_replicas
为0.(请参阅ES文档或其他答案).
查看集群中可用的磁盘空间: curl -s 'localhost:9200/_cat/allocation?v'
检查群集设置:curl 'http://localhost:9200/_cluster/settings?pretty'
并查找cluster.routing
设置
看看哪些碎片是UNASSIGNED curl -s localhost:9200/_cat/shards?v | grep UNASS
尝试强制分配分片
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
查看响应并查看其内容.会有一堆YES是好的,然后是NO.如果没有任何NO,则可能是防火墙/ SELinux问题.
这很好,谢谢 - 我用这种方式找到了我的问题.事实证明我的一个节点的Elasticsearch版本稍微落后于其他节点,因此集群拒绝将这些分片复制到它.哦,差异很小 - 1.4.2对1.4.4. (3认同)
小智.. 50
这是默认索引设置引起的常见问题,尤其是当您尝试在单个节点上进行复制时.要使用瞬态群集设置解决此问题,请执行以下操作
curl -XPUT http://localhost:9200/_settings -d '{ "number_of_replicas" :0 }'
接下来,启用群集重新分配分片(您可以在完成所有操作后始终打开它):
curl -XPUT http://localhost:9200/_cluster/settings -d ' { "transient" : { "cluster.routing.allocation.enable": true } }'
现在请坐下来观看群集清理未分配的副本分片.如果您希望此功能在将来的索引中生效,请不要忘记使用以下设置修改elasticsearch.yml文件并退回群集:
index.number_of_replicas: 0
这对我有用.windows命令供参考:curl -XPUT http:// localhost:9200/_settings -d"{"""number_of_replicas""":0}"curl -XPUT http:// localhost:9200/_cluster/settings -d" {"""transient""":{"""cluster.routing.allocation.enable""":true}}" (2认同)
eliasah.. 18
那些未分配的分片实际上是来自主节点的实际分片的未分配副本.
为了分配这些分片,您需要运行一个新的elasticsearch实例来创建一个辅助节点来承载数据副本.
编辑:有时未分配的分片属于已删除的索引,这使得它们孤立的分片无论是否添加节点都不会分配.但事实并非如此!