Site icon DesignLinux

How to Install Elasticsearch on Ubuntu 22.04

how-to-install-elasticsearch-on-ubuntu-22-04

Elasticsearch is a scalable, distributed and open-source software used to store collected. Its a data analytics and full-text search engine. It provides a multitenant-capable architecture which enables you to store, search and analyze large volumes of data faster. Elastic search is freely available under the Apache 2 license, which provides the most flexibility. In this tutorial we will show you how to install Elasticsearch on Ubuntu 22.04.

How to Install Elasticsearch on Ubuntu 22.04

First, you should login to your Ubuntu system using sudo privileged user or root account. Follow the below steps to install Elastic search on your Ubuntu 22.04 system:

Step 1 – Updating system

At first, we will update the package index list and install necessary dependencies to add a new HTTPS repository:

sudo apt update && sudo apt upgrade -y

The Elasticsearch package ships with a bundled version of OpenJDK, so you do not have to install Java.

sudo apt install apt-transport-https ca-certificates wget

Step 2 – Import GPG Key

After that, import the repository’s public key using the following wget command:

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

It should print OK as an output, that means the key has been successfully imported, and packages from this repository will be considered trusted.

Run the following command to add the Elasticsearch repository to the system:

sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'

Step 3 – Installing Elasticsearch

Next, update the packages index and install the Elasticsearch engine:

sudo apt update
sudo apt install elasticsearch

Once the process completed, start and enable the service using below given command:

sudo systemctl enable elasticsearch.service --now

Step 4 – Configuring Elasticsearch

Configuration files for Elasticsearch are located in /etc/elasticsearch and Java start-up options can be configured in the /etc/default/elasticsearch file.

By default, Elasticsearch is configured to listen on localhost only. There is no authentication layer in Elasticsearch, so it can be access by anyone who can access the HTTP API. If you want to allow remote access to your Elasticsearch server, you will need to configure your firewall and allow access to the Elasticsearch port 9200 only from trusted clients.

For instance, if your system has UFW and you want to allow connections only from 192.168.123.45, run the following command:

sudo ufw allow from 192.168.123.45 to any port 9200

Next, you have to edit the Elasticsearch configuration and allow Elasticsearch to listen for external connections.

Open the elasticsearch.yml configuration file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Find the line that contains network.host, uncomment and change the value to 0.0.0.0:

network.host: 0.0.0.0

Restart the Elasticsearch service for the changes to take effect:

sudo systemctl restart elasticsearch

That’s all. You can now connect to the Elasticsearch server from the remote location.

Step 5 – Test Elasticsearch Setup

The Elasticsearch service is ready to use. You can test it using curl command-line utility. To verify, use curl to send an HTTP request to port 9200 on localhost:

curl -X GET "http://localhost:9200/?pretty"
{
  "name" : "tecnstuff",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "IJqDxPfXSrmFQ27KbXbRIg",
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "build_snapshot" : false,
    "lucene_version" : "8.5.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Conclusion

This tutorial shown you how to install Elasticsearch on Ubuntu 22.04. To get more details about Elasticsearch visit the official documentation page.

If you face any problem or having a feedback, feel free to leave a comment below.

Exit mobile version