롤링 재시작 / 롤링 업그레이드 (노드별, 불필요한 샤드 이동 없이)
Elasticsearch클러스터/노드명령어
# 1) Disable replica allocation (only primaries are allocated):
PUT _cluster/settings
{
"persistent": { "cluster.routing.allocation.enable": "primaries" }
}
# 2) Optional: stop indexing and flush to speed up recovery:
POST _flush
# 3) Stop one node, do the maintenance, start it; verify it joined:
GET _cat/nodes?v&h=name,version,node.role,master,heap.percent
# 4) Re-enable allocation:
PUT _cluster/settings
{
"persistent": { "cluster.routing.allocation.enable": null }
}
# 5) Wait for green before moving to the next node:
GET _cluster/health?wait_for_status=green&timeout=10m하는 일
노드가 다운된 동안 replica가 다른 노드로 다시 복사되는 것을 막으면서 노드를 하나씩 재시작하거나 업그레이드하는 순서를 제공한다. 노드가 돌아오면 샤드는 로컬 사본에서 빠르게 복구된다.
사용 시점
OS 패치, JVM/heap 변경, elasticsearch.yml 변경, 마이너/메이저 버전 업그레이드를 위해 노드를 순차적으로 재시작할 때.
주의
green을 기다리지 않고 다음 노드로 넘어가지 않는다. 두 노드가 동시에 다운되면 샤드의 모든 사본이 사라질 수 있다. master-eligible 노드는 마지막에 하나씩 재시작한다. 과반수를 잃으면 클러스터가 master를 선출할 수 없다. allocation.enable을 다시 활성화하는 것을 잊으면 replica가 unassigned로 남는다. 업그레이드 중에는 data 노드를 먼저(frozen/cold 먼저, hot 마지막), 그다음 master를 업그레이드한다.