xxxx index created, but the operation timed out while waiting for enough shards to be started.

shard未分配问题的解决

es在head页面,看整个es集群的状态的时候,有个索引的状态是红色的,一直不见好转,shard未分配问题的解决

看es日志有如下一句话

xxxx 索引 index created, but the operation timed out while waiting for enough shards to be started.

然后就查整个原因,

使用​ Cluster Allocation Explain API,会返回集群为什么不分配分片的详细原因

GET /_cluster/allocation/explain?pretty

返回结果;

{
   "index": "analyzier_2020-04",
   "shard": 1,
   "primary": true,
   "current_state": "unassigned",
   "unassigned_info": {
      "reason": "INDEX_CREATED",
      "at": "2020-04-26T06:44:07.936Z",
      "last_allocation_status": "no"
   },
   "can_allocate": "no",
   "allocate_explanation": "cannot allocate because allocation is not permitted to any of the nodes",
   "node_allocation_decisions": [
      {
         "node_id": "HKYmGvwvQCq_BkjYSA5F1A",
         "node_name": "es-md",
         "transport_address": "192.168.1.191:9300",
         "node_attributes": {
            "box_type": "hot"
         },
         "node_decision": "no",
         "weight_ranking": 1,
         "deciders": [
            {
               "decider": "enable",
               "decision": "NO",
               "explanation": "no allocations are allowed due to cluster setting [cluster.routing.allocation.enable=none]"
            }
         ]
      }
   ]
}

用的是谷歌浏览器的sense插件,效果比在命令行使用curl方便

重点就是这个返回的描述里面有问题的原因,就是那个设置为none了,导致分片失败了。

cluster.routing.rebalance.enable
为特定类型的分片启用或禁用重新平衡:

  • all - (默认值)允许各种分片的分片平衡。
  • primaries - 仅允许主分片的分片平衡。
  • replicas - 仅允许对副本分片进行分片平衡。
  • none - 任何索引都不允许任何类型的分片平衡。

那现在把es集群的这个配置给换成all,就好了。

使用的语句

curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}'

在sense插件上就是这个截图的样子。运行结果也在图上。

完事儿之后,集群健康就成全绿了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值