Elasticsearch Installation and Configuration on Ubuntu 14.04


preview imageInformation Technology
by Lovish Sharma,May 7, 2018, 11:55:02 AM | 4 minutes |

Introduction

Elasticsearch is a platform for distributed search and analysis of data in real

time. Its popularity is due to its ease of use, powerful features, and scalability.

Prerequisites

Ubuntu 14.04

Step 1 - Installing Java

First, you will need a Java Runtime Environment (JRE) on your Droplet because Elasticsearch is written in the Java programming language. Elasticsearch requires Java 7 or higher

Before installing Java with APT, update the list of available packages for installation on your Ubuntu Droplet by running the command:

sudo apt-get update

After that, you can install Java with the command:

sudo apt-get install openjdk-7-jre

To verify your JAVA is installed and can be used, run the command:

java -version

The result should look like similar to this:

java version "1.7.0_79"

OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)

OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

For better Java performance and compatibility with ES need to install Oracle's proprietary Java (Oracle JDK 8).

Add the Oracle Java PPA to apt:

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

Update your apt package database:

sudo apt-get update

Install the latest stable version of Oracle Java 8 with this command (and accept the license agreement that pops up):

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

Lastly, verify it is installed:

java -version

The result should look like similar to this:

java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Step 2 — Downloading and Installing Elasticsearch

Elasticsearch can be downloaded directly from elastic.co in zip, tar.gz, deb, or rpm packages. For Ubuntu, we will use the deb (Debian) package which will install everything you need to run Elasticsearch.

Download it in a directory of your choosing with the command:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch- 6.2.4.deb

Then install it in the usual Ubuntu way with the dpkg command like this:

sudo dpkg -i elasticsearch-6.2.4.deb

This results in Elasticsearch being installed in /usr/share/elasticsearch/ with its configuration files placed in /etc/elasticsearch and its init script added in /etc/init.d/elasticsearch.

To make sure Elasticsearch starts and stops automatically with the Ubuntu, add

its init script to the default runlevels with the command:

sudo update-rc.d elasticsearch defaults

Step 3 — Configuring Elastic

Now that Elasticsearch and its Java dependencies have been installed, it is time to configure Elasticsearch.

The Elasticsearch configuration files are in the /etc/elasticsearch directory. There are two files:

elasticsearch.yml — Configures the Elasticsearch server settings. This is where all options, except those for logging, are stored, which is why we are mostly interested in this file.

logging.yml — Provides configuration for logging. You can leave all default logging options. You can find the resulting logs in /var/log/elasticsearch by default.

The first variables to customize on any Elasticsearch server are node.name and cluster.name in elasticsearch.yml. As their names suggest, node.name specifies the name of the server (node) and the cluster to which the latter is associated.

If you don't customize these variable, a node.name will be assigned automatically in respect to the Droplet hostname. The cluster.name will be automatically set to the name of the default cluster.

To edit main elasticsearch.yml configuration file use below command:

sudo vi /etc/elasticsearch/elasticsearch.yml

Remove the # character at the beginning of the lines for node.name and cluster.name to uncomment them, and then change their values.

node.name: es-node

cluster.name: es-search

One setting which you might be interested in changing is path.data, which determines the path where data is stored. The default path is /var/lib/elasticsearch. We will be using default path as of.

Once you make all the changes, please save and exit the file. Now you can start Elasticsearch for the first time with the command:

sudo service elasticsearch start

Please allow at least 10 seconds for Elasticsearch to fully start before you are

able to use it. Otherwise, you may get errors about not being able to connect.

Step 4 — Testing

By now, Elasticsearch should be running on port 9200. You can test it with a simple GET request like this on your browser:

http://localhost:9200

and the output is like this:



Hope You Like this. Please do share your comments and questions.

Stay tuned for new articles.






Comments (5)

  • user image
    Anurag Srivastava
    May 7, 2018, 12:44:19 PM

    Nice article Lovish. :)

  • user image
    Lovish Sharma
    May 7, 2018, 2:54:23 PM

    thanks anurag sir. :)

  • user image
    jitender yadav
    May 7, 2018, 5:37:00 PM

    Really helpful buddy

  • user image
    Lovish Sharma
    May 8, 2018, 6:40:48 PM

    Thanks jitender sir :)

  • user image
    Samuel Philip
    Aug 7, 2024, 12:43:11 AM

    Lovish, can u please update it for latest version of ubuntu and elastic?

Leave a comment

Related Blogs

preview thumbnail
Securing your Elastic Stack

Nov 4, 2019, 7:06:01 PM | Anurag Srivastava

preview thumbnail
Introduction to OpenAPI Specification

May 9, 2020, 6:58:33 AM | Anurag Srivastava

preview thumbnail
Creating dynamic presentations using Kibana Canvas

Apr 10, 2020, 3:01:55 PM | Anurag Srivastava

preview thumbnail
Geo distance search using Elasticsearch

May 16, 2020, 8:16:33 PM | Anurag Srivastava

Top Blogs

preview thumbnail
Geo distance search using Elasticsearch

May 16, 2020, 8:16:33 PM | Anurag Srivastava

preview thumbnail
Creating dynamic presentations using Kibana Canvas

Apr 10, 2020, 3:01:55 PM | Anurag Srivastava

preview thumbnail
Securing your Elastic Stack

Nov 4, 2019, 7:06:01 PM | Anurag Srivastava

preview thumbnail
Introduction to OpenAPI Specification

May 9, 2020, 6:58:33 AM | Anurag Srivastava

preview thumbnail
Elasticsearch Installation and Configuration on Ubuntu 14.04

May 7, 2018, 11:55:02 AM | Lovish Sharma