시작하며
Elasticsearch를 Docker로 설치하면서 발생한 오류들과 해결 방법을 기록으로 남긴다. 공식 가이드를 따라 설치를 진행했지만 몇 가지 환경적 문제를 마주쳤고, 결국 Colima를 활용하여 설치를 완료했다.
공식 가이드: https://www.elastic.co/guide/en/kibana/current/docker.html
Docker를 이용한 Elasticsearch 설치
Docker image pull (elasticsearch)
docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.5.3
docker run -d --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.5.3
# Port 9200 is used for all API calls over HTTP. This includes search and aggregations, monitoring and anything else that uses a HTTP request. All client libraries will use this port to talk to Elasticsearch
# Port 9300 is a custom binary protocol used for communications between nodes in a cluster. For things like cluster updates, master elections, nodes joining/leaving, shard allocation깔끔하게 설치되면 좋겠지만 역시나 몇 가지 문제가 발생했다.
발생한 error 1
- ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
- SOLVED: 공식 설치 가이드를 확인하면 최대 map-count를 조정하라는 안내가 나온다. https://www.elastic.co/guide/en/elasticsearch/reference/8.2/vm-max-map-count.html
발생한 error 2
- ERROR: cannot find tty
- SOLVED: https://github.com/docker/for-mac/issues/4822
docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh
sysctl -w vm.max_map_count=262144Docker VM 관련 참고
- https://stackoverflow.com/questions/41192680/update-max-map-count-for-elasticsearch-docker-container-mac-host
- https://github.com/docker/for-mac/issues/4822
결국 Colima를 사용해 설치를 완료했다.
docker version
> OS/Arch: darwin/amd64
Context: colima -> 사용중인 context는 colima(not docker-desktop)
Experimental: true
# 복구는 docker context use default최초 실행 시 자동 보안 설정
여기까지 진행했다면, 최초 실행 시 아래와 같은 보안 설정이 자동으로 이루어진다.
- transport 및 HTTP 레이어에 대한 인증서와 키가 생성된다.
- TLS(Transport Layer Security) 구성 설정이
elasticsearch.yml에 기록된다. elastic사용자의 패스워드가 생성된다.- Kibana를 위한 enrollment token이 생성된다.
백그라운드 실행 시 비밀번호가 안 보이는 현상
docker logs로 다시 봐도 비밀번호가 보이지 않는 경우가 있다.
참고: https://github.com/elastic/elasticsearch/issues/85047
docker exec -ti es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
docker exec -ti es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibanaDocker image pull (kibana)
docker pull docker.elastic.co/kibana/kibana:8.5.3
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.5.3이후 Logstash 설치
docker pull docker.elastic.co/logstash/logstash:8.5.3정리하며
Docker를 이용해 Elasticsearch 8.5.3을 설치하는 과정에서 vm.max_map_count 설정과 tty 오류라는 두 가지 장벽을 만났다. macOS 환경에서는 Docker Desktop 대신 Colima를 활용하면 이러한 문제를 우회할 수 있다. 최초 실행 시 TLS 인증서와 패스워드가 자동 생성되며, 백그라운드 모드에서는 reset-password 명령어로 재설정하면 된다.