How to Install Elasticsearch on Ubuntu

Elasticsearch is a powerful open-source search and analytics engine designed to help users store, search, and analyze large volumes of data quickly and in near real-time. Built on Apache Lucene, Elasticsearch is popular for its speed, scalability, and flexibility, making it ideal for log and event data analysis, full-text searches, and even complex data retrieval tasks. As an essential tool in the ELK stack (Elasticsearch, Logstash, and Kibana), Elasticsearch plays a central role in data management and insight generation for many industries.

Ubuntu users benefit from Elasticsearch’s seamless integration and ease of deployment on Linux-based systems. Installing Elasticsearch on Ubuntu allows users to enhance their applications with advanced search capabilities and powerful analytics without needing extensive resources. From monitoring infrastructure to powering search bars and recommendation systems, Elasticsearch provides Ubuntu users with robust data solutions that are both reliable and highly adaptable to varied needs.

In this article, we’ll guide you through the steps to install Elasticsearch Ubuntu.

Method 1: Installing Elasticsearch on Ubuntu via APT Repository

Step 1: Import the Elasticsearch PGP Key

To begin the installation process, the first step is to import the Elasticsearch PGP (Pretty Good Privacy) key. This key ensures that the Elasticsearch packages we download are secure and authentic. PGP keys act as digital signatures for software packages, allowing Ubuntu to verify that the files come from trusted sources and have not been tampered with. Using a PGP key helps protect your system from potentially harmful or unauthorized code.

The following command will import the Elasticsearch PGP key to your system:

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

In this command:

  • wget -qO – https://artifacts.elastic.co/GPG-KEY-elasticsearch downloads the PGP key for Elasticsearch. The -qO – part suppresses extra output and pipes (`|`) the key directly to the next command.
  • sudo gpg –dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg converts the downloaded key into a format that Ubuntu can use to authenticate packages. By storing it in /usr/share/keyrings/elasticsearch-keyring.gpg, Ubuntu can access the key whenever it checks for Elasticsearch package updates, ensuring continued security.

Importing this PGP key is essential, as it guarantees the integrity and trustworthiness of Elasticsearch packages on your Ubuntu system.

Step 2: Installing from the APT Repository

Once we’ve imported the Elasticsearch PGP key, the next step is to install Elasticsearch from the official APT (Advanced Package Tool) repository. Installing from the APT repository ensures you get the latest version of Elasticsearch directly from Elastic, along with automatic updates and patches.

Install the `apt-transport-https` Package

On some Debian-based systems, you may need the apt-transport-https package to enable downloading packages over HTTPS. This package ensures that APT, Ubuntu’s package management tool, can securely retrieve packages from remote repositories.

To install apt-transport-https, use the following command:

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

In this command, sudo apt-get install apt-transport-https tells APT to install the package that enables HTTPS transport. Installing this package helps ensure secure communication with the Elasticsearch repository.

Add the Elasticsearch Repository to APT Sources

After setting up HTTPS support, you need to add the Elasticsearch repository to your APT sources list. This enables APT to locate and retrieve Elasticsearch from Elastic’s official package repository.

To add the repository, run:

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
artifacts elastic

