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

The first step is to import Elasticsearch GPG Key which will trust elasticsearch packages downloaded from the upstream repository. Import the key by running the commands on your terminal.

$ wget -qO - | sudo apt-key add -

Step 2: Add Elasticsearch 6.x APT repository

Now that the GPG key has been imported, add the apt repository by running:

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

Step 3: Install OpenJDK

Elasticsearch is dependent on Java, you’ll need OpenJDK Java runtime environment installed to be able to run elasticsearch on your system.

sudo apt update
sudo apt install apt-transport-https openjdk-8-jre-headless

Step 4: Install Elasticsearch 6.x on Ubuntu 18.04

Now run apt-get update  then install elasticsearch package on your Ubuntu 18.04 server:

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 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 vim /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 daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl restart elasticsearch.service

Check elasticsearch service 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-08-18 05:16:08 UTC; 7s ago
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

You now have a working Elasticsearch 6.x on Ubuntu 18.04 LTS (Bionic Beaver) server. Other articles related to Elasticsearch are:

How to Install Elasticsearch 6 on CentOS 7 with Kibana Data Visualization tool

Manage Logs with Graylog server on Ubuntu 18.04

How to Install Graylog 2.4 with Elasticsearch 5.x on CentOS 7