'cluster'에 해당되는 글 5건

  1. 2020.09.10 [Elasticsearch+Docker] 로컬 클러스터 구성 시 흔한 실수.
  2. 2020.04.02 [Elasticsearch] Docker Compose 구성 하기
  3. 2019.10.02 [Elasticsearch] Elasticsearch Cluster Auto Scaling 구성 하기.
  4. 2013.04.23 [Elasticsearch] Cluster 설정 중 rack 과 zone 알아보기.
  5. 2013.04.17 [Elasticsearch] Indices API - Cluster ....

[Elasticsearch+Docker] 로컬 클러스터 구성 시 흔한 실수.

Elastic/Elasticsearch 2020. 9. 10. 08:54

Elasticsearch 가 각 노드들과 discovery 를 하기 위해서는 Transport 통신이 이루어져야 합니다.

문서에 정확하게 나와 있으나 놓치기 쉬운 부분이라 기록해 봅니다.

 

[참고문서]

https://www.elastic.co/guide/en/elasticsearch/reference/current/discovery-settings.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-bootstrap-cluster.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-settings.html

 

[Content Snippet]

[discovery.seed_hosts]

Provides a list of the addresses of the master-eligible nodes in the cluster.

1. transport.profiles.default.port
2. transport.port
If neither of these is set then the default port is 9300.

[Example Configuration]

[Node 1 - docker-compose.yml]
version: '3.7'

services:
  docker-es:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
    container_name: e1
    environment:
      - cluster.name=e3k1
      - node.name=e1
...중략...
      - discovery.seed_hosts=host.docker.internal:9300,host.docker.internal:9301,host.docker.internal:9302
      - cluster.initial_master_nodes=e1,e2,e3
...중략...

[Node 2 - docker-compose.yml]
version: '3.7'

services:
  docker-es:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
    container_name: e2
    environment:
      - cluster.name=e3k1
      - node.name=e2
...중략...
      - discovery.seed_hosts=host.docker.internal:9300,host.docker.internal:9301,host.docker.internal:9302
      - cluster.initial_master_nodes=e1,e2,e3
...중략...

[Node 3 - docker-compose.yml]
version: '3.7'

services:
  docker-es:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
    container_name: e3
    environment:
      - cluster.name=e3k1
      - node.name=e3
...중략...
      - discovery.seed_hosts=host.docker.internal:9300,host.docker.internal:9301,host.docker.internal:9302
      - cluster.initial_master_nodes=e1,e2,e3
...중략...

 

위에 작성된 설정 예제는 로컬에서 3개의 Elasticsearch 컨테이너를 실행 시켜서 클러스터링 시키는 예제 입니다.

이 방법 말고도 하나의 docker-compose.yml 에 구성을 하셔도 됩니다. (단, 설정이 조금 달라 집니다.)

 

주의 점은,

위에 언급된 내용처럼 Transport 통신을 한다는 것을 잊으면 안된다는 것입니다.

:

[Elasticsearch] Docker Compose 구성 하기

Elastic/Elasticsearch 2020. 4. 2. 07:49

Elasticsearch 를 Single Node 로 구성 하기 위한 docker-compose.yml 내용을 살펴 봅니다.

 

참고문서)

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

 

docker-compose.yml)

