[Tistory] [ES] M2 Elastic search, Kibana 도커 설치

원글 페이지 : 바로가기

1. 도커 허브에서 elasticsearch 최신 버전 확인하기 https://hub.docker.com/_/elasticsearch elasticsearch – Official Image | Docker Hub Quick reference Supported tags and respective Dockerfile links Quick reference (cont.) What is Elasticsearch? Elasticsearch is a distributed, RESTful search and analytics engine capable of solving a growing number of use cases. As the heart of the Elastic hub.docker.com 더보기 docker pull elasticsearch 위 명령만으로는 최신 버전이 자동으로 pull 받아지지 않았음 Using default tag: latest Error response from daemon: manifest for elasticsearch:latest not found: manifest unknown: manifest unknown 2. 도커 이미지 pull 받기 (pull 받지 않고 실행하면 자동 pull 되므로 생략 가능) docker pull elasticsearch:8.12.1 마찬가지로 키바나도 엘라스틱서치와 같은 버전 도커 이미지 pull 받기 docker pull kibana:8.12.1 3. 엘라스틱서치, 키바나 도커 컨테이너 실행 # 엘라스틱 서치 실행
# 옵션
# –net: 도커 네트워크 지정 / -it: interactive terminal 터미널환경에서 명령실행 / -m: 컨테이너 할당 메모리 제한 / –name: 컨테이너명 지정
docker run –net elastic -it -m 1GB -p 9200:9200 -p 9300:9300 –name elasticsearch elasticsearch:8.12.1

# 키바나 실행
docker run -d –net elastic –name kibana -p 5601:5601 kibana:8.12.1 도커 컨테이너 첫 실행하면 끝에 로그에 보안 관련 정보가 나오니까 꼭 확인 할 것 ! 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`): VUexW=odcrAI7Xoce+fa ℹ️ HTTP CA certificate SHA-256 fingerprint: b5180ccd6d0164d62f93711912990567c686a9584ed2da1972ce36ad3e7c1716 ℹ️ 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): eyJ2ZXIiOiI4LjEyLjEiLCJhZHIiOlsiMTcyLjE4LjAuMjo5MjAwIl0sImZnciI6ImI1MTgwY2NkNmQwMTY0ZDYyZjkzNzExOTEyOTkwNTY3YzY4NmE5NTg0ZWQyZGExOTcyY2UzNmFkM2U3YzE3MTYiLCJrZXkiOiJSTWN5MUkwQkhodm4zVFFMZHVNZjpyX0FYY0dXbFRGaVVncTZFTktqWlN3In0= ℹ️ Configure other nodes to join this cluster: • Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch –enrollment-token ` (valid for the next 30 minutes): eyJ2ZXIiOiI4LjEyLjEiLCJhZHIiOlsiMTcyLjE4LjAuMjo5MjAwIl0sImZnciI6ImI1MTgwY2NkNmQwMTY0ZDYyZjkzNzExOTEyOTkwNTY3YzY4NmE5NTg0ZWQyZGExOTcyY2UzNmFkM2U3YzE3MTYiLCJrZXkiOiJSY2N5MUkwQkhodm4zVFFMZHVNZzpWTWVBRGo2clNybTJ6MlVkNElzZEZRIn0= If you’re running in Docker, copy the enrollment token and run: `docker run -e “ENROLLMENT_TOKEN=” docker.elastic.co/elasticsearch/elasticsearch:8.12.1` 4. 엘라스틱 비밀번호, 키바나 토큰 확인 위에서 도커 실행 후 비밀번호와 토큰을 확인하지 못했다면 자격 증명을 다시 생성할 수 있음 # elastic 비밀번호 재설정
docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic

# kibana 토큰 생성
docker exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana 도커 공식 가이드에서는 elastic 비밀번호를 셸의 환경 변수로 저장하는 것이 좋다고함 export ELASTIC_PASSWORD=”비밀번호” http_ca.crt SSL인증서를 컨테이너에서 로컬로 복사 docker cp elasticsearch:/usr/share/elasticsearch/config/certs/http_ca.crt . 4-1. 비밀번호 세팅 비밀번호 설정도 가능함 # 도커 진입
docker exec -it -u 0 elasticsearch /bin/bash

cd bin
elasticsearch-setup-passwords interactive 5. 엘라스틱 실행 확인하기 1) curl로 호출해보기 curl –cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 2) 웹브라우저로 확인 https://localhost:9200으로 접속 보안 문제 발생시 크롬 빈화면 클릭하고 thisisunsafe 입력하면 풀림.. 더보기  참고 블로그 https://velog.io/@480/%EC%97%B0%EA%B2%B0%EC%9D%B4-%EB%B9%84%EA%B3%B5%EA%B0%9C%EB%A1%9C-%EC%84%A4%EC%A0%95%EB%90%98%EC%96%B4-%EC%9E%88%EC%A7%80-%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4.-%EC%9D%B4%EC%9C%A0%EC%99%80-%ED%8C%81 사용자 이름은 elastic, 비밀번호는 위에서 확인하거나 설정한 비밀번호 접속 확인 6. 키바나 실행 확인 1) http://localhost:5601 접속 2) 위에서 확인한 토큰을 붙여넣기 하면됨 토큰을 확인하지 못한 경우나 유효시간이 경과한 경우에는 토큰을 새로 생성 토큰 생성하기 # 엘라스틱서치 컨테이너 진입
docker exec -it -u 0 elasticsearch /bin/bash

cd bin
elasticsearch-create-enrollment-token -s kibana 맨 아래에 생성된 토큰을 복붙하면 됨 3) Verification required 6자리 입력하기 # 키바나 컨테이너 진입
docker exec -it -u 0 kibana /bin/bash

cd bin
kibana-verification-code 시작 중 셋업되면 wlcom to Elastic 아래와 같은 로그인 화면을 확인할 수 있음 위에서 설정한 비밀번호를 입력하면됨 로그인 완료 https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html Install Elasticsearch with Docker | Elasticsearch Guide [8.12] | Elastic The container runs Elasticsearch as user elasticsearch using uid:gid 1000:0. Bind mounted host directories and files must be accessible by this user, and the data and log directories must be writable by this user. www.elastic.co

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다