×


Install ElasticSearch on AlmaLinux 8 - Step by step guide ?

A key component of the Elastic Stack groups of software components is Elasticsearch. Elasticsearch is a opensource, fast and scalable , distributed search and analytics engine. It is Developed in Java and allows you to store, index, analyze and search massive volumes of data in near real-time speed. You can store and retrieve data in JSON format using REST APIs.

Over the course of time, Elasticsearch has become a popular search engine in fields such as log analytics, business analytics, security intelligence as well as full-text search.

Notable bluechip companies that leverage Elasticsearch in their tech stacks include Uber, Udemy, Shopify, Netflix, Facebook and many more.

Here at Ibmi Media, we shall look into the complete installation procedure of ElasticSearch on AlmaLinux 8.


Steps to install ElasticSearch on AlmaLinux

1. Install Java Package

ElasticSearch was built on Java and therefore you need to install Java on your system with the below command:

$ sudo dnf install java-11-openjdk

After installation of Java, you can confirm it by running the below command:

$ java —version


2. Import Elastic search GPG key

Next, we need to import the GPG key for the Elasticsearch rpm packages with the below command:

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


3. Install Elasticsearch on the system

Here, you need to create a file called elasticsearch.repo in the /etc/yum.repos.d/:

$ sudo vim /etc/yum.repos.d/elasticsearch.repo

Then, Paste the lines below to the file:

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

Next, install elastic search with the below command:

$ sudo dnf install --enablerepo=elasticsearch -y elasticsearch

The Elasticsearch service is disabled by default. Run the following systemctl command to start and enable the elastic search service:

$ sudo systemctl enable elasticsearch.service --now

Check the status of the service with the command:

$ sudo systemctl status elasticsearch


How to configure ElasticSearch ?

After a successful installation, edit the Elasticsearch configuration file. The default configuration settings are okay for single operating servers as Elasticsearch runs on localhost only. However, If you want to set up a cluster, you'll have to change the configuration file to allow remote connections.

Here, we have specified the address 0.0.0. 0. This allows Elasticsearch to listen on all interfaces. If you wish to specify a specific IP address, do so in this section:

$ sudo nano /etc/elasticsearch/elasticsearch.yml

For the changes to take effect, run the command:

$ sudo systemctl restart elasticsearch


How to test ElasticSearch installation ?

To confirm that Elasticsearch is up and running on our system, run the following curl command. Elasticsearch listens on port 9200 by default:

$ curl -X GET "localhost:9200/"


What operations can we use elastic search for ?

You can add data to ElasticSearch, you can use the curl command together with a POST request:

$ curl -H 'Content-Type: application/json' -X POST 'http://localhost:9200/employee/task/1' -d '{ "name": "Update John" }'

Next, let's retrieve that data using a GET request:

$ curl -X GET 'http://localhost:9200/employee/task/1'

You can retrieve the data in a in human-readable format:

$ curl -X GET 'http://localhost:9200/employee/task/1?pretty'


[Need help in fixing Linux system issues ? We can help you. ]


Conclusion

This article covers how to install the Elasticsearch on your AlmaLinux 8 system. In fact, Elasticsearch is a highly scalable open-source full-text search and analytics engine. It is generally the underlying engine/technology that powers applications with complex search features and requirements. The software supports RESTful operations that allow you to store, search, and analyze significant volumes of data quickly and in near real-time.