version: '2.2'
services:
  ${ES-SERVICE-NAME}:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: ${ES-SERVICE-NAME}
    environment:
      - node.name=${NODE-NAME}
      - cluster.name=${CLUSTER-NAME}
      - discovery.type=single-node
      - discovery.seed_hosts=${NODE-NAME}
      - path.data=/usr/share/elasticsearch/data
      - path.logs=/usr/share/elasticsearch/logs
      - bootstrap.memory_lock=true
      - http.port=9200
      - transport.port=9300
      - transport.compress=true
      - network.host=0.0.0.0
      - http.cors.enabled=false
      - http.cors.allow-origin=/https?:\/\/localhost(:[0-9]+)?/
      - gateway.expected_master_nodes=1
      - gateway.expected_data_nodes=1
      - gateway.recover_after_master_nodes=1
      - gateway.recover_after_data_nodes=1
      - action.auto_create_index=true
      - action.destructive_requires_name=true
      - cluster.routing.use_adaptive_replica_selection=true
      - xpack.monitoring.enabled=false
      - xpack.ml.enabled=false
      - http.compression=true
      - http.compression_level=3
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nproc:
        soft: 1024000
        hard: 1024000
      nofile:
        soft: 1024000
        hard: 1024000
    sysctls:
      net.core.somaxconn: 65000
    healthcheck:
      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cat/health || exit 1"]
      interval: 30s
      timeout: 30s
      retries: 3
    restart: always
    volumes:
      - ${NAMED-VOLUME-DATA}:/usr/share/elasticsearch/data:rw
      - ${NAMED-VOLUME-LOG}:/usr/share/elasticsearch/logs:rw
#      - ${FULL-PATH-DATA}:/usr/share/elasticsearch/data:rw
#      - ${FULL-PATH-LOG}:/usr/share/elasticsearch/logs:rw
    ports:
      - 9200:9200
      - 9300:9300
    expose:
      - 9200
      - 9300
    networks:
      - ${NETWORK-NAME}

volumes:
  ${NAMED-VOLUME-DATA}:
    driver: local
  ${NAMED-VOLUME-LOG}:
    driver: local

networks:
  ${NETWORK-NAME}:
    driver: bridge

 

Single Node 로 구성 하기 위해 중요한 설정은

- environment: 섹션에서 discovery.type=single-node 

입니다.

 

만약, Clustering 구성을 하고 싶다면 위 설정을 제거 하고 아래 세개 설정을 작성 하시면 됩니다.

- cluster.initial_master_nodes=# node 들의 private ip 를 등록 합니다.
- discovery.seed_hosts=# node 들의 private ip 를 등록 합니다.

- network.publish_host=# 컨테이너가 떠 있는 host 의 private ip 를 등록 합니다.

 

path.data 에 대한 구성을 복수로 하고 싶으실 경우

- volumes: 섹션에서 named volume 을 여러개 설정 하시거나

- bind mount 설정을 구성 하셔서 

적용 하시면 됩니다.

 

위 docker-compose.yml 을 기준으로 single node 구성과 cluster 구성을 모두 하실 수 있습니다.

 

  • ${....} 는 변수명 입니다.
    • 본인의 환경에 맞춰 작명(?) 하셔서 변경 하시면 됩니다.
:

[Elasticsearch] Elasticsearch Cluster Auto Scaling 구성 하기.

Elastic/Elasticsearch 2019. 10. 2. 16:04

기억하기 위해 작성해 봅니다.

 

ES Cluster 를 아래와 같이 구성 한다고 가정 하고 들어 가겠습니다.

 

1. Master Node 2개

2. Coordinating Node 2개

3. Data Node 2개

 

ES Cluster 를 구성 하다 보면 CPU, MEM, DISK, NETWORK 등 모든 자원을 다 효율적으로 사용하도록 구성 하기는 매우 어렵습니다.

그렇다 보니 CPU 는 부족한데 MEM 은 남는 다던가 MEM 은 부족한데 CPU 는 남는 다던가 또는 가끔 말도 안되게 NETWORK Bandwidth 가 부족 할 때도 나오더군요.

 

암튼 그래서 모든 자원을 다 쥐어 짜듯이 구성 할 수 없으니 적당히 포기 하시길 권장 드립니다.

 

여기서 Auto Scaling 하는 구성은 Coordinating Node 와 Data node 이 두 가지 입니다.

 

우선 ES 는 너무 쉽게 Node 를 추가 하고 삭제 할 수 있습니다.

elasticsearch.yml 파일 내 Master Node 정보만 등록 해 두시면 됩니다.

 

