How to Install 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.

Installing Java

As Elasticsearch depends on Java and it has to be installed on system by using following command.

dnf install java-11-openjdk-devel

Verify the Java installation by following command.

java -version

Output:

[[email protected] ~]# java -version
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)

Installing Elasticsearch

Run the following command to install GPG key for the Elasticsearch rpm packages.

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

Next, create a yum repository file for the Elasticsearch.

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

Add the following content.

[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

Save and exit,

After the repository is enabled, install the Elasticsearch package by using.

dnf install elasticsearch

Output:

[[email protected] ~]# nano /etc/yum.repos.d/elasticsearch.repo
[[email protected] ~]# dnf install elasticsearch
Elasticsearch repository for 7.x packages        31 MB/s |  25 MB     00:00
Last metadata expiration check: 0:00:09 ago on Mon 31 May 2021 02:45:32 PM EDT.
Dependencies resolved.
================================================================================
 Package             Architecture Version         Repository               Size
================================================================================
Installing:
 elasticsearch       x86_64       7.13.0-1        elasticsearch-7.x       312 M

Configure Elasticsearch

After installation is completed, edit Elasticsearch configuration file “/etc/elasticsearch/elasticsearch.yml” and set the network.host to localhost.

vim /etc/elasticsearch/elasticsearch.yml

Add the following content,

cluster.name: Crowncloud-Cluster
node.name: node-1
path.data: /var/lib/elasticsearch
network.host: 127.0.0.1

Save and exit,

Now enable and start the Elasticsearch service.

systemctl enable elasticsearch

systemctl start elasticsearch

Check the status of the service by using following command.

systemctl status elasticsearch

Output:

[[email protected] ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vend>
   Active: active (running) since Mon 2021-05-31 14:52:08 EDT; 4s ago
     Docs: https://www.elastic.co
 Main PID: 21851 (java)
    Tasks: 65 (limit: 11435)
   Memory: 1.1G
   CGroup: /system.slice/elasticsearch.service
           ├─21851 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.netw>
           └─22048 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x8>

Testing Elasticsearch

Run the following command to view the Elasticsearch server configuration and version details.

curl -X GET "localhost:9200/"

Output:

[[email protected] ~]# curl -X GET "localhost:9200/"
{
  "name" : "node-1",
  "cluster_name" : "Crowncloud-Cluster",
  "cluster_uuid" : "5uoMXvd4SbCe2TETVNymUw",
  "version" : {
    "number" : "7.13.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "5ca8591c6fcdb1260ce95b08a8e023559635c6f3",
    "build_date" : "2021-05-19T22:22:26.081971330Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}