诊断未分配的分片

edit

诊断未分配的分片

edit

分片可能未分配的原因有很多,从配置错误的分配设置到磁盘空间不足。

为了诊断您的部署中的未分配分片,请使用以下步骤:

为了诊断未分配的分片,请按照以下步骤操作:

使用 Kibana

  1. 登录到Elastic Cloud控制台
  2. Elasticsearch Service面板上,点击您的部署名称。

    如果您的部署名称被禁用,您的 Kibana 实例可能不健康,在这种情况下,请与 Elastic 支持 联系。如果您的部署不包含 Kibana,您需要做的就是 首先启用它

  3. 打开您的部署的侧边导航菜单(位于左上角的Elastic标志下方),然后转到开发工具 > 控制台

    Kibana Console
  4. 使用cat shards API查看未分配的分片。

    GET _cat/shards?v=true&h=index,shard,prirep,state,node,unassigned.reason&s=state

    响应将会是这样的:

    [
      {
        "index": "my-index-000001",
        "shard": "0",
        "prirep": "p",
        "state": "UNASSIGNED",
        "node": null,
        "unassigned.reason": "INDEX_CREATED"
      }
    ]

    未分配的分片具有stateUNASSIGNEDprirep值对于主分片是p,对于副本是r

    示例中的索引有一个主分片未分配。

  5. 要了解为什么未分配的分片没有被分配以及您必须采取什么行动才能让 Elasticsearch 分配它,请使用 集群分配解释 API

    GET _cluster/allocation/explain
    {
      "index": "my-index-000001", 
      "shard": 0, 
      "primary": true 
    }

    我们想要诊断的索引。

    未分配的分片ID。

    表示我们正在诊断一个主分片。

    响应将会是这样的:

    {
      "index" : "my-index-000001",
      "shard" : 0,
      "primary" : true,
      "current_state" : "unassigned",                 
      "unassigned_info" : {
        "reason" : "INDEX_CREATED",                   
        "at" : "2022-01-04T18:08:16.600Z",
        "last_allocation_status" : "no"
      },
      "can_allocate" : "no",                          
      "allocate_explanation" : "Elasticsearch isn't allowed to allocate this shard to any of the nodes in the cluster. Choose a node to which you expect this shard to be allocated, find this node in the node-by-node explanation, and address the reasons which prevent Elasticsearch from allocating this shard there.",
      "node_allocation_decisions" : [
        {
          "node_id" : "8qt2rY-pT6KNZB3-hGfLnw",
          "node_name" : "node-0",
          "transport_address" : "127.0.0.1:9401",
          "roles": ["data_content", "data_hot"],
          "node_attributes" : {},
          "node_decision" : "no",                     
          "weight_ranking" : 1,
          "deciders" : [
            {
              "decider" : "filter",                   
              "decision" : "NO",
              "explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"  
            }
          ]
        }
      ]
    }

    分片的当前状态。

    分片最初变为未分配的原因。

    是否分配分片。

    是否将分片分配给特定节点。

    导致节点决策为的决定因素。

    关于决策者返回决定的原因的解释,并提供了一个有用的提示,指向导致该决定的设置。

  6. 在我们的案例中,解释表明索引分配配置不正确。 要查看您的分配设置,请使用获取索引设置集群获取设置 API。

    GET my-index-000001/_settings?flat_settings=true&include_defaults=true
    
    GET _cluster/settings?flat_settings=true&include_defaults=true
  7. 使用更新索引设置集群更新设置 API 将设置更改为正确的值,以便允许索引被分配。

有关修复未分配分片的最常见原因的更多指导,请遵循本指南或联系Elastic 支持