Elasticsearch is flexible and powerful open-source, distributed real-time search and analytics engine. Using a simple set of APIs provides the ability for full-text search. Elastic search is freely available under the Apache 2 license, which provides the most flexibility.

Advertisement

Elasticsearch is used to store and search all kinds of documents. It supports full-text search completely based on the documents instead of tables and schema.

This tutorial will help you to setup Elasticsearch single node cluster on CentOS 8 and RedHat 8 systems.

Prerequisites

Java is the primary requirement for installing Elasticsearch on any system. You can check the installed version of Java by executing the following command. If it returns an error, install Java on your system using this tutorial.

sudo dnf install java-11-openjdk

After installation, check the Java version:

java -version 

openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)

Step 1 – Configure Yum Repository

The first step is to configure Elasticsearch package repository on your system. Run the following command to install GPG key for the Elasticsearch rpm packages.

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

Next, create a yum repository configuration file for the Elasticsearch. Edit /etc/yum.repos.d/elasticsearch.repo file in your favorite text editor:

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

Add below content:

[Elasticsearch-7]
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

Step 2 – Installing Elasticsearch

Your system is prepared for the Elasticsearch installation. Run the following commands to update DNF cache and install the Elasticsearch rpm packages on your system.

sudo dnf update -y
sudo dnf install elasticsearch -y

Step 3 – Configure Elasticsearch

After successful installation edit Elasticsearch configuration file “/etc/elasticsearch/elasticsearch.yml” and set the network.host to localhost. You can also change it to the system LAP IP address to make it accessible over the network.

vim /etc/elasticsearch/elasticsearch.yml

Set the following values to customize your Elasticsearch environment.

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

Save file and close.

After making configuration changes, let’s enable the Elasticsearch service and start it.

sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch

Your Elasticsearch server is up and running now. To view status of the service, run below command:

sudo systemctl status elasticsearch

Output:

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-10-21 05:28:25 UTC; 12min ago
     Docs: https://www.elastic.co
 Main PID: 99609 (java)
    Tasks: 61 (limit: 75413)
   Memory: 1.2G
   CGroup: /system.slice/elasticsearch.service
           ├─99609 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -X>
           └─99818 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Oct 21 05:28:09 centos8 systemd[1]: Starting Elasticsearch...
Oct 21 05:28:25 centos8 systemd[1]: Started Elasticsearch.

Step 4 – Test Elasticsearch

The Elasticsearch has been successfully installed and running on your CentOS 8 or RHEL 8 system. Now, you can use it for storing and searching content.

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

curl -X GET "localhost:9200/?pretty"

You will see the results like below:

{
  "name" : "centos8",
  "cluster_name" : "TecAdmin-ES-Cluster",
  "cluster_uuid" : "a0OZk1c1TEmPTlA24uT4zQ",
  "version" : {
    "number" : "7.9.2",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e",
    "build_date" : "2020-09-23T00:45:33.626720Z",
    "build_snapshot" : false,
    "lucene_version" : "8.6.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Conclusion

In this tutorial, You have learned to install and configure Elasticsearch on CentOS 8 / RHEL 8 Linux system.

Share.

4 Comments

  1. Steve Mushsero on

    Great article, though note there is no need to install Java – you can see when it’s running that it didn’t use the version you installed: /usr/share/elasticsearch/jdk/bin/java

Leave A Reply


Exit mobile version