elasticsearch cluster and traefik
개요
빅데이터 관리를 위하여 elasticsearch를 이용하던중, 기존 데이터 모델링이 1개의 인덱스 기반이여서 어쩔수 없이 노드 구성을 위해 클러스터와 traefik proxy 를 이용하여 분산 처리 하였다.
작업내용
docker-compose 파일로 간단하게 클러스터 구성을 진행 하였다.
docker-compose up -d
docker-compose.yaml
version: '3'
services:
elasticsearch:
restart: always
image: elasticsearch:6.8.5
container_name: elasticsearch
environment:
- node.name=elasticsearch
- cluster.name=es-docker-cluster
- TZ=Asia/Seoul
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch2,elasticsearch3"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- ./elasticsearch/data:/usr/share/elasticsearch/data
cap_add:
- IPC_LOCK
labels:
- stack=elasticsearch6
- traefik.http.routers.elasticsearch.rule=PathPrefix(`/`)
- traefik.http.services.elasticsearch.loadbalancer.server.port=9200
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.path=/_cluster/health?local=true
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.interval=15s
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.timeout=10s
elasticsearch2:
restart: always
image: elasticsearch:6.8.5
container_name: elasticsearch2
environment:
- node.name=elasticsearch2
- cluster.name=es-docker-cluster
- TZ=Asia/Seoul
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch,elasticsearch3"
- "node.master=false"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- ./elasticsearch/data2:/usr/share/elasticsearch/data
cap_add:
- IPC_LOCK
labels:
- stack=elasticsearch6
- traefik.http.routers.elasticsearch.rule=PathPrefix(`/`)
- traefik.http.services.elasticsearch.loadbalancer.server.port=9200
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.path=/_cluster/health?local=true
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.interval=15s
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.timeout=10s
elasticsearch3:
restart: always
image: elasticsearch:6.8.5
container_name: elasticsearch3
environment:
- node.name=elasticsearch3
- cluster.name=es-docker-cluster
- TZ=Asia/Seoul
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch,elasticsearch2"
- "node.master=false"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- ./elasticsearch/data3:/usr/share/elasticsearch/data
cap_add:
- IPC_LOCK
labels:
- stack=elasticsearch6
- traefik.http.routers.elasticsearch.rule=PathPrefix(`/`)
- traefik.http.services.elasticsearch.loadbalancer.server.port=9200
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.path=/_cluster/health?local=true
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.interval=15s
- traefik.http.services.elasticsearch.loadbalancer.healthcheck.timeout=10s
traefik:
image: traefik:2.3
command:
- --entrypoints.web.address=:9200
- --providers.docker=true
- --providers.docker.constraints=Label(`stack`,`elasticsearch6`)
- --api.insecure
- --accesslog=true
depends_on:
- elasticsearch
- elasticsearch2
- elasticsearch3
ports:
- 9200:9200
volumes:
- /var/run/docker.sock:/var/run/docker.sock
kibana:
image: kibana:6.8.5
container_name: log-kibana
environment:
- TZ=Asia/Seoul
- ELASTICSEARCH_HOSTS="http://elasticsearch:9200"
links:
- "elasticsearch"
ports:
- "5601:5601"
결과
노드3개로 분할되어 분산 저장된다.
localhost:5601
Author And Source
이 문제에 관하여(elasticsearch cluster and traefik), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@anisia20/elasticsearch-cluster-and-traefik저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)