企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Cluster Allocation Explain API **cluster allocation explanation API** 的目的是帮助回答这个问题 “为什么这个分片没有被分配”。为了说明分片的分配(未分配状态),发出一个这样的请求 :  | `$ curl -XGET ``'[http://localhost:9200/_cluster/allocation/explain'](http://localhost:9200/_cluster/allocation/explain')` `-d'{` `"index"``: ``"myindex"``,` `"shard"``: 0,` `"primary"``: ``false` `}'` | 指定您希望查看的说明的 **index** 和 **shard** 的 **id**,和 **primary** 标记一样来指出是否 **explain** 一个主或者副本分片。 该响应如下 :  | `{` `"shard"` `: {` `"index"` `: ``"myindex"``,` `"index_uuid"` `: ``"KnW0-zELRs6PK84l0r38ZA"``,` `"id"` `: 0,` `"primary"` `: ``false` `},` `"assigned"` `: ``false``,                             ①` `"shard_state_fetch_pending"``: ``false``,             ②` `"unassigned_info"` `: {` `"reason"` `: ``"INDEX_CREATED"``,                   ③` `"at"` `: ``"2016-03-22T20:04:23.620Z"` `},` `"allocation_delay_ms"` `: 0,                      ④` `"remaining_delay_ms"` `: 0,                       ⑤` `"nodes"` `: {` `"V-Spi0AyRZ6ZvKbaI3691w"` `: {` `"node_name"` `: ``"H5dfFeA"``,` `"node_attributes"` `: {                       ⑥` `"bar"` `: ``"baz"` `},` `"store"` `: {` `"shard_copy"` `: ``"NONE"`                     `⑦` `},` `"final_decision"` `: ``"NO"``,                    ⑧` `"final_explanation"` `: ``"the shard cannot be assigned because one or more allocation decider returns a 'NO' decision"``,` `"weight"` `: 0.06666675,                      ⑨` `"decisions"` `: [ {                           ⑩` `"decider"` `: ``"filter"``,` `"decision"` `: ``"NO"``,` `"explanation"` `: ``"node does not match index include filters [foo:\"bar\"]"` `} ]` `},` `"Qc6VL8c5RWaw1qXZ0Rg57g"` `: {` `"node_name"` `: ``"bGG90GE"``,` `"node_attributes"` `: {` `"bar"` `: ``"baz"``,` `"foo"` `: ``"bar"` `},` `"store"` `: {` `"shard_copy"` `: ``"AVAILABLE"` `},` `"final_decision"` `: ``"NO"``,` `"final_explanation"` `: ``"the shard cannot be assigned because one or more allocation decider returns a 'NO' decision"``,` `"weight"` `: -1.3833332,` `"decisions"` `: [ {` `"decider"` `: ``"same_shard"``,` `"decision"` `: ``"NO"``,` `"explanation"` `: ``"the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists"` `} ]` `},` `"PzdyMZGXQdGhqTJHF_hGgA"` `: {` `"node_name"` `: ``"DKDM97B"``,` `"node_attributes"` `: { },` `"store"` `: {` `"shard_copy"` `: ``"NONE"` `},` `"final_decision"` `: ``"NO"``,` `"final_explanation"` `: ``"the shard cannot be assigned because one or more allocation decider returns a 'NO' decision"``,` `"weight"` `: 2.3166666,` `"decisions"` `: [ {` `"decider"` `: ``"filter"``,` `"decision"` `: ``"NO"``,` `"explanation"` `: ``"node does not match index include filters [foo:\"bar\"]"` `} ]` `}` `}` `}` | | 编号 | 描述 | | --- | --- | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/1.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-1) | Whether the shard is assigned or unassigned | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/2.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-2) | Whether information about the shard is still being fetched | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/3.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-3) | Reason for the shard originally becoming unassigned | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/4.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-4) | Configured delay before the shard can be allocated | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/5.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-5) | Remaining delay before the shard can be allocated | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/6.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-6) | User-added attributes the node has | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/7.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-7) | The shard copy information for this node and error (if applicable) | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/8.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-8) | Final decision and explanation of whether the shard can be allocated to this node | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/9.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-9) | Weight for how much the allocator would like to allocate the shard to this node | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/10.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO138-10) | List of node decisions factoring into final decision about the shard | 对于一个已经分配的分片来说,输出与下面相似 :  | `{` `"shard"` `: {` `"index"` `: ``"only-foo"``,` `"index_uuid"` `: ``"KnW0-zELRs6PK84l0r38ZA"``,` `"id"` `: 0,` `"primary"` `: ``true` `},` `"assigned"` `: ``true``,` `"assigned_node_id"` `: ``"Qc6VL8c5RWaw1qXZ0Rg57g"``,      ①` `"shard_state_fetch_pending"``: ``false``,` `"allocation_delay_ms"` `: 0,` `"remaining_delay_ms"` `: 0,` `"nodes"` `: {` `"V-Spi0AyRZ6ZvKbaI3691w"` `: {` `"node_name"` `: ``"bGG90GE"``,` `"node_attributes"` `: {` `"bar"` `: ``"baz"` `},` `"store"` `: {` `"shard_copy"` `: ``"NONE"` `},` `"final_decision"` `: ``"NO"``,` `"final_explanation"` `: ``"the shard cannot be assigned because one or more allocation decider returns a 'NO' decision"``,` `"weight"` `: 1.4499999,` `"decisions"` `: [ {` `"decider"` `: ``"filter"``,` `"decision"` `: ``"NO"``,` `"explanation"` `: ``"node does not match index include filters [foo:\"bar\"]"` `} ]` `},` `"Qc6VL8c5RWaw1qXZ0Rg57g"` `: {` `"node_name"` `: ``"I8hydUG"``,` `"node_attributes"` `: {` `"bar"` `: ``"baz"``,` `"foo"` `: ``"bar"` `},` `"store"` `: {` `"shard_copy"` `: ``"AVAILABLE"` `},` `"final_decision"` `: ``"ALREADY_ASSIGNED"``,        ②` `"final_explanation"` `: ``"the shard is already assigned to this node"``,` `"weight"` `: 0.0,` `"decisions"` `: [ {` `"decider"` `: ``"same_shard"``,` `"decision"` `: ``"NO"``,` `"explanation"` `: ``"the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists"` `} ]` `},` `"PzdyMZGXQdGhqTJHF_hGgA"` `: {` `"node_name"` `: ``"H5dfFeA"``,` `"node_attributes"` `: { },` `"store"` `: {` `"shard_copy"` `: ``"NONE"` `},` `"final_decision"` `: ``"NO"``,` `"final_explanation"` `: ``"the shard cannot be assigned because one or more allocation decider returns a 'NO' decision"``,` `"weight"` `: 3.6999998,` `"decisions"` `: [ {` `"decider"` `: ``"filter"``,` `"decision"` `: ``"NO"``,` `"explanation"` `: ``"node does not match index include filters [foo:\"bar\"]"` `} ]` `}` `}` `}` | | 编号 | 描述 | | --- | --- | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/1.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO139-1) | Node the shard is currently assigned to | | [![](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/images/icons/callouts/2.png)](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-allocation-explain.html#CO139-2) | The decision is "ALREADY_ASSIGNED" because the shard is currently assigned to this node | 您也可以让 **Elasticsearch explain** 第一个未分配分片的分配情况,它可以通过发送一个空的 **body** 来找到,例如 :  | `$ curl -XGET ``'[http://localhost:9200/_cluster/allocation/explain'](http://localhost:9200/_cluster/allocation/explain')` | 如果您想要去包含所有的那些我们考虑到的最终的决策的决定,该***`include_yes_decisions` ***参数将返回所有的决策 :  | `$ curl -XGET ``'[http://localhost:9200/_cluster/allocation/explain?include_yes_decisions=true'](http://localhost:9200/_cluster/allocation/explain?include_yes_decisions=true%27)` | 此外,通过设置 ***`include_disk_info`***参数为 ***true***,您可以返回通过集群信息服务返回收集到的信息,包括硬盘使用和分配大小。 | `$ curl -XGET ``'[http://localhost:9200/_cluster/allocation/explain?include_disk_info=true'](http://localhost:9200/_cluster/allocation/explain?include_disk_info=true%27)` |