We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install Elasticsearch on Ubuntu 22.04|20.04|18.04

Learn how to – How To Install Elasticsearch on Ubuntu 22.04|20.04|18.04.

How can I install ElasticSearch 8, 7, or 6 on the Ubuntu 22.04|20.04|18.04 Linux system?. 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 8,7, or 6 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 full-upgrade

Check if the system needs reboot:

[ -f /var/run/reboot-required ] && sudo reboot -f

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
curl  -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/elastic.gpg

Step 3: Add APT repository

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

For Elasticsearch 8.x:

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

For Elasticsearch 7.x:

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

Step 4: Install Elasticsearch on Ubuntu

Then install the Elasticsearch Debian package by running:

sudo apt update
sudo apt 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:

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 nano /etc/elasticsearch/jvm.options

Change:

-Xms2g
-Xmx2g

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

-Xms512m
-Xmx512m

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
     Docs: http://www.elastic.co
 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:

Reference books:

Cart

Your Cart is Empty

Back To Shop