Getting Started With Elasticsearch Installation

ElasticSearch is an open-source and distributed search engine which is very much scalable and supports a good amount of enterprise Search use cases.

Introduction to Elasticsearch

ElasticSearch is an open source project, under the Apache License version 2, built on top of Lucene and Java. The source code is located on GitHub, at https://github.com/elastic/elasticsearch.

Behind the ElasticSearch product is a company named Elastic. It’s website is located at https://www.elastic.co/. Elastic is the core developers of the open source project and owns the copyright for it. Additionally, the company provides training, support and a number of commercial add-ons for ElasticSearch.

In other words, ElasticSearch is free to use but there is a company that supports its development. This company also provides services and add-ons which are not free. It’s entirely up to you whether you pay anything in conjunction with using ElasticSearch or not. If you don’t, you will still have access to the full ElasticSearch product, but if you do pay money, you’ll be able to get training, support and/or nice add-ons.

Apart from ElasticSearch, there are a number of other projects within the same ecosystem. Two of those are LogStash and Kibana. LogStash can be used to store logs from various sources in ElasticSearch. Kibana provides functionality to visualize data stored in ElasticSearch in dashboards. Together ElasticSearch, LogStash and Kibana is referred to as the “ELK stack”.

ElasticSearch Installation

Elasticsearch is a platform for distributed, RESTful search and analysis. It can scale as needed, and you can get started using it right away

ElasticSearch is a Java application built for Java 7 or higher. Therefore, the first step in setting up ElasticSearch is to ensure that you have Java installed and the JAVA_HOME environment variable correctly configured.

To check that you have a compatible version of Java installed, open up a terminal window and type java-version. The output should look something like this:

Running java -version in a console where Java 8 is installed.

$ java -version
  java version "1.8.0_25"
  Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
  Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Once you have made sure that you have Java 7 or higher installed and the Java executable in your path, ensure that you have the JAVA_HOME environment variable configured by typing echo $JAVA_HOME into your terminal. The output should look something like this:

Verifying that the JAVA_HOME environment variable is set on a computer where it indeed is set.

$ echo $JAVA_HOME

If you don’t have Java installed and/or the JAVA_HOME environment variable set up fix that prior to proceeding. Java can be downloaded from https://java.com/en/download/.

Next, with Java correctly set up, you’re ready to download and install ElasticSearch. This can be done using various package managers such as the Homebrew on OS X. However, it can also be done manually by downloading from www.elastic.co.

ElasticSearch can be downloaded from https://www.elastic.co/downloads/elasticsearch. From there, grab the ZIP package for ElasticSearch and unzip it to some suitable location on your computer.

Take a look inside the unzipped folder. You should find a few text files and some directories.

Inspecting the contents of the elasticsearch folder.

~/elasticsearch$ ls -p
  LICENSE.txt                      NOTICE.txt                      README.textile                      bin/                      config/

The “lib” directory contains the compiled JAR files that make up ElasticSearch and the “config” directory contains configuration files. For running ElasticSearch, the most interesting directory though is the “bin” directory. In there, you’ll find a shell script named “elasticsearch” and a Windows batch file named “elasticsearch.bat”. These provide the recommended ways for starting ElasticSearch on *nix and Windows environments respectively.

If you’re on Linux or OS X, execute the “bin/elasticsearch” shell script to start ElasticSearch. If you’re on Windows instead execute the “bin/elasticsearch.bat” batch file. The output should look something like this:

elasticsearch installation

As you can see from the timestamps in the console output above, it took a few seconds but ElasticSearch is now up and running. To verify this, open up a browser and make a request to http://localhost:9200. The response should be in the form of JSON, looking something like this:

Example response from ElasticSearch when making a request to it’s / endpoint.
  "status" : 200,
  "name" : "Tyger Tiger",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.5.0",
    "build_hash" : "927caff6f05403e936c20bf4529f144f0c89fd8c",
    "build_timestamp" : "2015-03-23T14:30:58Z",
    "build_snapshot" : false,
  "lucene_version" : "4.10.4"
  "tagline" : "You Know, for Search"

Given that your browser can connect to http://localhost:9200 and you see a response similar to the one above, ElasticSearch is running fine. The exact response isn’t very interesting. ElasticSearch’s “/” endpoint, which is what we’ve requested, responds with some basic information about the cluster, such as which version of ElasticSearch that it’s running.

To shut down ElasticSearch, simply press CTRL+C. To start it again execute the same command as previously used.

Marvel and Sense

Marvel is a monitoring and cluster management dashboard, enabling you to understand and visualize the health and status of your Elasticsearch infrastructure.

Marvel is a database monitoring tool that can show you how your ElasticSearch is feeling with a huge amount of meters and gauges.

You use HTTP to communicate with ElasticSearch and as such no specific tool is required. When communicating with ElasticSearch from within an application, you can use whatever HTTP libraries that are available or one of ElasticSearch’s client libraries. For “manually” communicating with ElasticSearch, which you typically do when playing with it or in order to execute ad-hoc queries, you can use any HTTP client, such as cURL, a browser or any number of “REST clients”.

However, there are a number of tools that can aid you beyond what generic HTTP clients provides. One such tool is Sense. Sense is a “JSON aware developer console to ElasticSearch” that offers auto completion and nice formatting of requests and responses.

These days Sense is shipped as a part of Marvel, a commercial plug-in for ElasticSearch. Marvel provides management and monitoring dashboards for an ElasticSearch cluster and, Sense.

While Marvel requires a paid for license for production use it’s free for development use. It is recommended to install it now as it’s a good tool to get to know and as Sense will make it more convenient to play with ElasticSearch. To do so, you can use the “bin/plugin” tool. From the ElasticSearch home directory, run bin/plugin -i elasticsearch/marvel/latest. The output should look something like this:

Installing Marvel:

To use Marvel, you need to install two components:

  • An Elasticsearch plugin that collects data from each node in your cluster. This plugin must be installed on every node.
  • A Kibana app that provides the Marvel monitoring UI.
~/elasticsearch$ bin/plugin -i elasticsearch/marvel/latest
  -> Installing elasticsearch/marvel/latest...
  Trying http://download.elasticsearch.org/elasticsearch/marvel/marvel-latest.zip...
  Downloading .........DONE
  Installed elasticsearch/marvel/latest into /Users/joelabrahamsson/elasticsearch/plugins\

Once the installation is complete, restart (or start) ElasticSearch. You can now navigate to http://localhost:9200/_plugin/marvel/ where Marvel resides.

marvel dashboard

 The default Marvel dashboard.

In order to access Sense, use the “Dashboards” drop down menu in the top right part of the Marvel and click on Sense. Alternatively, you can navigate directly to the Sense by directing your browser to http://localhost:9200/_plugin/marvel/sense/.

sense dashboard

The Sense dashboard.






0 Responses on Getting Started With Elasticsearch Installation"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.