How to Install and Configure Elasticsearch 8 on Ubuntu?

26-May-2023

.

Admin

How to Install and Configure Elasticsearch 8 on Ubuntu?

Hello Friends,

This tutorial shows you how to install and configure Elasticsearch 8 on Ubuntu. This post will give you a simple example of how to install Elasticsearch 8 on Ubuntu. you can see installing Elasticsearch on Ubuntu. let’s discuss installing Elasticsearch on Ubuntu for next-level searching. Let's see bellow example how to install elastic search on rocky Linux 8.

Installing and Configuring Elasticsearch 8 on Linux Ubuntu 22.04: In this tutorial, we will learn how to install and configure Elasticsearch 8 on Linux Ubuntu 22.04.

Step 1: Update System Dependencies


First of all, open the terminal or command line and execute the following command on the command line to update system dependencies:

sudo apt update

sudo apt upgrade -y

Then execute the following command on the command line to install some common packages:

sudo apt install -y vim wget

Step 2: Import the Elasticsearch PGP Key

Elasticsearch signs all of our packages with the Elasticsearch Signing Key (PGP key D88E42B4, available from https://pgp.mit.edu) with fingerprint:

4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4

Then execute the following command on the command line to download and install the public signing key:

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

Step 3: Install Elasticsearch from the APT repository

Execute the following commands on the command line to install the Elasticsearch package:

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

sudo apt-get update && sudo apt-get install elasticsearch

Step 4: Start and Enable the Elasticsearch Service

Then execute the following command on the command line to start Elasticsearch service:

sudo systemctl start elasticsearch

After that execute the following command on the command line to enable the service on boot:

sudo systemctl enable elasticsearch

Step 5: Verify Elasticsearch

To verify ElasticSearch is started and listening on port 9200:

ss -antpl | grep 9200

Step 6: Use Elasticsearch

Then use the following command with the Curl command to add data to the ElasticSearch; is as follows:

sudo curl -H 'Content-Type: application/json' -X POST --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic 'http://localhost:9200/todo/task/1' -d '{ "name": "Go to the mall." }'

Output after entering the password:

{"_index":"todo","_type":"task","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}

I hope it can help you...

#Ubuntu