AMP AMP

How to install Elasticsearch on Rocky Linux 9.2

To Install Elasticsearch On Rocky Linux 9.2

Introduction:

Elasticsearch is a free, open-source, distributed search and analytics engine capable of handling large amounts of data that is used for real-time full-text searches in applications where a large amount of data needs to be analyzed. It is very popular due to its usability, powerful features, and scalability. It supports RESTful API with an HTTP URI to manipulate data. Elasticsearch is easy to use, offering features such as automatic node recovery, improved security, scalability and resiliency, automatic data balancing, and more.

Procedure Steps:

Step 1: Check the OS version by using the following command

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.2 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

Step 2: Elastic Search is a Java-based application, so Java must be installed on your server. If not installed, you can install it by running the following command

[root@Linuxhelp ~]# dnf install java-11-openjdk-devel
Last metadata expiration check: 0:02:34 ago on Tuesday 24 October 2023 08:06:34 AM.
Dependencies resolved.
======================================================================================================================
 Package                              Architecture       Version                          Repository             Size
======================================================================================================================
Installing:
 java-11-openjdk-devel                x86_64             1:11.0.21.0.9-2.el9              appstream             3.3 M
Installing dependencies:
 copy-jdk-configs                     noarch             4.0-3.el9                        appstream              27 k
 java-11-openjdk                      x86_64             1:11.0.21.0.9-2.el9              appstream             438 k
 java-11-openjdk-headless             x86_64             1:11.0.21.0.9-2.el9              appstream              40 M
 javapackages-filesystem              noarch             6.0.0-4.el9                      appstream              11 k
 lksctp-tools                         x86_64             1.0.19-2.el9                     baseos                 90 k
 lua                                  x86_64             5.4.4-3.el9                      appstream             187 k
 lua-posix                            x86_64             35.0-8.el9                       appstream             131 k
 mkfontscale                          x86_64             1.2.1-3.el9                      appstream              31 k
 ttmkfdir                             x86_64             3.0.9-65.el9                     appstream              52 k
 tzdata-java                          noarch             2023c-1.el9                      appstream             149 k
 xorg-x11-fonts-Type1                 noarch             7.5-33.el9                       appstream             499 k

Transaction Summary
======================================================================================================================
Install  12 Packages

Total download size: 45 M
Installed size: 187 M
Is this ok [y/N]: y
Downloading Packages:
(1/12): lksctp-tools-1.0.19-2.el9.x86_64.rpm                                          352 kB/s |  90 kB     00:00    
(2/12): javapackages-filesystem-6.0.0-4.el9.noarch.rpm                                 26 kB/s |  11 kB     00:00    
(3/12): copy-jdk-configs-4.0-3.el9.noarch.rpm                                         149 kB/s |  27 kB     00:00    
(4/12): lua-posix-35.0-8.el9.x86_64.rpm                                               916 kB/s | 131 kB     00:00    
(5/12): lua-5.4.4-3.el9.x86_64.rpm                                                    1.0 MB/s | 187 kB     00:00    
----------------------------------------------------------------------------------------------------------------------
Total                                                                                 7.9 MB/s |  45 MB     00:05     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: copy-jdk-configs-4.0-3.el9.noarch                                                            1/1
  Running scriptlet: java-11-openjdk-headless-1:11.0.21.0.9-2.el9.x86_64                                          1/1
  Preparing        :                                                                                              1/1
  Installing       : mkfontscale-1.2.1-3.el9.x86_64                                                              1/12
  Installing       : ttmkfdir-3.0.9-65.el9.x86_64                                                                2/12
  Installing       : xorg-x11-fonts-Type1-7.5-33.el9.noarch                                                      3/12
  Running scriptlet: xorg-x11-fonts-Type1-7.5-33.el9.noarch                                                      3/12
  Installing       : tzdata-java-2023c-1.el9.noarch                                                              4/12
  Installing       : lua-posix-35.0-8.el9.x86_64                                                                 5/12
  Verifying        : lksctp-tools-1.0.19-2.el9.x86_64                                                            1/12
  Verifying        : javapackages-filesystem-6.0.0-4.el9.noarch                                                  2/12
  Verifying        : xorg-x11-fonts-Type1-7.5-33.el9.noarch                                                      3/12
  Verifying        : copy-jdk-configs-4.0-3.el9.noarch                                                           4/12
  Verifying        : lua-5.4.4-3.el9.x86_64                                                                      5/12

Installed:
  copy-jdk-configs-4.0-3.el9.noarch                        java-11-openjdk-1:11.0.21.0.9-2.el9.x86_64                 
  java-11-openjdk-devel-1:11.0.21.0.9-2.el9.x86_64         java-11-openjdk-headless-1:11.0.21.0.9-2.el9.x86_64        
  javapackages-filesystem-6.0.0-4.el9.noarch               lksctp-tools-1.0.19-2.el9.x86_64                           
  lua-5.4.4-3.el9.x86_64                                   lua-posix-35.0-8.el9.x86_64                                
  mkfontscale-1.2.1-3.el9.x86_64                           ttmkfdir-3.0.9-65.el9.x86_64                               
  tzdata-java-2023c-1.el9.noarch                           xorg-x11-fonts-Type1-7.5-33.el9.noarch                     

Complete!

Step 3: After the installation, verify the Java version by using the following command

[root@Linuxhelp ~]# java -version
openjdk version "11.0.21" 2023-10-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.21.0.9-1) (build 11.0.21+9-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.21.0.9-1) (build 11.0.21+9-LTS, mixed mode, sharing)

