티스토리 뷰

Scaling down an Elasticsearch cluster

Elasticsearch is a NoSQL database optimized for searching.

cluster는 node들이 동일한 cluster.name을 공유하면서 만들어진다. 데이터는 자동으로 분산처리된다. cluster에서 node를 제거하는 것은 더욱더 도전적이다. 첫째, cluster status를 green인것을 확인해라. cluster에서 node를 제거하는 것은, cluster가 rebalance와 분산처리 (status yellow) 할때까지 기다려야 한다. 그리고, 이작업을 3개의 node가 남을 때까지 반복해야 한다.

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

데이터는 index로 나뉘어진다. 이것은 database의 table과 비교된다. 그리고, index는 shard로 나뉘어져서 cluter에 저장된다. 당신이 옮기길 원하는 index에 대한 shard정보는 아래와 같이 얻을수 있다.

curl -XGET '192.168.2.35:9200/_cat/shards/yourindex'  
yourindex 1 p STARTED 537256 1.9gb 192.168.0.45 anothernode  
yourindex 2 p STARTED 537506 2gb 192.168.0.35 laptop  
yourindex 4 p STARTED 536696 1.9gb 192.168.0.35 laptop  
yourindex 3 p STARTED 537859 1.9gb 192.168.0.35 laptop  
yourindex 0 p STARTED 537282 1.9gb 192.168.0.35 laptop  

마지막으로 재할당(reallocation) 할때까지 기다려라.

curl -XPOST 'localhost:9200/_cluster/reroute' -d '{ "commands": \
    [{ "move" : { "index" : "yourindex", "shard" : 1, 
    "from_node": "anothernode", "to_node": "laptop" } }\] }'

Take the node down as soon as the cluster status is green again and reactivate balancing. Transient settings are lost after restarting the service.

curl -XPUT 'localhost:9200/_cluster/settings' -d '{ "transient" : { "cluster.routing.allocation.enable" : "all" } }'

https://schneefux.xyz/tech/scaling-elasticsearch/

'Kafka & Elasticsearch' 카테고리의 다른 글

Text and Keyword 타입  (0) 2020.04.29
Pandas  (0) 2020.03.05
Kafka Streams (Stateful, Aggregating)  (0) 2019.03.17
Kafka Fail-over (cluster)  (0) 2019.01.07
토픽 삭제 (Topic delete)  (0) 2019.01.06
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함