How to install Elasticsearch on Debian Latest

Introduction

Elasticsearch is a popular search and analytics engine used to index and centralized logging systems. In this tutorial, we will install Elasticsearch on Debian Latest.

Prerequisites

Step 1: Update System Packages

Before we start the installation, let's update our system packages to the latest version.

sudo apt update
sudo apt upgrade

Step 2: Install Java

Elasticsearch requires Java to run. We will install the OpenJDK package available in the Debian repository.

sudo apt install openjdk-11-jdk

Verify that the Java installation was successful by running the command below:

java -version

Step 3: Download and Install Elasticsearch

We will now download the Elasticsearch package. Visit the Elasticsearch downloads page and get the download link for the current stable release:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-linux-x86_64.tar.gz

Extract the downloaded archive and move the extracted directory to /usr/share/elasticsearch.

tar -xzf elasticsearch-7.10.2-linux-x86_64.tar.gz
sudo mv elasticsearch-7.10.2 /usr/share/elasticsearch/

Create a symlink to make Elasticsearch easier to manage:

sudo ln -s /usr/share/elasticsearch/bin/elasticsearch /usr/bin/elasticsearch

Set Elasticsearch's environment variables by creating a file called elasticsearch-env.sh in /etc/default/.

sudo nano /etc/default/elasticsearch-env.sh

Add the following details in the file:

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/

Step 4: Configure Elasticsearch

Elasticsearch's configuration file is located in /usr/share/elasticsearch/config/elasticsearch.yml.

sudo nano /usr/share/elasticsearch/config/elasticsearch.yml

Add the following lines to configure Elasticsearch:

cluster.name: mycluster1
node.name: node-1
network.host: 0.0.0.0

Save and close the file.

Step 5: Start Elasticsearch Service

Let's start the Elasticsearch service:

sudo systemctl restart elasticsearch
sudo systemctl enable elasticsearch

Verify that the Elasticsearch service is enabled and running:

sudo systemctl status elasticsearch

Conclusion

Congratulations! You have successfully installed and configured Elasticsearch on Debian Latest. You can now start using Elasticsearch to index and search your data.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!