var img = document.createElement('img'); img.src = "https://easystat.de/piwik.php?idsite=13&rec=1&url=https://docs.vps2day.com" + location.pathname; img.style = "border:0"; img.alt = "tracker"; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(img,s);
Skip to main content

How to install Elasticsearch 6 on Ubuntu

In this tutorial, we will explain how to install Elasticsearch 6 on Ubuntu.

Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multi-tenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java. Until more recent versions, following an open-core business model, parts of the software are licensed under various open source licenses (mostly the Apache License), while other parts fall under the commercial (source-available) Elastic License.

info

This tutorial is now older than 2 years and may contain outdated information. There might be inaccuracies due to major changes in the software described. You should rather consider this tutorial as a general guideline that may or may not work in your specific situation.

Prerequisites

In order to follow along this tutorial, you'll need

Step 1 – Install OpenJDK

As Elasticsearch is written in Java, we need to install a Java Runtime Environment (JRE), first. For Elasticsearch 6, we'll use OpenJDK 8. If you are connected to your server using a non-root user, you'll need to prefix the following commands with sudo to run them with elevated privileges. You can install it by running the following command:

sudo apt-get install openjdk-8-jre

Step 2 – Add Elasticsearch repository

For Ubuntu, we can just utilise the official Elasticsearch APT repository to install Elasticsearch 6. In order to add the repository to your APT package manager, we need to download and import the GPG key that is used for signing the packages, first. You can do this by running the following command:

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

Afterward, add the repository to your APT package manager and refresh all package sources by running the following command:

sudo add-apt-repository "deb https://artifacts.elastic.co/packages/6.x/apt stable main" && sudo apt-get update

Step 3 – Install Elasticsearch 6

Now it's time to install Elasticsearch 6. Install it by running the apt package manager.

sudo apt-get install elasticsearch

After the installation of Elasticsearch 6 it will not be automatically started or enabled for auto-start when your server stats. To enable Elasticsearch 6 for auto-start run:

systemctl enable elasticsearch.service

Afterward, proceed to start it:

systemctl start elasticsearch.service

Step 4 – Verify installation

Now you can test your Elasticsearch 6 installation by running this command:

curl -X GET "http://localhost:9200"

If you get a response that looks like this, your installation was successful.

Elasticsearch 6 response

info

Please notice that this only describes the basic installation process. You should always consider securing your Elasticsearch installation by following the official Elasticsearch security documentation.