How can I install Elasticsearch 7, ElasticSearch 6, or 5 on the Ubuntu 20.04/18.04/16.04 Linux system?. This guide will help you to install Elasticsearch 7/6/5 on Ubuntu 20.04/18.04/16.04. Elasticsearch is an Open Source full-text search and analytics engine tool used to store, search, and analyze big volumes of data in near real-time.

The Debian package for Elasticsearch can be downloaded from the website or from our APT repository. In this guide, we will use the APT installation method, which installs Elasticsearch on any Debian-based system such as Debian and Ubuntu.

We will install the free version which is released under the Elastic license. See the Subscriptions page for information about Elastic license levels. Here are the steps you’ll need to install ElasticSearch 7, 6 or 5 on Ubuntu Linux.

For multi-node cluster, refer to Setup Elasticsearch Cluster on CentOS | Ubuntu With Ansible

Step 1: Update your system

I like starting all installations on an updated system.

sudo apt update
sudo apt -y upgrade

Step 2: Import the Elasticsearch PGP Key

Import Elasticsearch Signing Key used to sign all Elastic packages. Run the following command to download and install the public signing key:

sudo apt -y install gnupg
wget -qO - | sudo apt-key add -

Step 3: Add APT repository

Next, we add the Elasticsearch APT repository from where we will download and install the packages.

For Elasticsearch 7.x (Latest):

sudo apt -y install apt-transport-https
echo "deb stable main" | sudo tee  /etc/apt/sources.list.d/elastic-7.x.list

For Elasticsearch 6.x:

sudo apt -y install apt-transport-https
echo "deb stable main" | sudo tee  /etc/apt/sources.list.d/elastic-6.x.list

For Elasticsearch 5.x:

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

Step 4: Install Elasticsearch on Ubuntu 20.04/18.04/16.04

Then install the Elasticsearch Debian package by running:

sudo apt update
sudo apt -y install elasticsearch-oss

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

E.g, you can set the correct cluster name for your applications: my-application

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

sudo nano /etc/elasticsearch/jvm.options



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


Note that it is recommended to set the min and max JVM heap size to the same value. Xms represents the initial size of total heap space and Xmx represents the maximum size of total heap space.

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

sudo systemctl enable elasticsearch.service && sudo systemctl restart elasticsearch.service

Check elasticsearch service status:

$ systemctl status elasticsearch.service 
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-05-03 09:18:39 PDT; 18s ago
 Main PID: 21459 (java)
    Tasks: 18 (limit: 1093)
   Memory: 429.0M
   CGroup: /system.slice/elasticsearch.service
           ├─21459 /usr/share/elasticsearch/jdk/bin/java -Xms512m -Xms512m -XX:+UseConcMarkSweepGC -XX:CMSIn
           └─21589 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

May 03 09:18:39 ubuntu systemd[1]: Started Elasticsearch.

You have deployed a single node Elasticsearch cluster on your Ubuntu system.

Learning materials:

How to delete Elasticsearch Index data with curl

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