In this command:

  • echo “deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main” outputs the repository definition, which specifies the location of Elasticsearch packages (https://artifacts.elastic.co/packages/8.x/apt), and the specific distribution and component (i.e., `stable main`).
  • signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg refers to the PGP key we imported earlier, verifying the repository’s authenticity.
  • sudo tee /etc/apt/sources.list.d/elastic-8.x.list saves the repository information to a new file, elastic-8.x.list, in /etc/apt/sources.list.d, where APT can read it for future package installations and updates.

Adding this repository allows Ubuntu to detect the latest Elasticsearch versions directly from Elastic, simplifying updates and maintenance.

Update APT and Install Elasticsearch

Now that we’ve added the repository, we need to update the APT package list to recognize Elasticsearch. Then, we can install Elasticsearch itself.

Run the following command:

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

Here’s what each part of this command does:

  • sudo apt-get update refreshes APT’s package list, pulling the latest package information from all sources, including the newly added Elasticsearch repository.
  • sudo apt-get install elasticsearch install Elasticsearch on your system.

This method ensures you’re using a trusted package, with easy access to future updates through Ubuntu’s package management.

Verifying Status of Elasticsearch on Ubuntu

After installing Elasticsearch, you can verify its status by executing:

sudo systemctl status elasticsearch.service
systemctl elastic

Method 2: Download and Install the Debian Package Manually

If you prefer not to use the APT repository, you can manually download and install the Debian package for Elasticsearch. This method gives you more control over the version you install and can be helpful for specific installation needs.

Step 1: Download the Elasticsearch Debian Package

First, download the latest Elasticsearch Debian package directly from Elastic’s website. Use the following command:

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

In this command:

  • wget is a utility that downloads files from the internet.
  • The URL https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.16.0-amd64.deb points to the Debian package for Elasticsearch version 8.16.0.

This command will download the .deb file to your current directory, ready for installation.

Step 2: Download the SHA512 Checksum File

After downloading the package, it’s crucial to verify its integrity. This ensures the file was downloaded correctly and hasn’t been altered. To do this, download the SHA512 checksum file with the following command:

wget
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.16.0-amd64.deb.sha512
download elasticsearch

This command downloads the checksum file, which contains the SHA512 hash for the Debian package you just downloaded.

Step 3: Verify the Package with the SHA512 Checksum

With the checksum file downloaded, you can now verify the integrity of the Elasticsearch Debian package. Use this command:

shasum -a 512 -c elasticsearch-8.16.0-amd64.deb.sha512
shasum 512

In this command, shasum -a 512 calculates the SHA512 checksum of the downloaded file. Whereas, -c elasticsearch-8.16.0-amd64.deb.sha512 compares the calculated checksum with the one in the .sha512 file. If they match, you’ll see a confirmation that the file is intact and safe to install.

Checksum verification helps ensure you’re installing a legitimate, untampered package, protecting your system from compromised or incomplete downloads.

Step 4: Install the Elasticsearch Debian Package

After verifying the package integrity, proceed with the installation using the `dpkg` command:

sudo dpkg -i elasticsearch-8.16.0-amd64.deb
elastic search

Here’s what this command does:

  • sudo dpkg -i installs the .deb package with elevated (admin) permissions.
  • elasticsearch-8.16.0-amd64.deb is the downloaded package you’re installing.

This step completes the manual installation of Elasticsearch on your Ubuntu system, bypassing the need for APT repository configurations and enabling you to install the exact version you downloaded.

Features of Elasticsearch

Elasticsearch offers powerful indexing capabilities, enabling rapid searches across large volumes of data. This high-speed search functionality allows users to retrieve relevant information quickly, making it suitable for applications where real-time data access is essential.

Scalability

Elasticsearch is designed to handle data growth effortlessly. It supports horizontal scaling, meaning you can add more nodes to the cluster as your data volume increases. This scalability makes it ideal for enterprises managing massive datasets across distributed systems.

Elasticsearch provides advanced full-text search capabilities, including support for complex queries, filters, and multi-language analysis. This feature enables precise searching in textual data, making it popular in applications requiring nuanced text analysis.

Real-Time Data Analysis

With Elasticsearch, users can perform real-time analytics on structured and unstructured data. This real-time analysis feature makes it easy to monitor and gain insights from data as it’s generated, making it valuable for applications like log monitoring.

Integration with Other Tools

Elasticsearch integrates well with data visualization tools like Kibana and Logstash. This seamless integration allows users to create dashboards, analyze data patterns, and simplify data processing workflows, enhancing overall data management.

Conclusion

In this article, we covered two methods for installing Elasticsearch on Ubuntu. The first method involves setting up Elasticsearch through the APT repository, which streamlines installation and updates by linking directly to the official Elasticsearch package source. This approach is user-friendly, ideal for those who want to keep Elasticsearch updated automatically with minimal manual intervention.

The second method is installing Elasticsearch manually using a downloaded Debian package. This approach offers more control, as users can choose specific versions and avoid potential compatibility issues from automatic updates. It’s especially useful for environments requiring version consistency. Both methods provide effective ways for elasticsearch ubuntu install, each with its own advantages, making it adaptable for different needs and preferences in system management.

Installing the Elasticsearch on Ubuntu provides a user-friendly way to manage data analytic tool. You can upgrade to an Ultahost Linux VPS hosting plan for complex server environments, giving you enhanced control and advanced real time server.

FAQ

What is Elasticsearch?
What are the system requirements to install Elasticsearch on Ubuntu?
Which version of Elasticsearch should I install?
How do I set Elasticsearch to start automatically on boot?
How do I stop or restart Elasticsearch on Ubuntu?
How do I check the status of Elasticsearch?
Can I install Elasticsearch as a Docker container on Ubuntu?

Related Post

How to Install Laravel on Ubuntu 22.04

Laravel is a popular open-source PHP framework used for...

How to Install Perl on Ubuntu

Perl, short for Practical Extraction and Reporting Lang...

How to Install and Configure NFS on Ubuntu

NFS, which stands for Network File System, is a tool th...

How To Install Jenkins on Ubuntu 22.04

Jenkins is a powerful open-source automation server tha...

How to Install CyberPanel on Ubuntu

CyberPanel is a control panel designed to simplify the ...

How to Install Spark on Ubuntu

Apache Spark offers a powerful open-source framework sp...

Leave a Comment