How to Install and Configure Elasticsearch 8 on Ubuntu 22.04

Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

In this tutorial, i am going to show you how to install and configure elasticsearch 8 on Linux ubuntu 22.04.

How to Install and Configure Elasticsearch 8 on Ubuntu 22.04

Use the below given steps to install and configure elasticsearch 8 on Linux ubuntu 22.04:

  • Step 1 – Update System Dependencies
  • Step 2 – Import the Elasticsearch PGP Key
  • Step 3 – Install Elasticsearch from the APT repository
  • Step 4 – Start and Enable the Elasticsearch Service
  • Step 5 – Verify Elasticsearch
  • Step 6 – Use Elasticsearch

Step 1 – Update System Dependencies

Start terminal and run the following command on command line to update system dependencies:

sudo apt update
sudo apt upgrade -y

After that, run the following command on 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

After that, run the following command on 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

Run the following commands on 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

Run the following command on command line to start Elasticsearch service:

sudo systemctl start elasticsearch

After that run the following command on 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 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}

Conclusion

In this tutorial, i have shown to you how to install and use ElasticSearch 8 on Ubuntu 22.04 server.

More Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *