'allocation'에 해당되는 글 7건

  1. 2021.09.07 [Elasticsearch] Shard Awareness Allocation 사용 시 주의점.
  2. 2015.12.10 [Elasticsearch] Shard Allocation Filtering 설정 시 주의사항. (on 2.1)
  3. 2015.07.03 [Elasticsearch] shard allocation 운영 테스트용 REST 코드 - 1.6.0 이상.
  4. 2015.07.02 [Elasticsearch] shard allocation 운영 테스트용 REST 코드
  5. 2014.07.02 [ElasticSearch] shard allocation 설정.
  6. 2014.04.29 [Elasticsearch] 운영중 발생하는 unassigned shard에 대해서..
  7. 2014.01.28 [elasticsearch] sharding 알고리즘.

[Elasticsearch] Shard Awareness Allocation 사용 시 주의점.

Elastic/Elasticsearch 2021. 9. 7. 23:30

로컬에서 테스트 할 때 주의 해야 하는 점이 있습니다. 

같은 shard 가 같은 host 장비에 할당 되게 하려고 아래와 같은 설정을 합니다.

 

cluster.routing.allocation.same_shard.host: true

 

그런데 이 설정으로 인해서 shard allocation 적용 시 동작 하지 않게 됩니다.

사용 시 위 설정에 대해서 반드시 확인 하고 사용 하세요.

(같은 실수를 몇 번 하는 지 ㅡ.ㅡ;;)

:

[Elasticsearch] Shard Allocation Filtering 설정 시 주의사항. (on 2.1)

Elastic/Elasticsearch 2015. 12. 10. 11:01

hot-warm architecture 구성시 경험했던 팁 공유 합니다.

아주 사소한 팁입니다.


원문링크)

https://www.elastic.co/guide/en/elasticsearch/reference/2.1/shard-allocation-filtering.html


index settings 기능을 이용해서 "index.routing.allocation.{attribute}.{attribute}" 설정을 하게 됩니다.

이 과정에서 사용하는 REST API 가 두 가지가 있습니다.


[_settings API]

$ curl -XPUT "http://localhost:9200/db/_settings" -d'

{

    "index.routing.allocation.require.box_type":"warm"

}'


[Request body에 settings]

$ curl -XPUT "http://localhost:9200/db" -d'

{

  "settings": {

    "index.routing.allocation.require.box_type":"warm"

  }

}'


개인적으로는 위 두 가지 방식이 다 동작해야 한다고 생각해서 실행을 시켰습니다.

해보시면 아시겠지만 아래 방식은 index_already_exists_exception 에러가 발생을 합니다.

Elasticsearch에 확인해본 결과로는 에러 메시지를 잘못 return 해준 경우라고 하내요. 즉, trivial 정도의 bug(?) 라고 봐도 될 것 같긴 합니다.

어쨌든 수정할 거라고 하니 나중에는 반영 되리라 기대 합니다.


그리고 http method 사용시 보시면 아시겠지만 PUT method 를 사용하셔야 합니다.

제가 POST 를 사용했는데요.

이 경우에는 PUT 을 사용하는게 맞다고 합니다.

제가 삽질한 이유가 되겠습니다. ㅡ.ㅡ;;

:

[Elasticsearch] shard allocation 운영 테스트용 REST 코드 - 1.6.0 이상.

Elastic/Elasticsearch 2015. 7. 3. 13:59

작성하고 보니 최신 내용을 반영할걸 이라는 후회가 밀려 오내요.

이전 글 http://jjeong.tistory.com/1034 이거는 사실 deprecated 예정입니다.

코드에도 명시되어 있어서.. ^^;;


아래 코드로 변경 합니다.

참고하세요.


curl -XPUT localhost:9200/_cluster/settings -d '{

    "persistent" : {

        "cluster.routing.allocation.enable" : "primaries",

        "cluster.routing.allocation.allow_rebalance" : "indices_all_active",

        "cluster.routing.allocation.cluster_concurrent_rebalance" : 2,

        "cluster.routing.allocation.node_initial_primaries_recoveries" : 4,

        "cluster.routing.allocation.node_concurrent_recoveries" : 2

    }

}'

※ 위 값들은 default 값입니다. "primaries" 만 빼고요 ^^


