Install and Configure Elasticsearch in Ubuntu -14.04

Elasticsearch is an open source search engine that uses Apache Lucene as its engine and released under an Apache license. Elastic search provides a platform for distributed search and analysis of data in real time. Elasticsearch is the most popular for its ease of use, powerful features. Using elastic search you can easily search, explore and analyze your data with an HTTP web interface.


Some of the general features of Elasticsearch are as follows:

  • Elasticsearch is scalable up to hundreds of servers and petabytes of structured and unstructured data.
  • Elasticsearch can be used as a replacement of MongoDB and RavenDB document store.
  • Elasticsearch is a real-time distributed search and analytics engine.
  • Elasticsearch is available under the Apache license version 2.0 and one of the most popular enterprise search engines. Many big organizations like StakOverflow and GitHub uses Elasticsearch.

In this tutorial, we will learn how to install and setup Elasticsearch on Ubuntu-14.04.


  • Ubuntu-14.04 installed on your system
  • A non-root user account with sudo privilege sets up on your system

Getting Started

Let’s start making sure that your Ubuntu-14.04 server is fully up to date. You can update your server by running the following command:

$ sudo apt-get update -y
$ sudo apt-get upgrade -y

Installing Java

Before installing Elasticsearch, you will need to install Java on your system. You can install Oracle JDK 8 using `Webupd8 team PPA` repository.

To add the webupd8team PPA repository, run the following command:

$ sudo add-apt-repository -y ppa:webupd8team/java

You should see the following output:

gpg: keyring `/tmp/tmpkjrm4mnm/secring.gpg' created
gpg: keyring `/tmp/tmpkjrm4mnm/pubring.gpg' created
gpg: requesting key EEA14886 from hkp server
gpg: /tmp/tmpkjrm4mnm/trustdb.gpg: trustdb created
gpg: key EEA14886: public key "Launchpad VLC" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

Next, update the metadata of the new repository by running the following command:

$ sudo apt-get update

Once you have finished, run the following command to install JDK 8:

$ sudo apt-get install oracle-java8-installer -y

You can also verify that JDK 8 is installed properly by running the following command:

$ sudo java -version

You should see the output something like this:

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Installing ElasticSearch

You can download Elasticsearch directly from site. For Ubuntu, you will need to download deb (Debian) package to install Elasticsearch.

To download Elasticsearch deb package run the following command:

$ sudo wget

When it’s downloaded, you can install it by running the following command:

$ sudo dpkg -i elasticsearch-2.3.5.deb

Now, start the Elasticsearch service and enable it to start at boot up by running the following command:

$ sudo /etc/init.d/elasticsearch start
$ sudo update-rc.d elasticsearch defaults

You should see the following output:

Adding system startup for /etc/init.d/elasticsearch ...
/etc/rc0.d/K20elasticsearch -> ../init.d/elasticsearch
/etc/rc1.d/K20elasticsearch -> ../init.d/elasticsearch
/etc/rc6.d/K20elasticsearch -> ../init.d/elasticsearch
/etc/rc2.d/S20elasticsearch -> ../init.d/elasticsearch
/etc/rc3.d/S20elasticsearch -> ../init.d/elasticsearch
/etc/rc4.d/S20elasticsearch -> ../init.d/elasticsearch
/etc/rc5.d/S20elasticsearch -> ../init.d/elasticsearch

You can see elastic search service status any time by running the following command:

$ sudo service elasticsearch status

Configuring Elasticsearch

You can configure Elasticsearch by editing it’s configuration file located at /etc/elasticsearch/ directory as per your requirement.

$ sudo nano /etc/elasticsearch/elasticsearch.yml

Find the line and replace it with localhost

Once you are finished with editing the file, save and close it. Then restart Elasticsearch:

$ sudo /etc/init.d/elasticsearch restart

Testing Elasticsearch

Now Elasticsearch and its dependencies have been installed, it is time to test Elasticsearch. By default, Elasticsearch should be running on port 9200.

You can test Elasticsearch by running the following curl command:

$ curl -X GET http://localhost:9200

You should see the following output:

   "name" : "Hussar",
   "cluster_name" : "elasticsearch",
   "version" : {
      "number" : "2.3.5",
      "build_hash" : "90f439ff60a3c0f497f91663701e64ccd01edbb4",
      "build_timestamp" : "2016-07-27T10:36:52Z",
      "build_snapshot" : false,
      "lucene_version" : "5.5.0"
   "tagline" : "You Know, for Search"

You can also get the health status of Elasticsearch Cluster by running the following command:

$ curl -XGET http://localhost:9200/_cluster/health?pretty=true


   "cluster_name" : "elasticsearch",
   "status" : "green",
   "timed_out" : false,
   "number_of_nodes" : 1,
   "number_of_data_nodes" : 1,
   "active_primary_shards" : 0,
   "active_shards" : 0,
   "relocating_shards" : 0,
   "initializing_shards" : 0,
   "unassigned_shards" : 0,
   "delayed_unassigned_shards" : 0,
   "number_of_pending_tasks" : 0,
   "number_of_in_flight_fetch" : 0,
   "task_max_waiting_in_queue_millis" : 0,
   "active_shards_percent_as_number" : 100.0

Hope you have learnt an important insight into this!!

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know