Step 4: By default, Elasticsearch is not included in the Rocky Linux default repository, so we will need to create a repository for it. For that first download and import the GPG key with the following command

[root@Linuxhelp ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

Step 5: create an Elasticsearch repo by using the following command

[root@Linuxhelp ~]# vim /etc/yum.repos.d/elasticsearch.repo
Add the following lines:

[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

Step 6: With the created repository file, we can now install Elasticsearch by using the following command

[root@Linuxhelp ~]# dnf install elasticsearch
Elasticsearch repository for 7.x packages                                              24 MB/s |  54 MB     00:02    
Last metadata expiration check: 0:00:31 ago on Tuesday 24 October 2023 08:13:07 AM.
Dependencies resolved.
======================================================================================================================
 Package                      Architecture          Version                    Repository                        Size
======================================================================================================================
Installing:
 elasticsearch                x86_64                7.17.14-1                  elasticsearch-7.x                308 M

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

Total download size: 308 M
Installed size: 515 M
Is this ok [y/N]: y
Downloading Packages:
elasticsearch-7.17.14-x86_64.rpm                                                       19 MB/s | 308 MB     00:16    
----------------------------------------------------------------------------------------------------------------------
Total                                                                                  19 MB/s | 308 MB     00:16     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                              1/1
  Running scriptlet: elasticsearch-7.17.14-1.x86_64                                                               1/1
Creating elasticsearch group... OK
Creating elasticsearch user... OK

  Installing       : elasticsearch-7.17.14-1.x86_64                                                               1/1
  Running scriptlet: elasticsearch-7.17.14-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/elasticsearch.keystore

/usr/lib/tmpfiles.d/elasticsearch.conf:1: Line references path below legacy directory /var/run/, updating /var/run/elasticsearch → /run/elasticsearch; please update the tmpfiles.d/ drop-in file accordingly.

  Verifying        : elasticsearch-7.17.14-1.x86_64                                                               1/1

Installed:
  elasticsearch-7.17.14-1.x86_64                                                                                      

Complete!

Step 7: After installing Elasticsearch, edit the Elasticsearch main configuration file by using the following command

[root@Linuxhelp ~]# vi /etc/elasticsearch/elasticsearch.yml
Change the following lines:
cluster.name: Linuxhelp.com
     node.name: node-1
     path.data: /var/lib/elasticsearch
     network.host: 127.0.0.1

Step 8: Enable and Start the Elasticsearch service by using the following command.

[root@Linuxhelp ~]# systemctl enable elasticsearch
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.
[root@Linuxhelp ~]# systemctl start elasticsearch

Step 9: Check the status of the Elasticsearch service by using the following command.

[root@Linuxhelp ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
     Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; preset: disabled)
     Active: active (running) since Tue 2023-10-24 08:19:24 IST; 32s ago
       Docs: https://www.elastic.co
   Main PID: 7067 (java)
      Tasks: 70 (limit: 22877)
     Memory: 2.0G
        CPU: 1min 50.222s
     CGroup: /system.slice/elasticsearch.service
             ├─7067 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networka>
             └─7248 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Oct 24 08:18:29 Linuxhelp systemd[1]: Starting Elasticsearch...
Oct 24 08:18:43 Linuxhelp systemd-entrypoint[7067]: Oct 24, 2023 8:18:43 AM sun.util.locale.provider.LocaleProviderAd>
Oct 24 08:18:43 Linuxhelp systemd-entrypoint[7067]: WARNING: COMPAT locale provider will be removed in a future relea>
Oct 24 08:19:24 Linuxhelp systemd[1]: Started Elasticsearch.

Step 10: Verify Elasticsearch using the following command

[root@Linuxhelp ~]# curl -X GET 'http://localhost:9200'
{
  "name" : "node-1",
  "cluster_name" : "Linuxhelp.com",
  "cluster_uuid" : "-GQDdChgQL-IUo2VNS6yMQ",
  "version" : {
    "number" : "7.17.14",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "774e3bfa4d52e2834e4d9d8d669d77e4e5c1017f",
    "build_date" : "2023-10-05T22:17:33.780167078Z",
    "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"
}

With the above response, Elasticserach is working properly on port 9200

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Elasticsearch on Rocky Linux 9.2. Your feedback is much welcome.

FAQ
Q
How do I start and manage the Elasticsearch service?
A
You can use your system's service manager to start and manage the Elasticsearch service. Common commands include systemctl start elasticsearch (systemd) or service elasticsearch start (SysV init).
Q
How can I access the Elasticsearch web interface (Kibana)?
A
To access the Elasticsearch web interface (Kibana), you need to install Kibana separately and configure it to connect to your Elasticsearch instance. Configuration settings are typically found in the Kibana configuration file.
Q
What are the important Elasticsearch configurations to consider?
A
Key configurations include setting the cluster name, configuring network settings, specifying data and log paths, and defining memory settings based on your system's available resources. Security and node roles are also important considerations.
Q
How do I install Java for Elasticsearch?
A
You should install a compatible version of Java (typically OpenJDK) before installing Elasticsearch. Use your system's package manager to install it.
Q
What is Elasticsearch, and why would I want to install it?
A
Elasticsearch is a powerful, open-source search and analytics engine. You might want to install it to build a robust search and analytics solution for your data, such as log and event data analysis, full-text search, and more.