ElasticsearchClusterRed
Что означает алерт
Алерт срабатывает, когда состояние кластера RED более 5 минут.
Это означает, что в кластере есть нераспределенные primary shard, поэтому часть чтения/записи может не работать.
Подключение к ES в Kubernetes
Откройте локальный доступ к ES:
kubectl -n camunda port-forward svc/camunda-elasticsearch 9200:9200
Далее все команды выполняются через localhost:9200.
Диагностика (по шагам)
- Проверить health и количество нераспределенных шардов:
curl -s 'localhost:9200/_cluster/health?filter_path=status,*_shards,number_of_nodes,number_of_data_nodes' | jq
- Посмотреть какие шарды в
UNASSIGNED:
curl -s 'localhost:9200/_cat/shards?h=index,shard,prirep,state,node,unassigned.reason&s=state'
- По проблемному шарду получить причину через Allocation Explain:
curl -s -X GET localhost:9200/_cluster/allocation/explain \
-H 'Content-Type: application/json' \
-d '{"index":"<index-name>","shard":0,"primary":true}' \
| jq
- Проверить узлы и дисковую емкость:
curl -s 'localhost:9200/_cat/nodes?v'
curl -s 'localhost:9200/_cat/allocation?v'
- Проверить настройки, которые чаще всего блокируют аллокацию:
curl -s localhost:9200/_cluster/settings?flat_settings=true\&include_defaults=true | jq
curl -s 'localhost:9200/_cluster/settings?include_defaults=true&filter_path=*.cluster.routing.allocation.enable' | jq
Как починить (по причинам)
1) Аллокация отключена
Проверка и возврат к дефолту all:
curl -s -X PUT localhost:9200/_cluster/settings \
-H 'Content-Type: application/json' \
-d '{"persistent":{"cluster.routing.allocation.enable":null}}'
После этого можно ускорить перераспределение:
curl -s -X POST 'localhost:9200/_cluster/reroute?pretty'
2) Недостаточно места / watermark
Проверить allocation + удалить старые индексы:
curl -s 'localhost:9200/_cat/allocation?v'
curl -s 'localhost:9200/_cat/indices?h=health,status,index,pri,rep,store.size,creation.date.string&s=creation.date:asc'
curl -s -X DELETE 'localhost:9200/<old-index-name>?pretty'
Если индекс стал read-only из-за watermark:
curl -s -X PUT 'localhost:9200/_all/_settings' \
-H 'Content-Type: application/json' \
-d '{"index.blocks.read_only_allow_delete":null}'
Временная мера (использовать осторожно):
curl -s -X PUT 'localhost:9200/_cluster/settings' \
-H 'Content-Type: application/json' \
-d '{
"persistent": {
"cluster.routing.allocation.disk.watermark.low": "90%",
"cluster.routing.allocation.disk.watermark.high": "95%"
}
}'
3) Потерян узел / временный outage
После возврата ноды выполнить повторную попытку failed-аллокаций:
curl -s -X POST 'localhost:9200/_cluster/reroute?retry_failed=true&pretty'
curl -s 'localhost:9200/_cluster/health?pretty'
4) Неправильные allocation-фильтры/awareness
Проверить настройки индекса и кластера:
curl -s 'localhost:9200/<index-name>/_settings?flat_settings=true&include_defaults=true' | jq
curl -s 'localhost:9200/_cluster/settings?flat_settings=true&include_defaults=true' | jq
Снять ошибочный фильтр (пример):
curl -s -X PUT 'localhost:9200/_cluster/settings' \
-H 'Content-Type: application/json' \
-d '{"persistent":{"cluster.routing.allocation.exclude._name":null}}'
5) Нет валидной копии primary (no_valid_shard_copy)
Приоритет: восстановить из snapshot:
curl -s 'localhost:9200/_snapshot/_all?pretty'
curl -s -X POST 'localhost:9200/_snapshot/<repo>/<snapshot>/_restore' \
-H 'Content-Type: application/json' \
-d '{"indices":"<index-name>","include_global_state":false}'
Аварийный вариант с потерей данных (только если ноду вернуть невозможно):
curl -s -X POST 'localhost:9200/_cluster/reroute' \
-H 'Content-Type: application/json' \
-d '{
"commands": [
{
"allocate_empty_primary": {
"index": "<index-name>",
"shard": 0,
"node": "<node-name>",
"accept_data_loss": true
}
}
]
}'
Критерий закрытия
cluster healthнеRED.- Нет unassigned
primaryshard. - Подтверждено восстановление записи/чтения для Camunda/Operate.
Источник
https://www.elastic.co/docs/troubleshoot/elasticsearch/red-yellow-cluster-status