API объяснения распределения кластера
Предоставляет объяснение текущего распределения фрагмента.
resp = client.cluster.allocation_explain(
index="my-index-000001",
shard=0,
primary=False,
current_node="my-node",
)
print(resp) response = client.cluster.allocation_explain(
body: {
index: 'my-index-000001',
shard: 0,
primary: false,
current_node: 'my-node'
}
)
puts response const response = await client.cluster.allocationExplain({
index: "my-index-000001",
shard: 0,
primary: false,
current_node: "my-node",
});
console.log(response); GET _cluster/allocation/explain
{
"index": "my-index-000001",
"shard": 0,
"primary": false,
"current_node": "my-node"
} Запрос
GET _cluster/allocation/explain
POST _cluster/allocation/explain
Предварительные условия
- Если функции безопасности Elasticsearch включены, у вас должна быть роль
monitorилиmanageправа доступа к кластеру, чтобы использовать этот API.
Описание
Цель API объяснения распределения кластера — предоставить объяснения для распределения фрагментов в кластере. Для неназначенных фрагментов API объяснения предоставляет объяснение, почему фрагмент не назначен. Для назначенных фрагментов API объяснения предоставляет объяснение, почему фрагмент остается на текущем узле и не переместился или не был перебалансирован на другой узел. Этот API может быть очень полезен при попытке диагностировать, почему фрагмент не назначен или почему фрагмент продолжает оставаться на текущем узле, когда можно ожидать обратного.
Параметры запроса
-
include_disk_info - (Необязательный, логический тип) Если
true, возвращает информацию об использовании диска и размерах фрагментов. По умолчаниюfalse. -
include_yes_decisions - (Необязательный, логический тип) Если
true, возвращает решения YES в объяснении. По умолчаниюfalse.
Тело запроса
-
current_node - (Необязательный, строка) Указывает ID узла или имя узла, на котором в данный момент находится фрагмент для объяснения. Чтобы объяснить неназначенный фрагмент, опустите этот параметр.
-
index - (Необязательный, строка) Указывает имя индекса, для которого требуется объяснение.
-
primary - (Необязательный, логический тип) Если
true, возвращает объяснение для первичного фрагмента для данного ID фрагмента. -
shard - (Необязательный, целое число) Указывает ID фрагмента, для которого требуется объяснение.
Примеры
Неназначенный первичный фрагмент
Противоречивые настройки
Следующий запрос получает объяснение распределения для незанятого первичного фрагмента.
resp = client.cluster.allocation_explain(
index="my-index-000001",
shard=0,
primary=True,
)
print(resp) response = client.cluster.allocation_explain(
body: {
index: 'my-index-000001',
shard: 0,
primary: true
}
)
puts response const response = await client.cluster.allocationExplain({
index: "my-index-000001",
shard: 0,
primary: true,
});
console.log(response); GET _cluster/allocation/explain
{
"index": "my-index-000001",
"shard": 0,
"primary": true
} Ответ API указывает, что фрагмент может быть назначен только несуществующему узлу.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : true,
"current_state" : "unassigned",
"unassigned_info" : {
"reason" : "INDEX_CREATED",
"at" : "2017-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", "data_cold", "data_content", "data_frozen", "data_hot", "data_warm", "ingest", "master", "ml", "remote_cluster_client", "transform"],
"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\"]"
}
]
}
]
} | Текущее состояние фрагмента. | |
| Причина первоначального незадания фрагмента. | |
| Произвести ли назначение фрагмента? | |
| Назначить ли фрагмент конкретному узлу? | |
| Решающий фактор, который привел к принятому для узла решению | |
| Объяснение того, почему решающий фактор принял решение |
См. это видео для пошагового руководства по устранению неполадок с несовпадением настроек узла и индекса.
Превышено максимальное количество попыток повторных операций
Следующий ответ содержит объяснение распределения незанятого первичного фрагмента, который достиг максимального числа попыток повторного распределения.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : true,
"current_state" : "unassigned",
"unassigned_info" : {
"at" : "2017-01-04T18:03:28.464Z",
"failed shard on node [mEKjwwzLT1yJVb8UxT6anw]: failed recovery, failure RecoveryFailedException",
"reason": "ALLOCATION_FAILED",
"failed_allocation_attempts": 5,
"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" : "3sULLVJrRneSg0EfBB-2Ew",
"node_name" : "node_t0",
"transport_address" : "127.0.0.1:9400",
"roles" : ["data_content", "data_hot"],
"node_decision" : "no",
"store" : {
"matching_size" : "4.2kb",
"matching_size_in_bytes" : 4325
},
"deciders" : [
{
"decider": "max_retry",
"decision" : "NO",
"explanation": "shard has exceeded the maximum number of retries [5] on failed allocation attempts - manually call [POST /_cluster/reroute?retry_failed&metric=none] to retry, [unassigned_info[[reason=ALLOCATION_FAILED], at[2024-07-30T21:04:12.166Z], failed_attempts[5], failed_nodes[[mEKjwwzLT1yJVb8UxT6anw]], delayed=false, details[failed shard on node [mEKjwwzLT1yJVb8UxT6anw]: failed recovery, failure RecoveryFailedException], allocation_status[deciders_no]]]"
}
]
}
]
} Когда Elasticsearch не может распределить фрагмент, он будет пытаться повторно распределить его до максимального числа разрешенных повторных попыток. После этого Elasticsearch прекратит попытки распределения фрагмента, чтобы предотвратить бесконечные повторные попытки, которые могут повлиять на производительность кластера. Запустите API перенаправления кластера для повторной попытки распределения, что приведет к распределению фрагмента, если проблема, препятствующая распределению, была устранена.
Нет допустимой копии фрагмента
Следующий ответ содержит объяснение распределения незанятого первичного фрагмента, который ранее был назначен.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : true,
"current_state" : "unassigned",
"unassigned_info" : {
"reason" : "NODE_LEFT",
"at" : "2017-01-04T18:03:28.464Z",
"details" : "node_left[OIWe8UhhThCK0V5XfmdrmQ]",
"last_allocation_status" : "no_valid_shard_copy"
},
"can_allocate" : "no_valid_shard_copy",
"allocate_explanation" : "Elasticsearch can't allocate this shard because there are no copies of its data in the cluster. Elasticsearch will allocate this shard when a node holding a good copy of its data joins the cluster. If no such node is available, restore this index from a recent snapshot."
} Если фрагмент не назначен со статусом распределения no_valid_shard_copy, убедитесь, что все узлы находятся в кластере.. Если все узлы, содержащие синхронизированные копии фрагмента, потеряны, можно восстановить данные фрагмента.
См. это видео для пошагового руководства по устранению неполадок no_valid_shard_copy.
Неназначенный фрагмент реплики
Задержка распределения
Следующий ответ содержит объяснение распределения реплики, которая не назначена из-за задержки распределения.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : false,
"current_state" : "unassigned",
"unassigned_info" : {
"reason" : "NODE_LEFT",
"at" : "2017-01-04T18:53:59.498Z",
"details" : "node_left[G92ZwuuaRY-9n8_tc-IzEg]",
"last_allocation_status" : "no_attempt"
},
"can_allocate" : "allocation_delayed",
"allocate_explanation" : "The node containing this shard copy recently left the cluster. Elasticsearch is waiting for it to return. If the node does not return within [%s] then Elasticsearch will allocate this shard to another node. Please wait.",
"configured_delay" : "1m",
"configured_delay_in_millis" : 60000,
"remaining_delay" : "59.8s",
"remaining_delay_in_millis" : 59824,
"node_allocation_decisions" : [
{
"node_id" : "pmnHu_ooQWCPEFobZGbpWw",
"node_name" : "node_t2",
"transport_address" : "127.0.0.1:9402",
"roles" : ["data_content", "data_hot"],
"node_decision" : "yes"
},
{
"node_id" : "3sULLVJrRneSg0EfBB-2Ew",
"node_name" : "node_t0",
"transport_address" : "127.0.0.1:9400",
"roles" : ["data_content", "data_hot"],
"node_decision" : "no",
"store" : {
"matching_size" : "4.2kb",
"matching_size_in_bytes" : 4325
},
"deciders" : [
{
"decider" : "same_shard",
"decision" : "NO",
"explanation" : "a copy of this shard is already allocated to this node [[my-index-000001][0], node[3sULLVJrRneSg0EfBB-2Ew], [P], s[STARTED], a[id=eV9P8BN1QPqRc3B4PLx6cg]]"
}
]
}
]
} | Настроенная задержка перед назначением фрагмента реплики, который не существует из-за выхода из кластера узла, на котором он находился. | |
| Остающаяся задержка перед назначением фрагмента реплики. | |
| Информация о данных фрагмента, найденных на узле. |
Ограничение распределения
Следующий ответ содержит объяснение распределения реплики, которая находится в очереди на назначение, но в настоящее время ожидает других фрагментов в очереди.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : false,
"current_state" : "unassigned",
"unassigned_info" : {
"reason" : "NODE_LEFT",
"at" : "2017-01-04T18:53:59.498Z",
"details" : "node_left[G92ZwuuaRY-9n8_tc-IzEg]",
"last_allocation_status" : "no_attempt"
},
"can_allocate": "throttled",
"allocate_explanation": "Elasticsearch is currently busy with other activities. It expects to be able to allocate this shard when those activities finish. Please wait.",
"node_allocation_decisions" : [
{
"node_id" : "3sULLVJrRneSg0EfBB-2Ew",
"node_name" : "node_t0",
"transport_address" : "127.0.0.1:9400",
"roles" : ["data_content", "data_hot"],
"node_decision" : "no",
"deciders" : [
{
"decider": "throttling",
"decision": "THROTTLE",
"explanation": "reached the limit of incoming shard recoveries [2], cluster setting [cluster.routing.allocation.node_concurrent_incoming_recoveries=2] (can also be set via [cluster.routing.allocation.node_concurrent_recoveries])"
}
]
}
]
} Это временное сообщение, которое может появиться при распределении большого количества фрагментов.
Назначенный фрагмент
Не может оставаться на текущем узле
Следующий ответ содержит объяснение распределения назначенного фрагмента. Ответ указывает, что фрагмент не может оставаться на текущем узле и должен быть перераспределен.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : true,
"current_state" : "started",
"current_node" : {
"id" : "8lWJeJ7tSoui0bxrwuNhTA",
"name" : "node_t1",
"transport_address" : "127.0.0.1:9401",
"roles" : ["data_content", "data_hot"]
},
"can_remain_on_current_node" : "no",
"can_remain_decisions" : [
{
"decider" : "filter",
"decision" : "NO",
"explanation" : "node does not match index setting [index.routing.allocation.include] filters [_name:\"nonexistent_node\"]"
}
],
"can_move_to_other_node" : "no",
"move_explanation" : "This shard may not remain on its current node, but Elasticsearch isn't allowed to move it to another node. 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" : "_P8olZS8Twax9u6ioN-GGA",
"node_name" : "node_t0",
"transport_address" : "127.0.0.1:9400",
"roles" : ["data_content", "data_hot"],
"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\"]"
}
]
}
]
} | Разрешено ли фрагменту оставаться на текущем узле? | |
| Решающие факторы, которые повлияли на решение о том, почему фрагмент не может оставаться на текущем узле. | |
| Разрешено ли назначение фрагмента другому узлу? |
Должен оставаться на текущем узле
Следующий ответ содержит объяснение распределения фрагмента, который должен оставаться на текущем узле. Перемещение фрагмента на другой узел не улучшит баланс кластера.
{
"index" : "my-index-000001",
"shard" : 0,
"primary" : true,
"current_state" : "started",
"current_node" : {
"id" : "wLzJm4N4RymDkBYxwWoJsg",
"name" : "node_t0",
"transport_address" : "127.0.0.1:9400",
"roles" : ["data_content", "data_hot"],
"weight_ranking" : 1
},
"can_remain_on_current_node" : "yes",
"can_rebalance_cluster" : "yes",
"can_rebalance_to_other_node" : "no",
"rebalance_explanation" : "Elasticsearch cannot rebalance this shard to another node since there is no node to which allocation is permitted which would improve the cluster balance. If you expect this shard to be rebalanced to another node, find this node in the node-by-node explanation and address the reasons which prevent Elasticsearch from rebalancing this shard there.",
"node_allocation_decisions" : [
{
"node_id" : "oE3EGFc8QN-Tdi5FFEprIA",
"node_name" : "node_t1",
"transport_address" : "127.0.0.1:9401",
"roles" : ["data_content", "data_hot"],
"node_decision" : "worse_balance",
"weight_ranking" : 1
}
]
} | Разрешено ли перебалансирование в кластере? | |
| Можно ли перебалансировать фрагмент на другой узел? | |
| Причина, по которой фрагмент нельзя перебалансировать на узел, в данном случае указывается, что это не улучшит баланс по сравнению с текущим узлом. |
Без аргументов
Если вы вызываете API без аргументов, Elasticsearch извлекает объяснение распределения произвольного незанятого первичного или фрагмента реплики, сначала возвращая любые незанятые первичные фрагменты.
resp = client.cluster.allocation_explain() print(resp)
response = client.cluster.allocation_explain puts response
const response = await client.cluster.allocationExplain(); console.log(response);
GET _cluster/allocation/explain
Если в кластере нет незанятых фрагментов, API возвращает ошибку 400.
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/cluster-allocation-explain.html