How to Install Elasticsearch on CentOS/RHEL 9

Elasticsearch, an influential analytics and open-source search engine, enables efficient storage, rapid searching, and real-time analysis of substantial data volumes.

In this guide, we offer step-by-step instructions for installing Elasticsearch on CentOS/RHEL 9—a renowned Linux distribution celebrated for its reliability and resilience. By adhering to these steps, you can elevate your application’s search functionality and unlock valuable data insights.

Step 1:

On your your terminal, execute the following command to update your system with the latest packages:

sudo dnf update

Read: How to Install MySQL 8.0 on RHEL & CentOS Stream 9

Step 2:

Elasticsearch relies on Java, necessitating the installation of Java on your CentOS/RHEL system. To achieve this, execute the following command to install the OpenJDK package:

sudo dnf install java-11-openjdk

To check the installation, invoke the command:

java -version

Read: How to Install Java on Ubuntu

Step 3

Import the GPG Key: To ensure the integrity of Elasticsearch packages, import the GPG key using the following command:

sudo rpm –import

Create a Repository File: Next, create a new repository file by opening it with the nano text editor:
sudo nano /etc/yum.repos.d/elasticsearch.repo

Insert the following content into the file:

  • [elasticsearch]
  • name=Elasticsearch repository for 8.x packages
  • baseurl=
  • gpgcheck=1
  • gpgkey=
  • enabled=0
  • autorefresh=1
  • type=rpm-md

Now run:
sudo dnf install –enablerepo=elasticsearch elasticsearch

Step 4:

Install Elasticsearch using DNF: Execute the following command to install

Elasticsearch using the DNF package manager:

sudo dnf install –enablerepo=elasticsearch elasticsearch

Start and Enable Elasticsearch: After the installation is complete, ensure that Elasticsearch starts automatically during boot by running the following commands:

sudo systemctl start elasticsearch

sudo systemctl enable elasticsearch

Read: Red Hat Based Derivatives: A Comprehensive Guide

Step 5:

To tailor Elasticsearch to your needs, modify the configuration file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Within this file, you can adjust parameters such as,, and network settings.

Step 6:

To confirm that Elasticsearch is functioning correctly, execute the following curl command to send an HTTP request:

curl -X GET “localhost:9200/”

You should receive a response containing details such as the name, cluster name, Elasticsearch version, and other relevant information.

Step 7:

To enhance the security of your Elasticsearch cluster, consider the following fundamental steps:

  1. User Authentication Setup: Configure user authentication to control access effectively.
  2. HTTPS Configuration: Implement HTTPS to encrypt communication.
  3. Firewall Restrictions: Restrict access using firewalls.

For more advanced security configurations, consult the official Elasticsearch documentation.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.


Nikolaus Oosterhof

Nikolaus holds a degree in software development and has a strong passion for all things tech-related, especially gadgets with screens. Though he is nostalgic for older phone models, he's a retired gamer and continues to enjoy programming in open-source environments. Additionally, Nikolaus enjoys writing about Linux, macOS and Windows and has experience designing web pages.

Leave a Reply