- discovery.zen.ping.unicast.hosts: MASTER_NODE_LIST

 

설정 공식 문서는 아래 링크 참고 하세요.

https://www.elastic.co/guide/en/elasticsearch/reference/6.2/modules-discovery-zen.html

 

Zen Discovery | Elasticsearch Reference [6.2] | Elastic

The zen discovery is the built in discovery module for Elasticsearch and the default. It provides unicast discovery, but can be extended to support cloud environments and other forms of discovery. The zen discovery is integrated with other modules, for exa

www.elastic.co

 

Coordinating Node Auto Scaling  구성 하기)

0. 가장 먼저 하셔야 하는 작업은 elasticsearch.yml 파일 내 Master Node 정보 등록 입니다.

1. 우선 Coordinating Node 들을 LoadBalancer 로 묶습니다. (AWS 를 사용 하시면 ALB/ELB 로 구성 하시면 됩니다.)

    - Coordinating Node 의 경우 "Too many requests" 오류가 발생 할 경우 이를 예방 하기 위해 Auto Scaling 구성을 하면 좋습니다.

    - 보통 트래픽이 몰릴 경우 search thread 가 부족 할 수 있기 때문 입니다.

    - LB 로 묶는 또 다른 이유는 API 단에서 단일 Endpoint 를 바라 보게 해서 운영을 편하게 하기 위함 입니다.

2. Auto Scaling 설정 구성을 합니다.

    - 이 부분은 사용하시는 환경에 맞춰서 구성 하시면 됩니다.

    - 공식 문서를 참고 하시면 됩니다.

    - https://docs.aws.amazon.com/ko_kr/autoscaling/ec2/userguide/scaling_plan.html#scaling_typesof

 

Auto Scaling 그룹의 크기 조정 - Amazon EC2 Auto Scaling

Auto Scaling 그룹의 크기 조정 조정은 애플리케이션의 컴퓨팅 용량을 늘리거나 줄이는 기능입니다. 조정은 이벤트와 함께 시작되거나 Auto Scaling 그룹에 Amazon EC2 인스턴스를 시작 또는 종료하도록 지시하는 조정 작업과 함께 시작됩니다. Amazon EC2 Auto Scaling에서는 여러 가지 방법으로 애플리케이션의 요구 사항에 가장 적합하게 조정 기능을 조절할 수 있습니다. 그러므로 애플리케이션을 충분히 이해하는 것이 중요합니다.

docs.aws.amazon.com

3. 테스트 해보시고 서비스에 적용 하시면 됩니다.

 

 

Data Node Auto Scaling 구성 하기) 

0. 가장 먼저 하셔야 하는 작업은 elasticsearch.yml 파일 내 Master Node 정보 등록 입니다.

0. 더불어 Replica Shard 설정은 (Data Node - 1) 만큼 구성이 되어야 합니다.

0. 더불어 초기 Data Node 수와 Primary Shard 크기를 잘 정의 하셔야 합니다.

0. 이유는 Primary Shard 는 한번 생성 하게 되면 ReIndexing 을 하지 않고서는 변경이 불가능 합니다.

1. Auto Scaling 설정 구성을 합니다.

    - 이 설정 시 Shard reallocation 에 대한 이슈는 없는지 꼭 확인을 하셔야 합니다.

    - CPU, DISk I/O, NETWORK 등에 대한 성능 저하가 발생 할 수 있습니다.

 

1. Auto Scaling 설정 후 수동으로 Shard Allocation 이 가능 합니다.

    - 보통 이런 문제는 트래픽이 몰리거나 운영 시점에 발생을 하기 때문에 미리 스크립트 구성해 놓으시고 re-location  진행 하시면 됩니다.

    - 그래서 Shard Allocation 설정을 꺼 두셔야 합니다.

    - 공식 문서를 참고 하시면 됩니다.

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

 

