Blog Detail

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

Elasticsearch Installation and Configuration on Ubuntu 14.04

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.





About Author

Lovish Sharma

I am software engineer and always ready to learn new technologies.

View Profile

Comments (4)

  • 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 :)

Leave a comment

Related Blogs

Secure your Elastic Stack

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

Apply transparent image background in GIMP

Dec 25, 2018, 6:17:04 PM | Anurag Srivastava

Top Blogs

Configure SonarQube Scanner with Jenkins

Jun 21, 2018, 4:58:11 AM | Anurag Srivastava

Build and deploy Angular code using Python

Jun 26, 2018, 4:50:18 PM | Anurag Srivastava

Configure Jenkins for Automated Code Deployment

Jun 13, 2018, 3:44:01 PM | Anurag Srivastava

SonarQube installation on Ubuntu

May 12, 2018, 4:47:07 PM | Anurag Srivastava

Execute Commands on Remote Machines using sshpass

Jul 16, 2018, 5:00:02 PM | Anurag Srivastava

Why SonarQube is important for IT projects ?

Apr 24, 2018, 2:52:28 PM | Anurag Srivastava

Elasticsearch Rest API

Jul 31, 2018, 6:16:42 PM | Anurag Srivastava

Analyze your project with SonarQube

Jun 2, 2018, 10:49:54 AM | Anurag Srivastava

Wildcard and Boolean Search in Elasticsearch

Aug 10, 2018, 7:14:40 PM | Anurag Srivastava

Install Jenkins on Ubuntu

May 26, 2018, 6:42:02 PM | Anurag Srivastava