Install and Configure Elasticsearch 8 on Ubuntu 22.04 Command Line

Install and configure elasticsearch 8 on Linux ubuntu 22.04; Through this tutorial, we will learn how to install and configure elasticsearch 8 on Linux ubuntu 22.04 using terminal or command line.

How to Install and Configure Elasticsearch 8 on Ubuntu 22.04

Steps to install and configure elasticsearch 8 on Linux ubuntu 22.04 using terminal or command line:

  • 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

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

sudo apt update
sudo apt upgrade -y

Then execute 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

Then execute 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

Execute 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

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

sudo systemctl start elasticsearch

After that execute 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

Through this tutorial, we learned how to install and use ElasticSearch 8 on Ubuntu 22.04 server.

Recommended Linux Ubuntu Tutorials

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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