How to install Elasticsearch on Ubuntu
Elasticsearch is a free and open-source search engine taht features
distributed full-text search and analytics engine. It supports RESTful
operations and allows you to store, search, and analyze big volumes of data in
real-time. Elasticsearch is one of the most popular search engines powering
applications that have complex search requirements such as big e-commerce
stores and analytic applications.
This guide explains how to install Elasticsearch on Ubuntu 20.04.
Installing Elasticsearch
Installing Elasticsearch on Ubuntu is fairly straightforward. We’ll enable the
Elasticsearch repository, import the repository GPG key, and install the
Elasticsearch server.
The Elasticsearch package ships with a bundled version of OpenJDK, so you
do not have to install Java.
First, update the packages index and install the dependencies necessary to
add a new HTTPS repository :
sudo apt update
sudo apt install apt-transport-https ca-certificates wget
Import the repository’s GPG key:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
The command above should output OK, which means that the key has been
successfully imported, and packages from this repository will be considered
trusted.
Next, add the Elasticsearch repository to the system by issuing:
sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" >
/etc/apt/sources.list.d/elastic-7.x.list'
If you want to install a previous version of Elasticsearch, change 7.x in the
command above with the version you need.
Once the repository is enabled, install Elasticsearch by typing:
sudo apt update
sudo apt install elasticsearch
Elasticsearch service will not start automatically after the installation process
is complete. To start the service and enable the service run:
sudo systemctl enable --now elasticsearch.service
To verify that Elasticsearch is running, use curl to send an HTTP request to
port 9200 on localhost:
curl -X GET "localhost:9200/"
You should see something similar to this: