Elastic Search

How to Install Elasticsearch on CentOS 8

Elasticsearch is a very popular and powerful real-time data analysis and distributed search platform. Elasticsearch is an open-source and free-to-use project developed by the Elastic company. Its scalability, ease of use, and free-to-use features allow users to use it for testing purposes for complex searching. It supports RESTful services to manipulate data by combining the HTTP methods with the HTTP URI. Let’s start with the installation of Elasticsearch on CentOS 8.

Installation of Elasticsearch on CentOS 8

Since Elasticsearch is written in Java, the first step is to have Java installed on CentOS 8 Operating system.

Step 1: Install Java on CentOS 8

Java can be installed on your CentOS 8 machine by installing the JRE(Java Runtime Environment). The OpenJDK package is available in the CentOS 8 package repository, and you can install the latest version by typing the command given below.

$ sudo dnf install java-11-openjdk-devel -y

After the installation of OpenJDK, check the installed version.

$ java --version

You can see that version 11.0.9.1 of OpenJDK is successfully installed on the CentOS 8 machine. Let’s install Elasticsearch now.

Step 2: Download and Install Elasticsearch on CentOS 8

Elastic provides all the packages to install Elasticsearch on any Operating system like deb, tar.gz, or rpm. For CentOS 8, we will definitely need the rpm package to install Elasticsearch on CentOS 8. You can visit their official website, elastic.co, to download and install the latest stable version of Elastic search on CentOS 8.

The latest and stable released version of Elasticsearch is 7.11.0 while writing this post. Download and install elastic search program using the following command:

$ sudo rpm -ivh https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-x86_64.rpm

For the future, just visit the download page of Elasticsearch, copy the link address of the RPM package, and paste it at the place of the link in the above command or you can just change the version number in the above command from 7.10.2 to the latest available version.

Once Elasticsearch is installed, the next step is to enable the elastic search.

First, reload the daemon using the command.

$ sudo systemctl daemon-reload

After reloading the daemon, enable the service of Elasticsearch.

$ sudo systemctl enable elasticsearch.service

Step 3: Configuration of Elasticsearch on CentOS 8

After the installation of Elasticsearch, if you want to configure Elastic search according to your desire, the configuration files of Elasticsearch are placed in the /etc/elasticsearch directory. For example, if you want to change the server or cluster name or configure the elastic search for remote access, all these types of configuration options are placed inside the elasticsearch.yml file.

elasticsearch.yml

For server settings and configuration, all the options are in this file.

Open up the elasticsearch.yml file in a nano text editor in the terminal.

$ sudo nano /etc/elasticsearch/elasticsearch.yml

And uncomment the lines that start from “node.name” and “cluster.name” and provide your desired names to change the name of the server and cluster, respectively.

node.name: "New Node Name"

Cluster. name: newClusterName

Similarly, if you want to configure the elastic search for remote access, uncomment the line that starts with the “network.host” if it is commented and provides the remote host’s IP address.

After all the configurations, save the file and exit using the shortcut keys (CTRL+S) and (CTRL+X).

After changing the configuration file to apply changes, we need to restart the Elasticsearch service.

$ sudo systemctl restart elasticsearch.service

Configuration of Elastic search is saved and applied successfully.

Conclusion

This is how we can install Elastic search on the CentOS 8 Operating system and configure it according to our requirements. By using Elasticsearch, we can perform a website search, application search, Application performance monitoring, Business and Security Analytics, and much more tasks. To learn more about Elasticsearch, read the getting started guide of Elasticsearch from its official website.

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.