Install and Configure Elasticsearch on AlmaLinux 8 easy steps

In this article, we want to teach you How To Install and Configure Elasticsearch on AlmaLinux 8.

Elasticsearch is an open-source full-text search and analytics engine tool used to store, search, and analyze big volumes of data in near real-time.

How To Install and Configure Elasticsearch on AlmaLinux 8

To Install and Configure Elasticsearch on AlmaLinux 8, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our article about the Initial Server Setup with AlmaLinux 8.

Now follow the steps below to install Elasticsearch.

Install Java on AlmaLinux 8

Elasticsearch needs Java installed on your server. First, update your local package index with the following command:

sudo dnf update

To install the OpenJDK package on AlmaLinux 8, run the following command:

sudo dnf install java-11-openjdk-devel

Now verify that your Java installation was successful by printing its version:

java -version

In your output you will see:

Output
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

Now you can start to install Elasticserach on AlmaLinux 8.

Set up Elasticsearch on AlmaLinux 8

As you know, the Elasticsearch package is not available in the default AlmaLinux repository.

You need to install it from the Elasticsearch RPM repository.

First, import the GPG key with the following command:

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

Then, you need to create an Elasticsearch repository file with your favorite text editor, here we use vi:

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

Add the following content to the file:

[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

When you are done, save and close the file.

Now you can use the following command to install Elasticsearch:

sudo dnf install elasticsearch

Here you need to start and enable Elasticsearch on AlmaLinux 8 with the command below:

sudo systemctl enable elasticsearch.service --now

You can verify your installation that was successful by using the curl command to send an HTTP request to port 9200 on localhost:

curl -X GET "localhost:9200/"

In your output you will see:

Output
{
"name" : "Alma.localhost",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "pUdHApeXQbmXc8dXII_L3A",
"version" : {
"number" : "7.15.2",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "93d5a7f6192e8a1a12e154a2b81bf6fa7309da0c",
"build_date" : "2021-11-04T14:04:42.515624022Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

Now that you have Elasticsearch up and running on your server, let’s see how to configure it on AlmaLinux 8.

Configure Elasticsearch

At this point, you can make some basic configuration changes.

Elasticsearch data is stored in the default directory location (/var/lib/elasticsearch). To edit the configuration files, you can find them in the directory location (/etc/elasticsearch). The Java start-up options can be configured in the (/etc/default/elasticsearch) configuration file.

If you want to set up a cluster, you need to modify the configuration file to allow remote connections.

By default, Elasticsearch listens on localhost. To change this, you need to open the configuration file with your favorite text editor, here we use vi:

sudo vi /etc/elasticsearch/elasticsearch.yml

Now find the network.host directive and uncomment it by removing the “#”.

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

When you are done, save and close the file.

To apply the changes, restart Elasticsearch on AlmaLinux 8 with the following command:

sudo systemctl restart elasticsearch

You can use the curl command to use Elasticsearch.

Here are some examples of using Elasticsearch:

To delete an index, you can use the following command, here the name of the index is “sample”:

curl -X DELETE 'http://localhost:9200/samples'

You can list all indexes with:

curl -X GET 'http://localhost:9200/_cat/indices?v'

Also, you can list all docs in the index with the command below:

curl -X GET 'http://localhost:9200/sample/_search'

Conclusion

At this point, you learn how to Install and Configure Elasticsearch on AlmaLinux 8.

We hope you enjoy it.

May these articles on the Orcacore website be useful for you:

How To Set up ElasticSearch on Centos 7.

Set up and Configure Elasticsearch on Ubuntu 20.04.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!