Устранение неполадок с емкостью фрагментов
Elasticsearch ограничивает максимальное количество фрагментов, хранимых на узле, с помощью настроек cluster.max_shards_per_node и cluster.max_shards_per_node.frozen. Текущая емкость фрагментов кластера доступна в разделе емкости фрагментов API состояния.
Кластер приближается к максимальному количеству фрагментов для узлов данных.
Настройка кластера cluster.max_shards_per_node ограничивает максимальное количество открытых фрагментов для кластера, учитывая только узлы данных, которые не относятся к замороженному уровню.
Данный симптом указывает на необходимость принятия мер, иначе создание новых индексов или обновление кластера может быть заблокировано.
Если вы уверены, что ваши изменения не дестабилизируют кластер, вы можете временно увеличить лимит, используя API обновления настроек кластера:
Используйте Kibana
- Войдите в консоль Elastic Cloud.
-
На панели Сервис Elasticsearch нажмите на имя вашей развертывания.
Если имя вашей развертывания отключено, ваши экземпляры Kibana могут быть неисправны. В этом случае обратитесь в службу поддержки Elastic. Если ваша развертывание не включает Kibana, вам нужно сначала его включить.
-
Откройте меню боковой навигации развертывания (расположено под логотипом Elastic в верхнем левом углу) и перейдите в Dev Tools > Console.
-
Проверьте текущее состояние кластера по показателю емкости фрагментов:
resp = client.health_report( feature="shards_capacity", ) print(resp)response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({ feature: "shards_capacity", }); console.log(response);GET _health_report/shards_capacity
Ответ будет выглядеть так:
{ "cluster_name": "...", "indicators": { "shards_capacity": { "status": "yellow", "symptom": "Cluster is close to reaching the configured maximum number of shards for data nodes.", "details": { "data": { "max_shards_in_cluster": 1000, "current_used_shards": 988 }, "frozen": { "max_shards_in_cluster": 3000, "current_used_shards": 0 } }, "impacts": [ ... ], "diagnosis": [ ... } } }Текущее значение настройки
cluster.max_shards_per_nodeТекущее количество открытых фрагментов по всему кластеру
-
Обновите настройку
cluster.max_shards_per_nodeс правильным значением:resp = client.cluster.put_settings( persistent={ "cluster.max_shards_per_node": 1200 }, ) print(resp)response = client.cluster.put_settings( body: { persistent: { 'cluster.max_shards_per_node' => 1200 } } ) puts responseconst response = await client.cluster.putSettings({ persistent: { "cluster.max_shards_per_node": 1200, }, }); console.log(response);PUT _cluster/settings { "persistent" : { "cluster.max_shards_per_node": 1200 } }Это увеличение должно быть временным. В качестве долгосрочного решения рекомендуется добавить узлы в перегруженный уровень данных или сократить количество фрагментов кластера на узлах, которые не принадлежат к замороженному уровню.
-
Для проверки того, что изменение исправило проблему, можно получить текущее состояние индикатора
shards_capacity, проверив разделdataв API состояния:resp = client.health_report( feature="shards_capacity", ) print(resp)response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({ feature: "shards_capacity", }); console.log(response);GET _health_report/shards_capacity
Ответ будет выглядеть так:
{ "cluster_name": "...", "indicators": { "shards_capacity": { "status": "green", "symptom": "The cluster has enough room to add new shards.", "details": { "data": { "max_shards_in_cluster": 1000 }, "frozen": { "max_shards_in_cluster": 3000 } } } } } -
После реализации долгосрочного решения рекомендуется сбросить ограничение
cluster.max_shards_per_node.resp = client.cluster.put_settings( persistent={ "cluster.max_shards_per_node": None }, ) print(resp)response = client.cluster.put_settings( body: { persistent: { 'cluster.max_shards_per_node' => nil } } ) puts responseconst response = await client.cluster.putSettings({ persistent: { "cluster.max_shards_per_node": null, }, }); console.log(response);PUT _cluster/settings { "persistent" : { "cluster.max_shards_per_node": null } }
Проверьте текущее состояние кластера по показателю емкости фрагментов:
resp = client.health_report(
feature="shards_capacity",
)
print(resp) response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({
feature: "shards_capacity",
});
console.log(response); GET _health_report/shards_capacity
Ответ будет выглядеть так:
{
"cluster_name": "...",
"indicators": {
"shards_capacity": {
"status": "yellow",
"symptom": "Cluster is close to reaching the configured maximum number of shards for data nodes.",
"details": {
"data": {
"max_shards_in_cluster": 1000,
"current_used_shards": 988
},
"frozen": {
"max_shards_in_cluster": 3000
}
},
"impacts": [
...
],
"diagnosis": [
...
}
}
} | Текущее значение настройки | |
| Текущее количество открытых фрагментов по всему кластеру |
Используя cluster settings API, обновите настройку cluster.max_shards_per_node:
resp = client.cluster.put_settings(
persistent={
"cluster.max_shards_per_node": 1200
},
)
print(resp) response = client.cluster.put_settings(
body: {
persistent: {
'cluster.max_shards_per_node' => 1200
}
}
)
puts response const response = await client.cluster.putSettings({
persistent: {
"cluster.max_shards_per_node": 1200,
},
});
console.log(response); PUT _cluster/settings
{
"persistent" : {
"cluster.max_shards_per_node": 1200
}
} Это увеличение должно быть временным. В качестве долгосрочного решения рекомендуется добавить узлы в перегруженный уровень данных или сократить количество фрагментов кластера на узлах, которые не принадлежат к замороженному уровню. Для проверки, что изменение исправило проблему, можно получить текущее состояние индикатора shards_capacity, проверив раздел data в API состояния:
resp = client.health_report(
feature="shards_capacity",
)
print(resp) response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({
feature: "shards_capacity",
});
console.log(response); GET _health_report/shards_capacity
Ответ будет выглядеть так:
{
"cluster_name": "...",
"indicators": {
"shards_capacity": {
"status": "green",
"symptom": "The cluster has enough room to add new shards.",
"details": {
"data": {
"max_shards_in_cluster": 1200
},
"frozen": {
"max_shards_in_cluster": 3000
}
}
}
}
} После реализации долгосрочного решения рекомендуется сбросить ограничение cluster.max_shards_per_node.
resp = client.cluster.put_settings(
persistent={
"cluster.max_shards_per_node": None
},
)
print(resp) response = client.cluster.put_settings(
body: {
persistent: {
'cluster.max_shards_per_node' => nil
}
}
)
puts response const response = await client.cluster.putSettings({
persistent: {
"cluster.max_shards_per_node": null,
},
});
console.log(response); PUT _cluster/settings
{
"persistent" : {
"cluster.max_shards_per_node": null
}
} Кластер приближается к максимальному количеству фрагментов для замороженных узлов.
Настройка кластера cluster.max_shards_per_node.frozen ограничивает максимальное количество открытых фрагментов для кластера, учитывая только узлы данных, которые принадлежат к замороженному уровню.
Данный симптом указывает на необходимость принятия мер, иначе создание новых индексов или обновление кластера может быть заблокировано.
Если вы уверены, что ваши изменения не дестабилизируют кластер, вы можете временно увеличить лимит, используя API обновления настроек кластера:
Используйте Kibana
- Войдите в консоль Elastic Cloud.
-
На панели Службы Elasticsearch нажмите имя своего развертывания.
Если имя вашего развертывания отключено, ваши экземпляры Kibana могут быть неисправны. В этом случае обратитесь за помощью к Службе поддержки Elastic. Если в вашем развертывании нет Kibana, вам сначала необходимо его включить.
-
Откройте меню навигации по развертыванию (расположено под логотипом Elastic в верхнем левом углу) и перейдите к Dev Tools > Console.
-
Проверьте текущее состояние кластера, согласно показателю ёмкости фрагментов:
resp = client.health_report( feature="shards_capacity", ) print(resp)response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({ feature: "shards_capacity", }); console.log(response);GET _health_report/shards_capacity
Ответ будет выглядеть так:
{ "cluster_name": "...", "indicators": { "shards_capacity": { "status": "yellow", "symptom": "Cluster is close to reaching the configured maximum number of shards for frozen nodes.", "details": { "data": { "max_shards_in_cluster": 1000 }, "frozen": { "max_shards_in_cluster": 3000, "current_used_shards": 2998 } }, "impacts": [ ... ], "diagnosis": [ ... } } }Текущее значение настройки
cluster.max_shards_per_node.frozenТекущее количество открытых фрагментов, используемых замороженными узлами по всему кластеру
-
Обновите настройку
cluster.max_shards_per_node.frozen:resp = client.cluster.put_settings( persistent={ "cluster.max_shards_per_node.frozen": 3200 }, ) print(resp)response = client.cluster.put_settings( body: { persistent: { 'cluster.max_shards_per_node.frozen' => 3200 } } ) puts responseconst response = await client.cluster.putSettings({ persistent: { "cluster.max_shards_per_node.frozen": 3200, }, }); console.log(response);PUT _cluster/settings { "persistent" : { "cluster.max_shards_per_node.frozen": 3200 } }Это увеличение должно быть временным. В качестве долгосрочного решения рекомендуется добавить узлы к слою данных с избыточным количеством фрагментов или уменьшить количество фрагментов вашего кластера на узлах, относящихся к замороженному слою.
-
Чтобы убедиться, что изменение устранило проблему, вы можете получить текущее состояние индикатора
shards_capacity, проверив разделdataAPI состояния здоровья:resp = client.health_report( feature="shards_capacity", ) print(resp)response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({ feature: "shards_capacity", }); console.log(response);GET _health_report/shards_capacity
Ответ будет выглядеть так:
{ "cluster_name": "...", "indicators": { "shards_capacity": { "status": "green", "symptom": "The cluster has enough room to add new shards.", "details": { "data": { "max_shards_in_cluster": 1000 }, "frozen": { "max_shards_in_cluster": 3200 } } } } } -
После того, как будет реализовано долгосрочное решение, рекомендуется сбросить ограничение
cluster.max_shards_per_node.frozen.resp = client.cluster.put_settings( persistent={ "cluster.max_shards_per_node.frozen": None }, ) print(resp)response = client.cluster.put_settings( body: { persistent: { 'cluster.max_shards_per_node.frozen' => nil } } ) puts responseconst response = await client.cluster.putSettings({ persistent: { "cluster.max_shards_per_node.frozen": null, }, }); console.log(response);PUT _cluster/settings { "persistent" : { "cluster.max_shards_per_node.frozen": null } }
Проверьте текущее состояние кластера, согласно показателю ёмкости фрагментов:
resp = client.health_report(
feature="shards_capacity",
)
print(resp) response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({
feature: "shards_capacity",
});
console.log(response); GET _health_report/shards_capacity
{
"cluster_name": "...",
"indicators": {
"shards_capacity": {
"status": "yellow",
"symptom": "Cluster is close to reaching the configured maximum number of shards for frozen nodes.",
"details": {
"data": {
"max_shards_in_cluster": 1000
},
"frozen": {
"max_shards_in_cluster": 3000,
"current_used_shards": 2998
}
},
"impacts": [
...
],
"diagnosis": [
...
}
}
} | Текущее значение настройки | |
| Текущее количество открытых фрагментов, используемых замороженными узлами по всему кластеру. |
Используя cluster settings API, обновите настройку cluster.max_shards_per_node.frozen:
resp = client.cluster.put_settings(
persistent={
"cluster.max_shards_per_node.frozen": 3200
},
)
print(resp) response = client.cluster.put_settings(
body: {
persistent: {
'cluster.max_shards_per_node.frozen' => 3200
}
}
)
puts response const response = await client.cluster.putSettings({
persistent: {
"cluster.max_shards_per_node.frozen": 3200,
},
});
console.log(response); PUT _cluster/settings
{
"persistent" : {
"cluster.max_shards_per_node.frozen": 3200
}
} Это увеличение должно быть временным. В качестве долгосрочного решения рекомендуется добавить узлы к слою данных с избыточным количеством фрагментов или уменьшить количество фрагментов вашего кластера на узлах, относящихся к замороженному слою. Для проверки того, что изменение устранило проблему, вы можете получить текущее состояние индикатора shards_capacity, проверив раздел data API состояния здоровья:
resp = client.health_report(
feature="shards_capacity",
)
print(resp) response = client.health_report( feature: 'shards_capacity' ) puts response
const response = await client.healthReport({
feature: "shards_capacity",
});
console.log(response); GET _health_report/shards_capacity
Ответ будет выглядеть так:
{
"cluster_name": "...",
"indicators": {
"shards_capacity": {
"status": "green",
"symptom": "The cluster has enough room to add new shards.",
"details": {
"data": {
"max_shards_in_cluster": 1000
},
"frozen": {
"max_shards_in_cluster": 3200
}
}
}
}
} После того, как будет реализовано долгосрочное решение, рекомендуется сбросить ограничение cluster.max_shards_per_node.frozen.
resp = client.cluster.put_settings(
persistent={
"cluster.max_shards_per_node.frozen": None
},
)
print(resp) response = client.cluster.put_settings(
body: {
persistent: {
'cluster.max_shards_per_node.frozen' => nil
}
}
)
puts response const response = await client.cluster.putSettings({
persistent: {
"cluster.max_shards_per_node.frozen": null,
},
});
console.log(response); PUT _cluster/settings
{
"persistent" : {
"cluster.max_shards_per_node.frozen": null
}
}
© 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/troubleshooting-shards-capacity-issues.html