Analytics Engines: Elasticsearch 5.4 on Ubuntu 16.04

elasticsearch analytics engine logo

Elasticsearch – A Distributed Analytics Engine

Elasticsearch is an open-source, highly scalable, full-text search and analytics engine. It is part of a full stack called Elastic Stack. It allows you to store and analyze data, even in big volumes, with near real time performances. This powerful analytics engine supports RESTful operations, so it is possible to use all the HTTP methods in combination with HTTP URIs for data management. Another advantage is the option to use different programming languages with Elasticsearch, such as Python or JavaScript.

An online web store is a great example of a project that could benefit from Elasticsearch. It is possible to use Elasticsearch to store the entire product catalog and inventory, providing ‘search’ and ‘autocomplete suggestions’ functionalities.

Elastisearch’s great scalability also permits it to run on a laptop or on a cluster of servers with petabytes of data.

Goals

In this tutorial we will see how to install Elasticsearch on a server running Ubuntu 16.04.

Prerequisites

  • One server running Ubuntu 16.04.
  • Oracle JDK 8 installed on the server.

Install Elastisearch

Elasticsearch is provided in different formats:

.zip

,

.tar.gz

,

.deb

,

.rpm

,

docker

. In this guide we will utilize the

.deb

package.

Import Elasticsearch Key

Download and install the Elasticsearch public signing key by executing the following command:

$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Install Elasticsearch from the Repository

Before proceeding with the installation process, we’ll need to install the

apt-transport-https

package:

$ sudo apt-get install apt-transport-https

Next, we’ll save the repository definition with the following command:

$ echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list

Install Elasticsearch with

apt

:

$ sudo apt-get update && sudo apt-get install elasticsearch

Enable Elasticsearch for starting at boot time:

$ sudo systemctl enable elasticsearch

Configure Elasticsearch

Elasticsearch configuration files are store in the

/etc/elasticsearch

directory. In particular, the main configuration files are:

  • elasticsearch.yml

    for configuring the server side part of this powerful analytics engine.

  • log4j2.properties

    for configuring logging.

Configuration files use the YAML format.

Elasticsearch requires very little configuration, however there are a number of settings which should be configured before launching into use.

Open the

elasticsearch.yml

configuration file with a text editor:

$ sudo vim /etc/elasticsearch/elasticsearch.yml

Here, search for

cluster.name

variables.

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#

Uncomment the bolded line and change

my-application

with a cluster name, for example:

cluster.name: MyCluster

Note: a node can join a cluster when it shares its cluster.name with all the other nodes of the cluster. Be sure that

cluster.name

describes the cluster’s purpose.

Next, change the

node.name

variable. As above, uncomment the line and change its value:

# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#

These are the minimum settings required for running Elasticsearch. Of course, there are more details to work out in order to deploy this system on a cluster of servers.

Save and close the file, then start Elasticsearch:

$ sudo systemctl start elasticsearch

Testing Elasticsearch

We can test Elasticsearch by executing the following command:

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

It should display something like this:

{
 "name" : "node-1",
 "cluster_name" : "MyCluster",
 "cluster_uuid" : "WqXLC-cUT5-bSVyisNRIgQ",
 "version" : {
 "number" : "5.4.1",
 "build_hash" : "2cfe0df",
 "build_date" : "2017-05-29T16:05:51.443Z",
 "build_snapshot" : false,
 "lucene_version" : "6.5.1"
 },
 "tagline" : "You Know, for Search"
}

This means that Elasticsearch is running correctly.

Conclusion

This concludes the basic Elasticsearch configuration. Look how easy it can be to install this analytics engine on an Ubuntu 16.04 server!