How to install Elasticsearch on CentOS 7

I. What is Elasticsearch?

Elasticsearch is a search engine based on Lucene software. It provides a full-featured, distributed search engine with an HTTP web interface that supports JSON data. Elasticsearch is developed in Java and is released as open source under the Apache license.

To put it more simply:

  • Elasticsearch is one  search engine.
  • Elasticsearch inherited from Lucene Apache
  • Elasticsearch actually acts as a web server, capable of fast search (near realtime) through RESTful protocol.
  • Elasticsearch Capable of data analysis and statistics
  • Elasticsearch runs on its own server and concurrently communicates via RESTful so it doesn’t depend on what the client is written in or what your current system is written in. So integrating it into your system is easy, you just need to send an http request and it will return results.
  • Elasticsearch It is a distributed system with excellent scalability. Add a node to it and it will automatically expand for you.
  • Elasticsearch is 1  open source developed with  Java.

II. Install Elasticsearch on CentOS 7

To install Elasticsearch on CentOS 7 we need to follow the following X steps.

Step 1: SSH into your server

To install Elasticsearch on CentOS 7, we first need to SSH or access your VPS or server with  root privileges  first.

After successfully SSHing, we continue with step 2 to install Java, because Elasticsearch requires the server to install Java first to allow the installation.

Step 2: Install Java 8 on CentOS 7

Because Elasticsearch only requires Java 8 version, I will guide you to install Java 8 version with the command below.

yum -y install java-1.8.0-openjdk.x86_64

After installing Java, you can check again with the following command.

java -version

If the results are returned as below, you have successfully installed Java 8.

java check version

Step 3: Install Elasticsearch on CentOS 7

The process of installing Elasticsearch is also relatively simple, you just need to follow the commands below, and of course I will explain each command clearly for your peace of mind.

First we will need to download the Elasticsearch installation file with the format .rpm:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-x86_64.rpm

This file is about 300MB in size, so it may take some time to download.

how-to-install-cai-dat-elasticsearch-tren-centos-7

Download the Elasticsearch installation file.

Then we install Elasticsearch with the downloaded file with the following command:

rpm -ivh elasticsearch-7.8.0-x86_64.rpm
how-to-install-cai-dat-elasticsearch-tren-centos-7
Install the Elasticsearch installation file.

We then need to restart the service daemon-reloadby activating the following command:

systemctl daemon-reload

We then start Elasticsearch with the following command:

systemctl start elasticsearch

And after Elasticsearch has finished starting, we can check the operating status of Elasticsearch with the following command:

systemctl status elasticsearch.service
how-to-install-cai-dat-elasticsearch-tren-centos-7
Install Elasticsearch on CentOS 7 successfully.

So far you can verify that Elasticsearch is running by sending an HTTP request to port 9200 on localhost with the curlfollowing command:

curl -X GET "localhost:9200/"

If the results are returned like the following, then you are successful:

how-to-install-cai-dat-elasticsearch-tren-centos-7

Step 4: Enable Remote Access Elasticsearch

However, so far we can only use Elasticsearch right on the local computer. If you want external users to connect to port 9200 then you need to open port 9200 and do a few more steps.

Edit the configuration file of Elasticsearch with the command below:

vi /etc/elasticsearch/elasticsearch.yml

Move to the line 55, remove #this line and edit it to the content below:

network.host: 0.0.0.0
how-to-install-cai-dat-elasticsearch-tren-centos-7

Then remove #the line 72and edit it to the following content:

cluster.initial_master_nodes: node-1

We will then need to restart Elasticsearch with the following command:

systemctl start elasticsearch

That’s it, now you can completely connect to your server remotely via port 9200 as shown below.

how-to-install-cai-dat-elasticsearch-tren-centos-7

At this point, the installation of Elasticsearch on CentOS 7 has been successful.

III. Summary

Although the article on installing Elasticsearch on CentOS 7 is relatively long and has many complicated sections, I hope you can do it all. You can now visit the official Elasticsearch Documentation page and learn how to get started with Elasticsearch.


Support 24/24h with coupon code: 1DOLLAROFF 10% discount. Click now! 👆
On this page