CentOS 7 ElasticSearch 설치

Posted by Albert 802Day 18Hour 53Min 59Sec ago [2023-02-07]

간단히 centos 상 elasticsearch 설치해보았다. 

1. [kafka@localhost kafka_2.13-3.3.2]$ sudo vi /etc/yum.repos.d/elasticsearch.repo

아래 내용 추가하고 wq 

7x 버전 설치시 

[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

8x 버전 설치시 

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


2. 위 repo설정 마쳤으면 설치시작

[kafka@localhost ~]$ sudo yum install elasticsearch -y
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
elasticsearch x86_64 7.17.9-1 elasticsearch-7.x 301 M

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

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/elasticsearch.keystore
Verifying : elasticsearch-7.17.9-1.x86_64 Installed:
elasticsearch.x86_64 0:7.17.9-1

Complete!


3. 설치 완료되면 elasticsearch 외부접속설정

1. sudo vi /etc/elasticsearch/elasticsearch.yml

/9200 으로 아래 내용을 찾는다

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

'network.host: 192.168.0.1

'network.host: localhost

network.host: 0.0.0.0

'

' By default Elasticsearch listens for HTTP traffic on the first free port it

' finds starting at 9200. Set a specific HTTP port here:

'

http.port: 9200

'

' For more information, consult the network module documentation.

'

...

' --------------------------------- Discovery ----------------------------------
'
' Pass an initial list of hosts to perform discovery when this node is started:
' The default list of hosts is ["127.0.0.1", "[::1]"]
'
'discovery.seed_hosts: ["host1", "host2"]
'
' Bootstrap the cluster using an initial set of master-eligible nodes:
'
cluster.initial_master_nodes: ["node-1", "node-2"]
'
' For more information, consult the discovery and cluster formation module documentation.
'

이렇게 하여 3곳 수정하고 elasticsearch 서비스 재시작 하면 된다.

1.network.host: 0.0.0.0, 2.http.port: 9200 3.cluster.initial_master_nodes: ["node-1", "node-2"] 


서비스 실행

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

sudo systemctl enable elasticsearch 

sudo systemctl start elasticsearch

sudo systemctl status elasticsearch

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

상태 확인 시 

● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
Active: active (running) since 2023-02-07 20:54:35 KST; 19min ago
Docs: https://www.elastic.co
Main PID: 23664 (java)
Tasks: 79
CGroup: /system.slice/elasticsearch.service
├─23664 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.ne...
└─23872 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-...

active상태가 되면 정상적으로 된것임


4. curl 확인 

[kafka@localhost kafka_2.13-3.3.2]$ curl http://localhost:9200/
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "6AU70llYRXKAvp6gXzT5aQ",
"version" : {
"number" : "7.17.9",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "ef48222227ee6b9e70e502f0f0daa52435ee634d",
"build_date" : "2023-01-31T05:34:43.305517834Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}





LIST

Copyright © 2014 visionboy.me All Right Reserved.