[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 통신을 한다는 것을 잊으면 안된다는 것입니다.

: