Backup

docker elasticsearch in mac setting

두라미 2024. 3. 21. 15:57

 

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

https://velog.io/@moongyu1/Elasticsearch-%EB%A1%9C%EC%BB%AC-%EA%B0%9C%EB%B0%9C-%ED%99%98%EA%B2%BD-%EC%84%B8%ED%8C%85%ED%95%98%EA%B8%B0-with-Docker

 

 


위 문서 그대로 

# download elasticsearch file 

docker network create elastic

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.12.2

docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.12.2

 

 

아래는 처음에 생성되는 정보들. 문서에 따르면 다시 생성할 수 있다고. 

✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.

ℹ️  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
  1owP-24xIpsLziZeJ7KX

ℹ️  HTTP CA certificate SHA-256 fingerprint:
  5b85730195ac8e432c480c4b2b0c6d5d68efb86fc84e0b054e44d50639c5885a

ℹ️  Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjE4LjAuMjo5MjAwIl0sImZnciI6IjViODU3MzAxOTVhYzhlNDMyYzQ4MGM0YjJiMGM2ZDVkNjhlZmI4NmZjODRlMGIwNTRlNDRkNTA2MzljNTg4NWEiLCJrZXkiOiI2bHJEWDQ0Qm9jNDk2NDlxQktiZDpieHVSRnFoR1JOU2lQam1DTnZJRXVBIn0=

ℹ️ Configure other nodes to join this cluster:
• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
  eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjE4LjAuMjo5MjAwIl0sImZnciI6IjViODU3MzAxOTVhYzhlNDMyYzQ4MGM0YjJiMGM2ZDVkNjhlZmI4NmZjODRlMGIwNTRlNDRkNTA2MzljNTg4NWEiLCJrZXkiOiI2VnJEWDQ0Qm9jNDk2NDlxQktiZDpKQlZtZzNwQ1NPS29Ua3BGbTdwdml3In0=

  If you're running in Docker, copy the enrollment token and run:
  `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.12.2`

 

 

본인의 설정 파일에 환경변수를 설정해준다. 

export ELASTIC_PASSWORD="1owP-24xIpsLziZeJ7KX"

 

 

docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .

컨테이너에서 지금 내 맥북으로 인증서 파일을 복사해준다. 

 

 

curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200

이렇게 호출해야 호출 가능 

근데 개발 환경에서는 http로 붙는게 낫다. 

 

 

 

# 명령어
docker ps

docker start es01

 

 

docker exec -u root -it container_id  /bin/bash

apt-get update && apt-get install vim

 

true에서 false로 바꿈

 

 

 

restart해보겠습니다

 

docker-cluster-test로 이름 바꿨는데, 적용 잘 됐습니다. http 통신도 가능. 개발환경 용 입니다.