Elasticsearch is a highly scalable open-source analytics engine and full-text search. With Elasticsearch, you can store, search, and analyze big volumes of data faster and in near real time. Elasticsearch is generally used as the underlying engine/technology that powers applications that have complex search features and requirements. This guide will show you how to install Elasticsearch 5.x on Ubuntu 18.04 LTS (Bionic Beaver) Linux.

For Elasticsearch 6.x, check How to Install Elasticsearch 6.x on Ubuntu 18.04 LTS (Bionic Beaver) Linux

Here is the guide to install Elasticsearch 5.x on Ubuntu 18.04 LTS.

Step 1: Import Elasticsearch GPG Key

The first step is to import Elasticsearch GPG Key using the command:

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

Step 2: Add Elasticsearch 5.x APT repository

Once the GPG key has been imported, add the apt repository so that you can install Elasticsearch package from:

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

Step 3: Install OpenJDK

Elasticsearch is dependent on Java, you need to install OpenJDK before you can continue.

sudo apt -y install default-jdk default-jre

Step 4: Install Elasticsearch 5.x on Ubuntu 18.04

Now run apt-get update  then install elasticsearch package:

sudo apt update
sudo apt install elasticsearch

After the installation, a default configuration file will be populated to /etc/elasticsearch/elasticsearch.ymlMost lines are commented out, edit the file to tweak and tune the configuration.

E.g, you can set correct cluster name for your applications:

cluster.name: my-application

Note that the default minimum memory set for JVM is 2gb, if your server has small memory size, change this value:

$ sudo vi /etc/elasticsearch/jvm.options



And set your values for minimum and maximum memory allocation. E.g to set values to 512mb of ram, use:


After you have modified the configuration, you can start Elasticsearch:

sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl restart elasticsearch.service

Check status:

$ sudo systemctl status elasticsearch.service 
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2018-07-01 10:39:54 UTC; 18s ago
Docs: http://www.elastic.co
Process: 14314 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
Main PID: 14325 (java)
Tasks: 38 (limit: 2362)
CGroup: /system.slice/elasticsearch.service
└─14325 /usr/bin/java -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -X

That’s all for the installation of Elasticsearch 5.x on Ubuntu 18.04 LTS (Bionic Beaver) Linux.

Video course content:

For Cluster setup, check out Setup Elasticsearch Cluster on CentOS / Ubuntu With Ansible

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here