Elasticsearch7.11 "reason" : "INDEX_CREATED" a copy of this shard is already allocated to this node

  • 在kiban终端中, 运行集群健康状态命令
GET /_cluster/health

{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 11,
  "active_shards" : 11,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 2,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 84.61538461538461
}
GET /_cluster/allocation/explain
{
  "index" : "rread_me",
  "shard" : 0,
  "primary" : false,
  "current_state" : "unassigned",
  "unassigned_info" : {
    "reason" : "INDEX_CREATED",
    "at" : "2021-03-04T06:23:29.218Z",
    "last_allocation_status" : "no_attempt"
  },
  "can_allocate" : "no",
  "allocate_explanation" : "cannot allocate because allocation is not permitted to any of the nodes",
  "node_allocation_decisions" : [
    {
      "node_id" : "p8hSt2cqQfShoeuGQSFe9Q",
      "node_name" : "node-1",
      "transport_address" : "xxx.xx.xx.xx:9300",
      "node_attributes" : {
        "ml.machine_memory" : "1922101248",
        "xpack.installed" : "true",
        "transform.node" : "true",
        "ml.max_open_jobs" : "20"
      },
      "node_decision" : "no",
      "deciders" : [
        {
          "decider" : "same_shard",
          "decision" : "NO",
          "explanation" : "a copy of this shard is already allocated to this node [[rread_me][0], node[p8hSt2cqQfShoeuGQSFe9Q], [P], s[STARTED], a[id=ntehmVVoS7yeIiTyahaL6A]]"
        }
      ]
    }
  ]
}

  • 根据集群异常的解释信息,定位原因

在返回结果中给出了导致分片未分配的详细信息,reason 给出了分片最初未分配的原因,可以理解成 unassigned 是什么操作触发的;
allocate_explanation 则进一步的说明,该分片无法被分配到任何节点,而无法分配的具体原因在 deciders 的 explanation 信息中详细描述。这些信息足够我们诊断问题。

本案例中a copy of this shard is already allocated to this node是集群yellow的详细原因, 这个由于这个复制分片已经分配到此节点, 那么解决方案就是把复制分片设置为0【number_of_replicas: 0】, 根据上面的解释是index:rread_me已有分片,

PUT /rread_me/_settings
{
  "number_of_replicas": 0
}
  • 继续查看集群健康状态
GET /_cluster/health

{
  "cluster_name" : "elasticsearch",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 11,
  "active_shards" : 11,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
posted @ 2021-03-04 14:39  phper-liunian  阅读(2068)  评论(1编辑  收藏  举报