Hamsa K
Editor
7 min read | 1 month ago

How to Install Elasticsearch on Rocky Linux 8

Install elasticsearch on Rocky Linux 8

Elasticsearch can be used to search any kind of documents.Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

In this Article,we will show you how to install ElasticSearch on Rocky Linux system

Also Read -> How to Install Apache Maven on Rocky Linux

Step 1: Install Java

Before installing elasticsearch, we need to install Java.

sudo dnf install java-11-openjdk-devel

Now you can verify java version

java -version

output:

openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

Also Read -> How to Install PostgreSQL on Rocky Linux

Step 2: Install Elasticsearch

we need to import ElasticSearch GPG key with below command.

sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

now create elasticsearch repo

sudo vi /etc/yum.repos.d/elasticsearch.repo

Add below lines to above file

[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

save and exit the file.Next, install elasticsearch using dnf

sudo dnf install elasticsearch

sample output:

Elasticsearch repository for 7.x packages                                                                                               1.8 MB/s |  34 MB     00:18
Last metadata expiration check: 0:01:54 ago on Tue 19 Oct 2021 07:55:04 PM IST.
Dependencies resolved.
========================================================================================================================================================================
 Package                                   Architecture                       Version                               Repository                                     Size
========================================================================================================================================================================
Installing:
 elasticsearch                             x86_64                             7.15.1-1                              elasticsearch-7.x                             325 M
Transaction Summary
========================================================================================================================================================================
Install  1 Package
Total download size: 325 M
Installed size: 524 M
Is this ok [y/N]: y

Also Read -> How to Install Docker and Docker Compose on Rocky Linux

once it is installed,we need to configure elasticsearch.

Step 3: configure Elasticsearch

now edit configuration file elasticsearch.yml

vi /etc/elasticsearch/elasticsearch.yml

find below lines and uncomment and change as below

cluster.name: lampblogs-cluster
node.name: node-1
path.data: /var/lib/elasticsearch
network.host: 127.0.0.1

save the file and exit.

Now start and enable elasticsearch service with following commands.

sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
sudo systemctl status elasticsearch

Note: we got below error while start the service.

systemd[1]: elasticsearch.service: start operation timed out. Terminating.
systemd[1]: elasticsearch.service: Failed with result 'timeout'.
systemd[1]: Failed to start Elasticsearch.

then follow below steps to resolve the timeout error.

sudo mkdir /etc/systemd/system/elasticsearch.service.d
##### define TimeoutStartSecoption to increase startup timeout.####
echo -e "[Service]\nTimeoutStartSec=180" | sudo tee /etc/systemd/system/elasticsearch.service.d/startup-timeout.conf
#######Reload systemd manager configuration and start service ######
sudo systemctl daemon-reload
sudo systemctl start elasticsearch

The service startup timeout was not triggered as it was increased from 90secs to 3mins.then service is started and running fine.

output:

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/elasticsearch.service.d
           └─startup-timeout.conf
   Active: active (running) since Tue 2021-10-19 20:37:09 IST; 3min 0s ago
     Docs: https://www.elastic.co
 Main PID: 42149 (java)
    Tasks: 59 (limit: 7596)
   Memory: 912.6M
   CGroup: /system.slice/elasticsearch.service

Also Read -> How to Install NodeJS and NPM on Rocky Linux 8

Step 4: Verify Elasticsearch

you can verify ElasticSearch with the following command.

curl -X GET "localhost:9200/"

output:

{
  "name" : "node-1",
  "cluster_name" : "lampblogs-cluster",
  "cluster_uuid" : "dgIpDyzgS_aQaau15JMN3Q",
  "version" : {
    "number" : "7.15.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "83c34f456ae29d60e94d886e455e6a3409bba9ed",
    "build_date" : "2021-10-07T21:56:19.031608185Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

That's it. Now you have successfully installed elasticsearch on Rocky Linux 8.

Also Read -> How to Install PgAdmin 4 on Rocky Linux 8



Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy