RedPlug's Tory

Elasticsearch Install

ETC2019. 8. 13. 20:05

LDAP 연동 테스트용으로 설치 진행

 

1. CentOS 7 설치
- Hyper-V 로 구성

- 2세대, 설정에서 보안부팅 사용 X

- Root 계정 외 별도 계정사용(root로 Elasticsearch 실행불가)

 

2. 네트워크 설정 (고정IP)

- 계정 로그인 후 이더넷 장치 확인

[redplug@localhost ~]$ nmcli d
DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  disconnected  eth0
lo      loopback  unmanaged  --

- 고정IP 설정

[redplug@localhost ~]$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=cbcd721a-ea1b-4a62-8719-902db2585700
DEVICE=eth0
ONBOOT=yes
IPADDR=10.1.1.100 
NETMASK=255.255.255.0
GATEWAY=10.1.1.1
DNS1=10.1.1.110
DNS2=10.1.1.210

# 네트워크 재시작

systemctl restart network

 

3. Elasticsearch 설치

- Import the Elasticsearch PGP Key

[redplug@localhost ~]$ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
[redplug@localhost ~]$

- Installing from the RPM repository
레파지토리 추가

[redplug@localhost /]$ sudo vi /etc/yum.repos.d/elasticsearch.repo

[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

 

 

- Elasticsearch 설치

sudo yum install elasticsearch[redplug@localhost /]$ sudo yum install elasticsearch
Loaded plugins: fastestmirror
base                                                                                    | 3.6 kB  00:00:00
esticsearch-7.x                                                                         | 1.3 kB  00:00:00
extras                                                                                  | 3.4 kB  00:00:00
updates                                                                                 | 3.4 kB  00:00:00
(1/5): extras/7/x86_64/primary_db                                                       | 215 kB  00:00:00
(2/5): base/7/x86_64/group_gz                                                           | 166 kB  00:00:00
(3/5): base/7/x86_64/primary_db                                                         | 6.0 MB  00:00:00
(4/5): updates/7/x86_64/primary_db                                                      | 7.4 MB  00:00:00
(5/5): esticsearch-7.x/primary                                                          |  43 kB  00:00:01
Determining fastest mirrors
 * base: mirror.navercorp.com
 * extras: mirror.navercorp.com
 * updates: mirror.navercorp.com
esticsearch-7.x                                                                                        119/119
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.x86_64 0:7.3.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                     Arch                 Version                  Repository                     Size
===============================================================================================================
Installing:
 elasticsearch               x86_64               7.3.0-1                  esticsearch-7.x               271 M

Transaction Summary
===============================================================================================================
Install  1 Package

Total download size: 271 M
Installed size: 457 M
Is this ok [y/d/N]: y
Downloading packages:
elasticsearch-7.3.0-x86_64.rpm                                                          | 271 MB  00:01:14
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Creating elasticsearch group... OK
Creating elasticsearch user... OK
  Installing : elasticsearch-7.3.0-1.x86_64                                                                1/1
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch
  Verifying  : elasticsearch-7.3.0-1.x86_64                                                                1/1

Installed:
  elasticsearch.x86_64 0:7.3.0-1

Complete!

- Elasticsearch 실행

[redplug@localhost /]$ sudo systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.
[redplug@localhost /]$
[redplug@localhost /]$ sudo service elasticsearch start
Starting elasticsearch (via systemctl):                    [  OK  ]

- 실행 확인
하기와 같이 화면이 노출되면 정상적으로 실행

[redplug@localhost /]$ curl -XGET 127.0.0.1:9200
{
  "name" : "localhost.localdomain",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "KR5xkBUJRwqrBdETyAJoqg",
  "version" : {
    "number" : "7.3.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "de777fa",
    "build_date" : "2019-07-24T18:30:11.767338Z",
    "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"
}
[redplug@localhost /]$

4. 외부 접근 허용

elasticsearch.yml 파일 수정 후 서비스 재시작

[redplug@localhost /]$ sudo vi /etc/elasticsearch/elasticsearch.yml

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.

 

 

 

[redplug@localhost /]$ sudo service elasticsearch restart
Restarting elasticsearch (via systemctl):                  [  OK  ]