reroute: shard를 강제로 locate 시키는 방법

# ElasticSearch Shard Initialize fail 시 강제로 locate 시키는 방법

어떤 이유에선지 shard의 initialize가 실패하고 unassigned shard상태로 남아있다면 강제로 특정 노드로 옮겨줘야 할 필요가 있습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
POST _cluster/reroute
{
"commands": [
{
"allocate": {
"index": "인덱스명",
"shard": "보낼샤드넘버,
"node": "타겟노드명",
"allow_primary": "true"
}
}
]
}

allow_primary 옵션을 true로 주면 primary 샤드를 옮기겠다고 선언 하는 것 입니다.
혹시라도 cluster health가 red로 빠져있고 primary and replica shard 모두 unassigned 샤드 인경우…
primary 샤드만 재배치 되고 replica는 여전히 unassigned 로 남아 있다면 “allow_primary”: “false” 로 바꾸고 “node” 도 primary shard가 있는 노드가 아닌 다른 노드로 설정하여 다시 한번 실행 시켜주면 됩니다.

Share