How to Install Elasticsearch on CentOS 7

Install Elasticsearch on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure Elasticsearch on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Elasticsearch is a flexible and powerful open source, distributed real-time search and analytics engine. With Elasticsearch, you can store, search, and analyze big volumes of data faster and in near real time. Elasticsearch is generally used as the underlying engine/technology that powers applications that have complex search features and requirements.

Install Elasticsearch on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum install epel-release
sudo yum update

Step 2. Install Java.

Java is the primary requirement for installing Elasticsearch. You can install Java by executing the following command:

sudo yum install java-1.8.0-openjdk-devel

Verify the Java installation by printing the Java version:

java -version

Step 3. Install Elasticsearch.

First, add the Elasticsearch repository:

sudo rpm --import

Next, Open your text editor and create the following repo file:

sudo nano /etc/yum.repos.d/elasticsearch.repo
name=Elasticsearch repository for 6.x packages

You can install Elasticsearch using the command below:

sudo yum install elasticsearch

Once the installation is done, you can start elasticsearch service by executing:

sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service

Step 4. Configure Elasticsearch.

You can customize this by editing the Elasticsearch configuration file. Edit configuration file in your favorite text editor and update the following values:

sudo nano /etc/elasticsearch/elasticsearch.yml

Change the following values: ES_Cluster_01 "Cluster_01_Node_001"

Restart the Elasticsearch service for the changes to take effect:

sudo systemctl restart elasticsearch

Step 5. Test Elasticsearch Setup.

You can verify that Elasticsearch is running by sending an HTTP request to port 9200 on localhost with the following curl command:

curl -X GET "localhost:9200/"

You should see something similar to this:

  "name" : "kwEp0A2Q",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "B-5B34LmailanaD3ww",
  "version" : {
    "number" : "6.6.6",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "1fbmw69",
    "build_date" : "2019-08-13T17:10:46.160291Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.8.0",
    "minimum_index_compatibility_version" : "5.1.0"
  "tagline" : "You Know, for Search"

Congratulation, you have learned how to install and configure Elasticsearch on CentOS 7. If you have any question, please leave a comment below.