Skip to content

Step-by-Step Guide to Installing Elasticsearch on CentOS/RHEL 9

Steps
7
Category
Databases
Covers
CentOS, Elasticsearch, RHEL
On this page 7 steps

Elasticsearch is a powerful open-source search and analytics engine that allows you to store, search, and analyze large volumes of data quickly and in near real time. In this article, we provide a comprehensive guide on installing Elasticsearch on CentOS/RHEL 9, a popular Linux distribution known for its stability and robustness. By following these steps, you can enhance the search capabilities of your applications and maximize data insights.

Prerequisites

Before beginning the installation, ensure you have:

  • A server running CentOS/RHEL 9.
  • Sudo privileges or access to the root user.
  • A stable internet connection.

Step 1 of 7Update Your System

Open your terminal and update your system to the latest packages using the command:

sudo dnf update

Step 2 of 7Installing Java

Elasticsearch is built using Java, so you need to install Java on your CentOS/RHEL system.

Install the OpenJDK package by running:

sudo dnf install java-11-openjdk

Verify the installation:

java -version

Step 3 of 7Add Elasticsearch Repository

Elasticsearch packages are signed with a GPG key to ensure their integrity. You need to import this key:

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

Create a new repository file:

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

Add the following content to the file:


[elasticsearch]
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=0
autorefresh=1
type=rpm-md

sudo dnf install –enablerepo=elasticsearch elasticsearch

Step 4 of 7Installing Elasticsearch

Install Elasticsearch using the dnf package manager:

sudo dnf install --enablerepo=elasticsearch elasticsearch

Once the installation is complete, start and enable Elasticsearch to run on boot:

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch

Step 5 of 7Configure Elasticsearch (Optional)

You might want to configure Elasticsearch to suit your requirements. Edit the configuration file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Here, you can set various parameters like cluster.name, node.name, and network settings.

Step 6 of 7Test the Installation

To verify that Elasticsearch is running correctly, use the curl command to send an HTTP request:

curl -X GET "localhost:9200/"

You should see a response with the name, cluster name, Elasticsearch version, and more.

Step 7 of 7Securing Elasticsearch

It’s essential to secure your Elasticsearch cluster. Some basic steps include:

  1. Setting up user authentication.
  2. Configuring HTTPS.
  3. Restricting access using firewalls.
  4. Refer to the official Elasticsearch documentation for advanced security configurations.

Conclusion

You have successfully installed Elasticsearch on your CentOS/RHEL 9 system. This setup provides a robust platform for developing powerful search and data analysis applications. Remember, maintaining and securing your Elasticsearch instance is crucial for effective and safe operations.

For more information and advanced configurations, refer to the Elasticsearch official documentation.

Happy searching!

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

1 Comment

  1. After executing below command we are getting. curl: (52) Empty reply from server
    curl -X GET “localhost:9200/”

    Kindly help me how solve this issue .

    Thanks,

    Muhammad Younus

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top