Cluster level shard allocation | Elasticsearch Reference [7.4] | Elastic

Regardless of the result of the balancing algorithm, rebalancing might not be allowed due to forced awareness or allocation filtering.

www.elastic.co

2. Data Node 의 경우 Auto Scaling 종료 정책에 따라 Primary Shard 가 유실 되지 않도록 구성 하는 것이 좋습니다.

    - 물론 Full Replicaiton 구성이라 다른 Replica 가 Primary Shard 로 선출 되겠지만 그래도 주의 하는게 좋겠죠.

 

마무리를 하면)

Coordinating Node 까지는 쉽게 적용이 가능 합니다.

하지만, Data Node 적용은 실제 운영 경험이 있고 문제 발생 시 신속하게 대응이 가능 하지 않다면 시도 하지 마시라고 말씀 드리고 싶습니다.

:

[Elasticsearch] Cluster 설정 중 rack 과 zone 알아보기.

Elastic/Elasticsearch 2013. 4. 23. 16:36

본 문서는 개인적인 테스트와 elasticsearch.org 그리고 community 등을 참고해서 작성된 것이며,

정보 교환이 목적입니다.


잘못된 부분에 대해서는 지적 부탁 드립니다.

(예시 코드는 성능 및 보안 검증이 되지 않았습니다.)



[elasticsearch API 리뷰]

원문 링크 : http://www.elasticsearch.org/guide/reference/modules/cluster/


cluster 세팅 중 위 문서에 아래와 같은 설정이 있습니다.

Shard Allocation Awareness

sharding 과 replica 설정에 따라 clustering 환경에서 어떻게 배치 시킬것인지 관리 할 수 있도록 해주는 추가 설정 입니다.

즉, 특정 노드로 shard 를 배치 시키거나 replica 가 되도록 합니다.


아래는 이해를 돕기 위한 설정 예제 입니다.


[Rack 설정 예제]

- 1 cluster, 4 nodes


[node 공통]

cluster.name: cluster_a

cluster.routing.allocation.awareness.attributes: rack_id


[node 1]

  node.rack_id: rack_1

  node.name: node_1


[node 2]

  node.rack_id: rack_2

  node.name: node_2


[node 3]

  node.rack_id: rack_1

  node.name: node_3


[node 4]

  node.rack_id: rack_2

  node.name: node_4


[Zone 설정 예제]

- 1 cluster, 2 nodes


[node 공통]

cluster.name: cluster_a

cluster.routing.allocation.awareness.force.zone.values: zone_1, zone_2

cluster.routing.allocation.awareness.attributes: zone


[node 1]

  node.zone: zone_1

  node.name: node_1


[node 2]

  node.zone: zone_1

  node.name: node_2



Rack 의 경우 서로 다른 Rack 위치한 node 들에 대한 분산설정으로 같은 IDC 내 서로 다른 rack 이나 IDC 간 HA 구성이 가능 합니다.

 Zone 의 경우 특정 zone 으로 동일 데이터가 몰려 SPOF 를 예방하기 위한 구성으로 사용이 가능 합니다.


직접 해보시면 쉽게 이해가 됩니다. :)

:

[Elasticsearch] Indices API - Cluster ....

Elastic/Elasticsearch 2013. 4. 17. 14:58

본 문서는 개인적인 테스트와 elasticsearch.org 그리고 community 등을 참고해서 작성된 것이며,

정보 교환이 목적입니다.


잘못된 부분에 대해서는 지적 부탁 드립니다.

(예시 코드는 성능 및 보안 검증이 되지 않았습니다.)



[elasticsearch API 리뷰]

원문 링크 : http://www.elasticsearch.org/guide/reference/api/admin-cluster-*


cluster 관련 API 는 워낙 원문이 쉽고 직관적으로 잘 되어 있어서 따로 정리 하지 않습니다.

아래 링크들을 참고 하시기 바랍니다.


Cluster

: