Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Elasticsearch on Ubuntu

Two ways to install Elasticsearch 8: from the APT repository or from the .deb package.

Databases2 min read9 screenshots
Elasticsearch

Method 1: The APT repository

Step 1: Import the PGP key

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

This downloads the public key of Elastic and stores it in a keyring, so APT can check the packages.

Step 2: Install the HTTPS transport

sudo apt-get install apt-transport-https
Installing apt-transport-https

Step 3: Add the repository

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

signed-by points to the keyring, and tee saves the line in the sources file.

Step 4: Update and install

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

At the end of the install, the output shows a **generated password for the elastic user**. Copy it and keep it safe.

Step 5: Start the service

sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service

Step 6: Check the status

sudo systemctl status elasticsearch.service
The Elasticsearch service status

Method 2: The .deb package by hand

Step 1: Download the package

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.16.0-amd64.deb
Downloading the package

Use the current version number from the Elastic website.

Step 2: Download the checksum file

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.16.0-amd64.deb.sha512
Downloading the checksum file

Step 3: Check the package

shasum -a 512 -c elasticsearch-8.16.0-amd64.deb.sha512
Checking the SHA512 sum

You should see OK.

Step 4: Install

sudo dpkg -i elasticsearch-8.16.0-amd64.deb
Installing the package

Then start the service as in Method 1.

Test it

Elasticsearch 8 uses HTTPS and a login by default:

curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200

Enter the elastic password. You get a JSON answer with the name of the node and the version.

To reset the password later:

sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic

Main configuration

The file is /etc/elasticsearch/elasticsearch.yml. Common settings are cluster.name, node.name, network.host and discovery.seed_hosts. Memory is set in /etc/elasticsearch/jvm.options.d/. Keep network.host on localhost unless you need remote access, and then protect the port 9200 with a firewall.

Features of Elasticsearch

  • Fast search.
  • Scalability across many nodes.
  • Full-text search.
  • Real-time data analysis.
  • Integrations with Kibana, Logstash and Beats.

Quick recap

  • Add the Elastic APT repository and install elasticsearch.
  • Save the generated elastic password.
  • Start the service and test with curl.