How To Install Elasticsearch on Ubuntu 22.04 LTS

Install Elasticsearch on Ubuntu 22.04

In this tutorial, we will show you how to install Elasticsearch on Ubuntu 22.04 LTS. For those of you who didn’t know, Elasticsearch is a powerful scalable real-time distributed search and data analysis. Elasticsearch is well-liked and popular amongst sysadmins and developers as it is a mighty search engine based on the Lucene library. The search engine works very quickly, can be used to search large amounts of data (big data), and supports distributed architectures for high availability.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Elasticsearch on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 22.04, 20.04, 18.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo useror access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Elasticsearch on Ubuntu 22.04 LTS Jammy Jellyfish

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade
sudo apt install build-essential checkinstall zlib1g-dev libssl-dev

Step 2. Installing Elasticsearch on Ubuntu 22.04.

By default, the Elasticsearch is not available on Ubuntu 22.04 base repository. Now run the following command below to add the Elasticsearch repository to your Ubuntu system:

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list

Next, import the GPG key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

After the repository is enabled, now install the latest version of Elasticsearch using the below command:

sudo apt update
sudo apt install elasticsearch

Elasticsearch service is not started automatically after installation, to start the service and enable it on system boot, type the following systemctl command:

sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
sudo systemctl status elasticsearch

Step 3. Configure Elasticsearch.

To configure Elasticsearch, we edit its main configuration file elasticsearch.yml where most of its configuration options are stored:

nano /etc/elasticsearch/elasticsearch.yml

Find the line that specifies network.host, uncomment it and replace its value with localhost so it reads like this:

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: localhost
. . .

Save and exit the file, then restart the Elasticsearch service for the changes to take effect:

sudo systemctl restart elasticsearch

Step 4. Configure Firewall.

Ubuntu 22.04 has ufw a firewall running by default. Enable connection through ports 9200:

sudo ufw allow 9200
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status

Step 4. Testing Elasticsearch.

Once successfully installed, open a web browser on your system and type the server’s IP in the address bar:

http://Your-IP-address:9200

Output:

{
  "name" : "1krDCO-",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "mzgLCfLJeliZUbpC_6R0wQ",
  "version" : {
    "number" : "6.8.24",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "4f66956",
    "build_date" : "2022-06-06T21:23:50.08771JZ",
    "build_snapshot" : false,
    "lucene_version" : "7.7.4",
    "minimum_wire_compatibility_version" : "5.6.1",
    "minimum_index_compatibility_version" : "5.0.1"
  },
  "tagline" : "You Know, for Search"
}

Congratulations! You have successfully installed Elasticsearch. Thanks for using this tutorial for installing the Elasticsearch on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official Elasticsearch website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!