'unassigned'에 해당되는 글 2건

  1. 2014.04.29 [Elasticsearch] 운영중 발생하는 unassigned shard에 대해서..
  2. 2013.11.13 [elasticsearch] unassinged shard reroute...

[Elasticsearch] 운영중 발생하는 unassigned shard에 대해서..

Elastic/Elasticsearch 2014. 4. 29. 10:56

운영하다 보면 저절로 정상적이던 shard 가 unassigned 로 상태가 변경되어 있는 경험을 하시는 분들이 꽤 되시는 것 같습니다.

그래서 초간단 팁을 공유 합니다.


elasticsearch 는 대량의 데이터를 분산 처리 하기 위한 구조로 설계가 되어 있습니다.

그래서 clustering, sharding, replication, recovery 등등의 기능들이 들어 있는 것일 겁니다.


shard 가 unassigned 되었을 때 강제로 reroute 시키는 방법은 이전 글에 공유를 하였습니다.

http://jjeong.tistory.com/909

http://jjeong.tistory.com/905


우선 elasticsearch 의 설정을 살펴 봐야 합니다.

elasticsearch.yml 에 보시면 recovery 세션에 아래 와 같은 내용이 있습니다.


############################# Recovery Throttling #############################


# These settings allow to control the process of shards allocation between

# nodes during initial recovery, replica allocation, rebalancing,

# or when adding and removing nodes.


# Set the number of concurrent recoveries happening on a node:

#

# 1. During the initial recovery

#

# cluster.routing.allocation.node_initial_primaries_recoveries: 4

#

# 2. During adding/removing nodes, rebalancing, etc

#

# cluster.routing.allocation.node_concurrent_recoveries: 2


# Set to throttle throughput when recovering (eg. 100mb, by default 20mb):

#

# indices.recovery.max_bytes_per_sec: 20mb


# Set to limit the number of open concurrent streams when

# recovering a shard from a peer:

#

# indices.recovery.concurrent_streams: 5


보시면 아시겠지만 이건 node 가 추가 되거나 제거 되었을 때 shard 를 rebalancing 하는 것입니다.

이유는 잘 아시겠죠?

이 설정 또한 성능에 영향을 주는 부분이니 참고 하시면 좋을 것 같습니다.


그리고 cluster.routing 설정에 보시면 shard allocation 에 대한 정보가 있습니다.

allocation 에 대한 정책을 설정 하는 것인데요.

이 설정을 해보신 분이라면 아마 운영 중에 발생 하는 unassigned shard 를 어떻게 예방할지를요.. 

물론 아래 설정은 1.0.0.RC1 부터 추가되었습니다.


===== Disable allocation


added[1.0.0.RC1]


All the disable allocation settings have been deprecated in favour for

`cluster.routing.allocation.enable` setting.


`cluster.routing.allocation.disable_allocation`::

     See <<modules-cluster>>.


`cluster.routing.allocation.disable_replica_allocation`::

     See <<modules-cluster>>.


`cluster.routing.allocation.disable_new_allocation`::

     See <<modules-cluster>>.


일반적인 내용으로 정리를 하면,


- shard allocation 은 왜 발생 하는가?


특정 shard 의 크기가 커졌을 때...

특정 node 의 인덱스 크기가 커졌을 때...

node 가 추가 되었거나 삭제 되었을 때.. (신규 서버 투입, 또는 실행중인 노드가 죽었을 때)


- shard allocation 을 방지 할 수는 없는가?


disable allocation 설정을 통해 할 수 있습니다.

이 설정은 재시작 시 allocation 을 방지 하는 것이 아니라 rebalancing을 방지 하는 것입니다.


- unassigned shard 는 왜 발생 하는가?


recovery 과정중 문제가 발생 했을 경우 발생을 합니다.

shard rebalance 과정중 문제가 발생 했을 경우 발생을 합니다.


문제란)

- node 간 데이터를 옮기는 과정이기 때문에 네트워크 구간에서 발생 할 수 있는 여러가지 문제들이 영향을 줄 수 있습니다. 

- 또는 색인 데이터 recovery 가 실패 하고 깨졌을 때도 발생 합니다.


해결방법) 아래 두 가지 방법은 기본적으로 primary shard 가 정상이라는 전제 입니다.

- 강제 reroute

- 재시작


shard allocation 에 대한 정책이 궁금하신 분은 아래 패키지 소스들을 보시면 되겠습니다.

org.elasticsearch.cluster.routing.allocation.allocator

org.elasticsearch.cluster.routing.allocation.decider

:

[elasticsearch] unassinged shard reroute...

Elastic/Elasticsearch 2013. 11. 13. 15:05

간혹 shard unassigned 되는 경우가 있습니다.

실제 데이터가 깨진게 아니라면 reroute 를 통해서 노드에 할당해 주시면 됩니다.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-reroute.html

curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
   
"commands" : [ {
       
"move" :
           
{
             
"index" : "test", "shard" : 0,
             
"from_node" : "node1", "to_node" : "node2"
           
}
       
},
       
{
         
"allocate" : {
             
"index" : "test", "shard" : 1, "node" : "node3"
         
}
       
}
   
]
}'


curl -XPOST 'http://localhost:9200/_cluster/reroute' -d '{"commands" : [ {"allocate" : {"index" : "index_test", "shard" : 13, "node" : "genie1", "allow_primary" : true}}]}'


- allow_primary 가 설정 되어 있지 않을 경우 primary shard 는 할당 할 수 없습니다.

: