Hamsa K
7 min read | 6 months ago

How to install Elasticsearch on centos 7

Install Elasticsearch in Centos and fedora

Elasticsearch is one of the most popular search engines powering applications that have complex search requirements such as big e-commerce stores and analytic applications.Elastic search is freely available under the Apache 2 license, which provides the most flexibility.


Java is the Basic requirement for installing Elasticsearch on any system.If your system don't have java installed then install lasest version by following our tutorial. You can check the installed version of Java by following command.

[root@lampblogs ~]# java -version
openjdk version "1.8.0_161"

Installing Elasticsearch

you can download the latest Elasticsearch  from its official download url

[root@lampblogs ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-x86_64.rpm

In this article i have added following repo as elasticsearch.repo

[root@lampblogs ~]# vi /etc/yum.repos.d/elasticsearch.repo
name=Elasticsearch repository for 6.x packages

Once the repository is added, clear and update your YUM package index

[root@lampblogs ~]# yum clean all

Now you can install Elasticsearch using the command below 

[root@lampblogs ~]# yum install elasticsearch
# if you downloaded rpm package from official download url then follow below #
[root@lampblogs ~]# yum localinstall elasticsearch-7.2.0-x86_64.rpm

configure Elasticsearch

Edit elasticsearch.yml file

[root@lampblogs ~]# vi /etc/elasticsearch/elasticsearch.yml

Replace lamp_Cluster1 with your Elasticsearch cluster name

cluster.name: lamp_Cluster1

nodename is like a hostname for the Elasticsearch server, dynamically generated during the service startup. You can set the Node name by updating the below line. Replace myfirstnode with your Elasticsearch node name.

node.name: myfirstnode

Elasticsearch binds to localhost ( and listens on port number 9200 for HTTP traffic by default.Replace network host with your system ip or localhost.

# Listening on particular IPv4 #
# Set a custom port for HTTP:
http.port: 9200

Once the installation process is complete, start and enable the service.

[root@lampblogs ~]# sudo systemctl daemon-reload
[root@lampblogs ~]# sudo systemctl start elasticsearch.service
[root@lampblogs ~]# sudo systemctl enable elasticsearch.service

Check if Elasticsearch is listening on port 9200

[root@lampblogs ~]# netstat -antp | grep 9200
tcp        0      0        TIME_WAIT   -                   
tcp6       0      0        :::*                    LISTEN      2054/java  

Test Elasticsearch in browser using

or run curl -X GET '' in server.

  "name" : "myfirstnode",
  "cluster_name" : "lamp_Cluster1",
  "cluster_uuid" : "AU0sEbACSz2QjaNBel2irQ",
  "version" : {
    "number" : "6.8.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "1fad4e1",
    "build_date" : "2019-06-18T13:16:52.517138Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  "tagline" : "You Know, for Search"

Now Elasticsearch is sucessfully installed and working fine.

Below are few examples to add,search data in Elasticsearch cluster.

Use the following curl command to add data on to our Elasticsearch.

curl -XPUT '' -H 'Content-Type: application/json' -d '
    "Title" : "Install Elasticsearch On CENTOS 7", 
    "Date"  : "June 2019", 
    "Tag"   : "CENTOS"

you should get the following response with “result” as ”created”


Use the following command to query/read data on Elasticsearch.

curl -X GET ''
  "_index" : "lampblogs",
  "_type" : "howtos",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "Title" : "Install Elasticsearch On CENTOS 7",
    "Date" : "June 2019",
    "Tag" : "CENTOS"

Use the following command to delete the document.

curl -X DELETE ''

Response will look like below. If the document is found you will get “result” as' deleted'.


Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy