(Last Updated On: May 3, 2019)

How can I install Elasticsearch on RHEL / CentOS 8?. This guide will help you to install Elasticsearch 6 / Elasticsearch 5 on RHEL 8. Elasticsearch is an Open source full-text search and analytics engine tool used to store, search, and analyze big volumes of data in near real time.

Step 1: Install Java on RHEL 8

As Elasticsearch depends on Java, you need it installed on your system prior to installing Elasticsearch 6 or 5 on RHEL 8.

How to Install Java 11 (OpenJDK 11) on RHEL 8

How to Install Elasticsearch 7/6/5 on RHEL/CentOS 8

For Elasticsearch 7.x, add:

cat <<EOF | sudo tee /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
EOF

To install Elasticsearch 6 on RHEL 8, add its repository to your system.

cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

For Elasticsearch 5.x, add:

cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

Once the repository is added, clear and update your YUM package index.

sudo yum clean all
sudo yum makecache

Elasticsearch 6 repository is ready for use. You can install Elasticsearch using the command below:

sudo yum -y install elasticsearch

Confirm package installation.

$ rpm -qi elasticsearch 
Name : elasticsearch
Epoch : 0
Version : 7.0.1
Release : 1
Architecture: x86_64
Install Date: Fri 03 May 2019 08:25:52 PM EAT
Group : Application/Internet
Size : 571521653
License : Elastic License
Signature : RSA/SHA512, Mon 29 Apr 2019 05:14:11 PM EAT, Key ID d27d666cd88e42b4
Source RPM : elasticsearch-7.0.1-1-src.rpm
Build Date : Mon 29 Apr 2019 04:06:59 PM EAT
Build Host : packer-virtualbox-iso-1553723689
Relocations : /usr
Packager : Elasticsearch
Vendor : Elasticsearch
URL : https://www.elastic.co/
Summary : Elasticsearch is a distributed RESTful search engine built for the cloud. Reference documentation can be found at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html and the 'Elasticsearch: The Definitive Guide' book can be found at https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html
Description :
Elasticsearch subproject :distribution:packages

You can set JVM options like memory limits by editing the file: /etc/elasticsearch/jvm.options

Example below sets initial/maximum size of total heap space

-Xms1g
-Xmx1g

If your system has less memory, you can configure it to use small megabytes of ram.

-Xms256m
-Xmx512m

Start and enable elasticsearch service on boot:

$ sudo systemctl enable --now elasticsearch.service 
Synchronizing state of elasticsearch.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable elasticsearch
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.

Test to verify that it is working:

$ curl http://127.0.0.1:9200 
{
"name" : "bBzN5Kg",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "LKyqXXSvRvCpX9QAwKlP2Q",
"version" : {
"number" : "6.5.4",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "d2ef93d",
"build_date" : "2018-12-17T21:17:40.758843Z",
"build_snapshot" : false,
"lucene_version" : "7.5.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

Create a test index:

$ curl -X PUT "http://127.0.0.1:9200/mytest_index"
{"acknowledged":true,"shards_acknowledged":true,"index":"mytest_index"}

Install Kibana on RHEL / CentOS 8

If you need to install Kibana visualization tool, run the command below in your terminal.

sudo yum install kibana

After a successful installation, configure Kibana:

$ sudo vim /etc/kibana/kibana.yml
server.host: "0.0.0.0"
server.name: "kibana.example.com"
elasticsearch.url: "http://localhost:9200"

Change other settings as desired then start kibana service:

sudo systemctl enable --now kibana

Access http://ip-address:5601 to open Kibana Dashboard:

If you have an active firewall, you’ll need to allow access to Kibana port:

sudo firewall-cmd --add-port=5601/tcp --permanent
sudo firewall-cmd --reload

You now have Elasticsearch 7/6/5 on RHEL / CentOS 8. Also read:

How to delete Elasticsearch Index data with curl