How To Install Elasticsearch on CentOS/RHEL 8

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.

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 Thu 2020-07-23 11:08:38 UTC; 46s ago
     Docs: https://www.elastic.co
 Main PID: 13303 (java)
    Tasks: 63 (limit: 11491)
   Memory: 1.2G
   CGroup: /system.slice/elasticsearch.service
           ├─13303 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddres>
           └─13458 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Jul 23 11:08:07 centos8 systemd[1]: Starting Elasticsearch...
Jul 23 11:08:38 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.

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.8.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Conclusion

Congratulations! You have successfully configured Elasticsearch single node cluster on your CentOS 8 Linux system.

The post How To Install Elasticsearch on CentOS/RHEL 8 appeared first on TecAdmin.

cluster elasticsearch Linux Tutorials TecAdmin