상세 내용을 확인 하고 싶으신 분들은 아래 문서를 참고하시길 바랍니다.


https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-cluster.html#shards-allocation


그냥 넘어 갈라고 했지만...


▷ cluster.routing.allocation.allow_rebalance

설명에 있지만 이건 shard rebalance에 대한 설정 입니다.

아래 값들에 대한 조건일 때 rebalance 하겠다는 것으로 이해 하시면 됩니다.

always : 항상 할 거다.

indices_primaries_active : primary shard 가 올라 오면 할 거다.

indices_all_active : 전체 shard 가 올라 오면 할 거다.


당연히 indices_all_active 가 default 설정이 되겠죠.


▷ cluster.routing.allocation.cluster_concurrent_rebalance

클러스터를 통틀어서 동시에 rebalance 할 shard 수를 제한 하는 설정 입니다.

기본은 2개로 설정 되어 있습니다.


▷ cluster.routing.allocation.node_initial_primaries_recoveries

각 노드 당 primary shard recovery에 대한 초기 크기를 설정 하는 것입니다.

기본은 4개로 설정 되어 있습니다.


▷ cluster.routing.allocation.node_concurrent_recoveries

노드에서 동시에 수행할 recovery 크기를 설정 하는 것입니다.


▷ cluster.routing.allocation.enable

이게 이전에 deprecated 된 설정의 확장인데요. (위에 설정도 포함 이지만..)

shard 종류에 따라 어떻게 처리 할 것인지를 결정 하게 합니다.

all : 몽땅 다 하겠다.

primaries : primary shard 만 하겠다.

new_primaries : 새로 생성한 인덱스의 primary shard 만 하겠다.

none : 몽땅 다 안하겠다.


딱 보면 disable_allocation:true = primaries + none 정도로 보면 쉽쥬.

반대는 disable_allocation:false = all 정도로 보면 쉽쥬.


:

[Elasticsearch] shard allocation 운영 테스트용 REST 코드

Elastic/Elasticsearch 2015. 7. 2. 18:18
매번 작성 하기 귀찮아서 그냥 남겨 봅니다.

[shard allocation disable]
curl -XPUT localhost:9200/_cluster/settings -d '{
    "persistent" : {
    "cluster.routing.allocation.disable_allocation" : true
    }
}'

[모든 종류의 shard allocation disable]
curl -XPUT localhost:9200/_cluster/settings -d '{
    "transient" : {
        "cluster.routing.allocation.enable" : "none"
    }
}'

[shard allocation enable]
curl -XPUT localhost:9200/_cluster/settings -d '{
    "persistent" : {
    "cluster.routing.allocation.disable_allocation" : false
    }
}'

[모든 종류의 shard allocation enable]
curl -XPUT localhost:9200/_cluster/settings -d '{
    "transient" : {
        "cluster.routing.allocation.enable" : "all"
    }
}'

[모든 인덱스의 replica shard disable]
curl -XPUT localhost:9200/*/_settings -d '{"number_of_replicas":0}'



:

[ElasticSearch] shard allocation 설정.

Elastic/Elasticsearch 2014. 7. 2. 17:36

shard rebalancing 제어하기 위해... 


curl -XPUT localhost:19200/_cluster/settings -d '{ "persistent" : { "cluster.routing.allocation.enable" : "none" } }'

curl -XPUT localhost:19200/_cluster/settings -d '{ "persistent" : { "index.routing.allocation.enable" : "none" } }'

:

[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] sharding 알고리즘.

Elastic/Elasticsearch 2014. 1. 28. 16:47

elasticsearch 에서 어떤식으로 index 와 document 를 분산 시키는지 궁금 하신 분들이 계실걸로 압니다.

뭐 소스 코드 보신 분들은 다 아실 것 같고 보기 귀찮으신 분들을 위해서 짧게 적어 봅니다.


[Index Sharding Route]

- index settings 에서 number_of_shards 설정 정보를 이용합니다.

- 그래서 각 node 들에 순서데로 나눠서 할당을 합니다.


[Document Route]

- sharding 된 index shard 에 document 를 어떻게 분배 할지 결정을 합니다.

- 분배는 hash 알고리즘을 이용합니다.

- Math.abs( hash(....) % numberOfShards )


관련 소스는 아래 

- org.elasticsearch.cluster.routing 패키지

입니다.

: