DBAtlas · 데이터베이스 운영 아틀라스

Elasticsearch red/yellow 클러스터 및 unassigned shard

증상

_cluster/health가 'red' 또는 'yellow'. unassigned shard 발생, 읽기/쓰기가 제한되거나 데이터에 접근할 수 없다.

1. 색상과 원인

yellow = replica 샤드가 할당되지 않음(데이터는 있으나 내구성 저하). red = 최소 하나의 PRIMARY shard가 없음(해당 데이터 접근 불가). 먼저 어느 쪽이고 왜인지 파악한다.

Elasticsearch

GET _cluster/health?level=indices
GET _cluster/allocation/explain

2. unassigned shard와 이유를 나열한다

unassigned.reason 컬럼이 근본 원인을 알려준다(NODE_LEFT, ALLOCATION_FAILED, DISK 등).

Elasticsearch

GET _cat/shards?v&h=index,shard,prirep,state,unassigned.reason&s=state

3. 흔한 원인을 처리한다

1) Disk watermark → low를 넘으면 노드가 새 샤드를 받지 않고, flood_stage에서는 인덱스가 읽기 전용이 된다. 2) 노드가 다운되었거나 이탈했다. 3) allocation이 비활성화된 채로 남아 있다. 4) replica 수 > 적격 노드 수.

4. 해결한다

해당 원인에 따라 차단을 해제한다.

Elasticsearch

# If disk space was freed, remove the read-only block (7.4+ also lifts it automatically once below the high watermark):
PUT _all/_settings {"index.blocks.read_only_allow_delete": null}
# If allocation was left restricted, return it to the default (all):
PUT _cluster/settings {"persistent":{"cluster.routing.allocation.enable":null}}
# Retry failed allocations:
POST _cluster/reroute?retry_failed=true

5. 여전히 red이고 primary가 정말 손실되었다면

영향받은 인덱스를 스냅샷에서 복원하거나 원본 데이터에서 reindex한다(_reindex). 영구 조치: disk watermark 알림, 적절한 replica 수(≥1), 노드 상태 모니터링.

DBAtlas에서 열기 →