TOOL/ELK 2019. 11. 20. 11:24

ElasticSearch (엘라스틱서치)

설치 on Linux

1. 환경:

  • OS: CentOS 7.6
  • JDK: 1.8

2. 설치:

0. root로 접속
1. User와 Group 생성
  • es라는 User로 예를 들겠다.

      groupadd es
      useradd -g es es
      passwd es    
2. ElasticSearch 설치: https://www.elastic.co/guide/en/elasticsearch/reference/7.3/targz.html#install-linux
  • /usr/local/elasticsearch에 설치하는 것으로 예를 들겠다.

      mkdir /usr/local/elasticsearch
      cd /usr/local/elasticsearch
      wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz
      wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz.sha512
      shasum -a 512 -c elasticsearch-7.3.2-linux-x86_64.tar.gz.sha512 
      tar -xzf elasticsearch-7.3.2-linux-x86_64.tar.gz
      cd elasticsearch-7.3.2/ 
3. 권한 부여
chown -R es:es /usr/local/elasticsearch
4. ElasticSearch Plugin Nori 설치
su es
cd /usr/local/elasticsearch        
bin/elasticsearch-plugin install analysis-nori
bin/elasticsearch-plugin list
5. 실행
  • 실행

      ./bin/elasticsearch
  • 실행 as a Daemon

      ./bin/elasticsearch -d -p pid
    • Shutdown

        pkill -F pid
    • with Cluster

        ./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1

3. 확인

1. 확인 - ElasitcSearch
curl -X GET http://localhost:9200/
{
  "name" : "kofpi-DMZ-Visual01",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "u7JkfXqTT-KHXowgbwB-Vw",
  "version" : {
    "number" : "7.3.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "1c1faf1",
    "build_date" : "2019-09-06T14:40:30.409026Z",
    "build_snapshot" : false,
    "lucene_version" : "8.1.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
2. 확인 - ElasticSearch Plugin Nori
curl -X POST http://127.0.0.1:9200/_analyze?pretty -H 'Content-Type: application/json' -d '{"analyzer":"nori", "text":"아버지가방에들어갔다"}'
{
  "tokens" : [
    {
      "token" : "아버지",
      "start_offset" : 0,
      "end_offset" : 3,
      "type" : "word",
      "position" : 0
    },
    {
      "token" : "가방",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "word",
      "position" : 1
    },
    {
      "token" : "들어가",
      "start_offset" : 6,
      "end_offset" : 9,
      "type" : "word",
      "position" : 3
    }
  ]
}