요번엔 Elasticsearch 초간단 실행방법에 대해 알아보자.


알아보기 전에, Elasticsearch가 뭔지에 설명을 하고 넘어가자. 

Elasticsearch 는 분산형 RESTful 검색 및 분석 엔진이다. (홈페이지에도 이렇게 설명을 하고 있다...)

처음엔 데이터 검색엔진이라고 생각했지만, 데이터 분석과 시각화 기능까지 제공하고 있다. 

시각화 기능은 Kibana를 설치하여 이용할 수 있는데, 이 부분은 추후에 진행해보자.


그럼 이제, Elasticsearch 설치부터 알아보자.

참고로, 설치 환경은 Linux 환경 (Ubuntu 16.04) 이다. 


우선 설치 파일은 https://www.elastic.co/kr/downloads/elasticsearch 에서 받을 수 있다.

글 작성시의 최신 버전은 5.5.1이다. 


다운로드 페이지에서 tar 파일을 받아서 설치할 경로에 저장을 한다.

명령어로 받으려면 아래와 같이 하면 된다.


wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.tar.gz


다운로드 받은 파일은 tar 파일로 압축을 해제 한다.


tar zxvf elasticsearch-5.5.1.tar.gz 


압축해제를 하고나면, 파일명과 같은 폴더가 생기고, 파일 목록은 아래와 같다.


$~/elasticsearch/elasticsearch-5.5.1$ ls

LICENSE.txt  NOTICE.txt  README.textile  bin  config  data  lib  logs  modules  plugins


bin 폴더에 가서 elasticsearch 를 실행하면 되는데, 

전에 config 폴더에 elasticsearch.yml 파일을 열어서 몇가지 설정만 해놓자.


먼저, 아래 글과 같이 path.logs에 경로를 지정한다. 이름과 같이 로그 파일 저장경로이다.


...

# ----------------------------------- Paths ------------------------------------

#

# Path to directory where to store the data (separate multiple locations by comma):

#

#path.data: /path/to/data

#

# Path to log files:

#

path.logs: /home/austinlee/elasticsearch/elasticsearch-5.5.1/logs

...


다음으로는, IP 설정이다. elasticsearch 서버의 IP 주소를 입력한다. 

일단, 내부적으로 테스트 하는 것이므로 Localhost인 127.0.0.1로 한다.


...

# ---------------------------------- Network -----------------------------------

#

# Set the bind address to a specific IP (IPv4 or IPv6):

#

network.host: 127.0.0.1

#

# Set a custom port for HTTP:

#

#http.port: 9200

#

# For more information, consult the network module documentation.

...


이렇게 설정하고 나서, bin 폴더에 있는 elasticsearch를 실행한다.


./bin/elasticsearch


데몬으로 실행하고 싶으면 다음과 같이 실행하면 된다.


./bin/elasticsearch -d


데몬으로 실행했을 경우, 종료는 해당 pid 를 찾아서  kill 을 하면 된다.


# pid 찾기 

ps -ef | grep elasticsearch 


# 찾은 pid 로 프로세스 죽이기

kill 'pid'


elasticsearch 서버를 실행하고 나서 정상적으로 동작을 하는지, 웹 브라우저를 통해 확인한다.

주소 창에 http://localhost:9200/를 입력하고 접속을 한다. (localhost는 위에서 설정한 IP 주소, 접속  Default 포트는 9200이다.)


{
  "name" : "OR5RLR1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Fe_tQmzOT8OVj-K1C7VQYA",
  "version" : {
    "number" : "5.5.1",
    "build_hash" : "19c13d0",
    "build_date" : "2017-07-18T20:44:24.823Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

정상 동작이면 위와 같은 정보가 나온다.


이렇게 초간단 실행법은 끝!

이제 REST API 를 이용해서 데이터를 저장하고 검색하면 된다. 이에 대한 것은 다음에....






반응형

+ Recent posts