본문 바로가기
Infra/검색엔진

Elasticsearch 도커 설치

by 골든크랩 2023. 8. 30.
728x90
반응형

 

1. 이미지 댕겨오기

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

-> ubuntu 20.04 

 

2. 실행하기

docker run -d --name elasticsearch  -p 9200:9200 -p 9300:9300 -v elasticsearch-root:/usr/share/elasticsearch/data  -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:8.7.0

 

9200 : EL에 접속하는 포트

9300 : 내부 노드가 통신하는 포트

single-node : 단일 노드 실행

 

 

3. 접속방법 --> id와 pwd 를 넣어야 들어갈수 있음. 4번으로 진행하면 됨

https://localhost:9200

 

계정은 : elastic

 

 

설치 위치 : /usr/share/elasticsearch

config : /usr/share/elasticsearch/config/

init script :  

 

4. 컨테이너에 접속하기

docker exec -it elastic bash

 

 

5. 비밀번호 설정 (아래 붉은 글씨를 타이핑한다.)

 

비밀번호 설정시, kibana, logstash도 설치하는것을 알수 있다.

 

 

elasticsearch@5f61a9282584:~$ bin/elasticsearch-setup-passwords interactive
******************************************************************************
Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This       command will be removed in a future release.
******************************************************************************

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
elasticsearch@5f61a9282584:~$

 

 

6. 빠져나간다. 

exit

 

 

7. 테스트 방법

UBUNTU 쉘에서 하면 테스트가 잘 안됨...

 

chrome 브라우저에서 아래와같이 임의의 인덱스를 호출해보자.

 

https://localhost:9200/goldencrab

 

응답으로 아래와 같은 결과를 받는다.

{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [goldencrab]","resource.type":"index_or_alias","resource.id":"goldencrab","index_uuid":"_na_","index":"goldencrab"}],"type":"index_not_found_exception","reason":"no such index [goldencrab]","resource.type":"index_or_alias","resource.id":"goldencrab","index_uuid":"_na_","index":"goldencrab"},"status":404}

 

참고) ubuntu 쉘에서 실행시 응답이 아래와같다.  해결법은 나중에 찾아보자.

goldencrab@DESKTOP-SRQ9MD1:~$ curl -XGET https://localhost:9200goldencrab


curl: (60) SSL certificate problem: self-signed certificate in certificate chain
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

 

8. 생성/삭제/레코드생성.....Postman 에서 실행해야 함. 쉘에서 하면 7번의 SSL 오류 같은게 뜸

생성 : curl -XPUT https://localhost:9200/goldencrab

삭제 : curl -XDELETE https://localhost:9200/goldencrab 

레코드생성 : curl -XPOST https://localhost:9200/goldencrab/class/1 -d '{"title":"goldencrab", "shef":"dennis"}'

 

 

 

# apt-get update

#apt-get install net-tools

#apt-get install nano

#apt-get install vim

#apt-get install telnet

#apt-get install wget

#apt-get install systemd

 

 

=======================================

Postman으로 테스트 방법은 아래글 참고.

 

https://ksb-dev.tistory.com/309

 

엘라스틱서치 8.X 도커로 무작성 실행해보기

1. 개요 검색엔진으로 유명한 엘라스틱 서치(Elastic Search)를 도커로 실행해 볼 것입니다. 엘라스틱 서치 버전 8 부터 Security가 default로 설정되어 있기 때문에, 이전 버전과 달리 비밀번호를 설정해

ksb-dev.tistory.com

 

 

 

 

728x90
반응형

'Infra > 검색엔진' 카테고리의 다른 글

EL과 RDB 비교  (0) 2023.10.27
kibana 설치하기 (8.7.0)  (0) 2023.08.30
Knowledge Graph  (0) 2022.08.30
ElasticSearch 실습 - 색인 생성, 웹사이트와 ES 연결등  (0) 2022.08.30
Solr 설치  (0) 2021.07.01

댓글