Elasticsearch 설치

김수민·2020년 4월 19일
0

https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html

1) wget으로 압축파일 받기 / 풀기

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
tar -xzf <elasticsearch>

2) Java 설치

  • 설치 가능 확인
yum list java*jdk-devel
Error: Failed to download metadata for repo 'rhui-client-config-server-8'
// 참고 : https://access.redhat.com/discussions/4656371
// dnf?? 삭제 후 upgrade
[ec2-user@ip-172-31-46-224 downloads]$ sudo yum list java*jdk-devel
Last metadata expiration check: 0:00:18 ago on Sun 19 Apr 2020 05:37:23 AM UTC.
Available Packages
java-1.8.0-openjdk-devel.x86_64      1:1.8.0.242.b08-0.el8_1       rhel-8-appstream-rhui-rpms
java-11-openjdk-devel.x86_64         1:11.0.6.10-0.el8_1           rhel-8-appstream-rhui-rpms
  • 설치
sudo yum install java-1.8.0-openjdk-devel.x86_64

3) elasticsearch 실행

ec2 mechine의 메모리가 1gb라서 "There is insufficient memory for the Java Runtime Environment to continue."라는 오류메시지가 뜬다.

~/elasticsearch/jvm.optins 파일에서 "-Xms1g"를 "-Xms256m"로 바꾸어 주었다.

./elasticsearch -d 

실행 확인: localhost:9200

4) Index some documents

JSON 형식의 document를 Elasticsearch index에 PUT 한다.

curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "John Doe"
}
'

성공적으로 PUT되었다는 응답을 받았다.

PUT한 document를 다음과 같이 GET 할 수 있다.

curl -X GET "localhost:9200/customer/_doc/1?pretty"

5) 대량 Indexing

6) searching

profile
python developer

0개의 댓글