How to install Elasticsearch

How To Install Elasticsearch On CentOS 8

On this article we are going to learn how to install Elasticsearch version 7.8.1 on CentOS 8 operating system.

Introduction

Elasticsearch is an open source search and analytic engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and RESTful operations. Elasticsearch enable us to store, search, and analyze big volumes of data in real-time and the most popular enterprise search engine. Elasticsearch is developed in Java. Following an open-core business model, parts of the software are licensed under various open-source licenses (mostly the Apache License).

Elasticsearch 7.8 New features

The last stable version of Elasticsearch when the article is being written is version 7.8.1 which was released on July 28, 2020. Here are the new features on new release as found on Elasticsearch official web page :

  • Geo improvements
  • Add support for t-test aggregations
  • Expose aggregation usage in feature usage API
  • Support value_count and avg aggregations over histogram fields
  • Reduce aggregation memory consumption
  • Scalar functions now supported in SQL aggregations
  • Increase the performance and scalability of transforms with throttling
  • Better estimates for machine learning model memory usage
  • Additional loss functions for regression
  • Extended upload limit and explanations for Data Visualizer
  • Fixed out-of-memory error when using cross-cluster replication with large documents

Elasticsearch Installation On CentOS 8

After all prerequisite was met and the repository was setup, then we proceed to install. For this purpose we will exexere are several step for installing Elasticsearch on CentOS 8 operating system.

Prerequisite

Before we are going to install Elasticsearch on CentOS 8, we have to check the prerequisite of our system. We need the root or account with sudo privilege. Elasticsearch is built using Java, The bundled OpenJDK is located within the JDK directory of the Elasticsearch home directory /usr/share/elasticsearch. If we want to use our own version of Java, install the LTS version of Java and set the JAVA_HOME environment variable on our system.

The Java installation on CentOS 8 has been discussing on this article. Verify the java version on our system by submitting command line below.

[ramans@otodiginet ~]$ 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)
openJDK11

Setting Elasticsearch Repository

  1. Import the repository’s GPG to our system, by submitting command line below.
[ramans@otodiginet ~]$ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

2. Create the repository file at the /etc/yum.repos.d directory called as elasticsearch.repofile.

[ramans@otodiginet ~]$ sudo vi /etc/yum.repos.d/elasticsearch.repo

There are two source we can use as our Elasticsearch reposity : Free version and open source version. At this tutorial we will use the free version. Add the following text to the elasticsearch.repo 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
EOF

But if we want to use the Open source repository version, add the following text on the elasticsearch.repo file.

[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

Elasticsearch Installation

After all the prerequisite was met and the repository settubg was completed done, the next step is to install the Elasticsearch. This step is done by executing command line below.

[ramans@otodiginet ~]$ sudo dnf install elasticsearch
sudo dnf install ealsticsearch

Once the installation was completed done, then we start and enable the Elasticsearch daemon by submitting command line below.

sudo systemctl enable elasticsearch.service --now

The next step is verifying if Elasticsearch is running, we will use curl to send an HTTP request to port 9200 on localhost:

[ramans@otodiginet ~]$ curl -X GET "localhost:9200/"

the output will be :

{
"name" : "otodiginet",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "-6vJhmt3StSS0Vf2ZcfLaQ",
"version" : {
"number" : "7.8.1",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "b5ca9c58fb664ca8bf9e4057fc229b3396bf3a89",
"build_date" : "2020-07-21T16:40:44.668009Z",
"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"
}
elasticsearch_localhost_response

Configuring Elasticsearch

The configuration files of Elasticsearch are located in /etc/elasticsearch with elasticsearch.yml as the main configuration file, while the Elasticsearch data is stored in the /var/lib/elasticsearch directory. Elasticsearch is configured to listen only on localhost, by default. If the client need to connect to the database which is running on the same host on a single node cluster, we don’t need to change the default configuration file.

As an example we will modify the Elasticsearch name and clustername by editing the /etc/elasticsearch/elasticsearch.yml file. We wll modify the cluster name and node name on our Elasticsearch environment.

---------------------------------- Cluster -----------------------------------
#
Use a descriptive name for your cluster:
#
cluster.name: otodiginet-cluster
#
------------------------------------ Node ------------------------------------
#
Use a descriptive name for the node:
#
node.name: otodiginet-node1

To take effectm we have to submit the command line .

ramans@otodiginet ~]$ sudo systemctl restart elasticsearch

we will get the new Elasticsearch environment like this.

Elastic Node view from browser

We also could change other parameters on this file.

Remote Access

By default Elasticsearch can be accessed by anyone who can access the HTTP API, because it does not implement authentication. We have to configure the firewall on Elasticsearch server If we want to allow remote access to our Elasticsearch server via port 9200 only from trusted clients.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *