Диагностика неназначенных фрагментов
Существует несколько причин, по которым фрагменты могут быть не назначены, начиная от неправильно сконфигурированных параметров распределения и заканчивая недостатком дискового пространства.
Чтобы диагностировать не назначенные фрагменты в вашей развертывании, выполните следующие шаги:
Чтобы диагностировать не назначенные фрагменты, выполните следующие шаги:
Используйте Kibana
- Войдите в консоль Elastic Cloud.
-
На панели Elasticsearch Service нажмите имя вашей развертывания.
Если имя вашей развертывания отключено, ваши экземпляры Kibana могут быть неисправны. В этом случае обратитесь за помощью в поддержку Elastic. Если в вашем развертывании нет Kibana, вам сначала необходимо его включить.
-
Откройте навигационное меню развертывания (расположено под логотипом Elastic в верхнем левом углу) и перейдите к Dev Tools > Console.
-
Просмотрите не назначенные фрагменты, используя API cat shards.
resp = client.cat.shards( v=True, h="index,shard,prirep,state,node,unassigned.reason", s="state", ) print(resp)response = client.cat.shards( v: true, h: 'index,shard,prirep,state,node,unassigned.reason', s: 'state' ) puts response
const response = await client.cat.shards({ v: "true", h: "index,shard,prirep,state,node,unassigned.reason", s: "state", }); console.log(response);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" } ]Не назначенные фрагменты имеют
stateзначениеUNASSIGNED. Значениеprirepравноpдля первичных фрагментов иrдля реплик.В примере фрагмент первичного индекса не назначен.
-
Чтобы понять, почему не назначенный фрагмент не назначается и какие действия необходимо предпринять, чтобы разрешить Elasticsearch назначить его, используйте API объяснения распределения кластера.
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 responseconst 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 }Индекс, который мы хотим диагностировать.
Идентификатор не назначенного фрагмента.
Указывает, что мы диагностируем первичный фрагмент.
Ответ будет выглядеть так:
{ "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\"]" } ] } ] }Текущее состояние фрагмента.
Причина первоначального не назначения фрагмента.
Необходимо ли назначить фрагмент.
Необходимо ли назначить фрагмент конкретному узлу.
Решающий, который привел к
noрешению для узла.Объяснение того, почему решающий принял
noрешение, с полезным подразумеваемым намеком на настройку, которая привела к этому решению. -
В данном случае объяснение указывает на то, что конфигурация распределения индекса некорректна. Чтобы пересмотреть настройки распределения, используйте API получения настроек индекса и получения настроек кластера.
resp = client.indices.get_settings( index="my-index-000001", flat_settings=True, include_defaults=True, ) print(resp) resp1 = client.cluster.get_settings( flat_settings=True, include_defaults=True, ) print(resp1)response = client.indices.get_settings( index: 'my-index-000001', flat_settings: true, include_defaults: true ) puts response response = client.cluster.get_settings( flat_settings: true, include_defaults: true ) puts response
const response = await client.indices.getSettings({ index: "my-index-000001", flat_settings: "true", include_defaults: "true", }); console.log(response); const response1 = await client.cluster.getSettings({ flat_settings: "true", include_defaults: "true", }); console.log(response1);GET my-index-000001/_settings?flat_settings=true&include_defaults=true GET _cluster/settings?flat_settings=true&include_defaults=true
- Измените настройки, используя API обновления настроек индекса и обновления настроек кластера на правильные значения, чтобы разрешить назначение индекса.
Для получения дополнительной информации по устранению наиболее распространенных причин неназначенных фрагментов, пожалуйста, следуйте этому руководству или обратитесь за помощью к поддержке Elastic.
Чтобы диагностировать не назначенные фрагменты, выполните следующие шаги:
-
Просмотрите не назначенные фрагменты, используя API cat shards.
resp = client.cat.shards( v=True, h="index,shard,prirep,state,node,unassigned.reason", s="state", ) print(resp)response = client.cat.shards( v: true, h: 'index,shard,prirep,state,node,unassigned.reason', s: 'state' ) puts response
const response = await client.cat.shards({ v: "true", h: "index,shard,prirep,state,node,unassigned.reason", s: "state", }); console.log(response);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" } ]Не назначенные фрагменты имеют
stateзначениеUNASSIGNED. Значениеprirepравноpдля первичных фрагментов иrдля реплик.В примере фрагмент первичного индекса не назначен.
См. это видео для ознакомления с процессом мониторинга состояния распределения.
© 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/diagnose-unassigned-shards.html