In this guide, you will learn the Elasticsearch Installation and Configuration Setup Guide on AlmaLinux 9. Elasticsearch is an open-source analytics engine. Also, it is a highly scalable and full-text search engine. With Elasticsearch, you can store, search, and analyze big data in real-time. This tutorial will show you how to install Elasticsearch on AlmaLinux 9 step by step by using the official RPM packages. To do this, proceed to the following steps.
Steps To Elasticsearch Installation Guide on AlmaLinux 9
Before you start your Elasticsearch installation, you must log in to your server as a non-root user with sudo privileges. For this purpose, you can check the AlmaLinux 9 Initial Setup Guide.
Now follow the steps below to complete this guide.
Step 1 – Install Java For Elasticsearch Setup
Elasticsearch needs Java to run on your AlmaLinux 9. So you must install Java. First, run the system update with the following command:
sudo dnf update -y
Then, use the following command to install OpenJDK on AlmaLinux 9:
sudo dnf install java-17-openjdk-devel -y
Verify your Java installation by checking its version:
Step 2 – Download and Install Latest Elasticsearch RPM Package on AlmaLinux 9
At this point, you must visit the official website and get the latest RPM package on AlmaLinux 9. First, import the GPG key by using the following command:
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo vi /etc/yum.repos.d/elasticsearch.repo
Add the following latest RPM repo to the file:
name=Elasticsearch repository for 8.x packages
When you are done, save and close the file.
At this point, you can use the following command to install Elasticsearch on AlmaLinux 9:
sudo dnf install --enablerepo=elasticsearch elasticsearch -y
Once your installation is completed, you can verify it by using the following command:
sudo rpm -qi elasticsearch
Step 3 – Start and Enable Elasticsearch Service on AlmaLinux 9
At this point, you need to reload the system daemon and start and enable your Elasticsearch service. To do this, you can use the following commands:
# sudo systemctl daemon-reload
# sudo systemctl enable elasticsearch.service
# sudo systemctl start elasticsearch.service
Then, verify your ELasticsearch service is active and running on your server:
sudo systemctl status elasticsearch.service
Step 4 – Check Elasticsearch Listening Port
By default, the Elasticsearch service listens to port 9200. You can confirm this using the command below:
ss -pnltu | grep 9200
Step 5 – Modify Elasticsearch to Allow Remote Connections
By default, Elasticsearch data is sotred in the /var/lib/elasticsearch directory. Elasticsearch configurtaion file can be find under the /etc/elasticsearch directory. Also, the Java start-up options are avaiable in the /etc/default/elasticsearch directory.
If you want to set up a cluster, you must make some changes to Elasticsearch confoguration file and allow the remote connections on AlmaLinux 9. Open the file with your desired text ediotr:
sudo vi /etc/elasticsearch/elasticsearch.yml
At the file, find the network.host directive and uncomment it. By default, Elasticsearch listens on localhost. You can replace it with your private IP address. Or you can change it to listen to all by entering 0.0.0.0:
network.host: 0.0.0.0 or Server's IP Address
Then, find the cluster.name directive and uncomment it. Set a name for your cluster:
Next, uncomment the node.name directive and specify the name of your node:
Finally, set the xpack.security.enabled security setting to false:
When you are done, save and close the file.
Restart Elasticserach service to apply the changes on AlmaLinux 9:
sudo systemctl restart elasticsearch
Step 6 – Test Elasticsearch with HTTP Request on AlmaLinux 9
At this point, you can verify your installation that was successful by using the curl command to send an HTTP request to port 9200 on localhost or your server’s IP:
sudo curl -X GET "localhost:9200/"
Or from your web browser, you can follow:
You should see:
Here are some other examples of using Elasticsearch with curl command:
To delete an index like samples, you can run:
sudo curl -X DELETE 'http://localhost:9200/samples'
You can list all indexes with:
sudo curl -X GET 'http://localhost:9200/_cat/indices?v'
Also, you can list all docs in the index with:
sudo curl -X GET 'http://localhost:9200/sample/_search'
Elasticsearch is a powerful tool for managing and analyzing large volumes of data, especially when search and real-time analysis are critical components of your application. At this point, you have learned Elasticsearch Installation and Configuration Setup on AlmaLinux 9. Hope you enjoy it.
Also, you may like to read the follwoing articles: