Site icon DesignLinux

How to Install Elasticsearch on Debian 10

How to Install Elasticsearch on Debian 10

Elasticsearch is a powerful open-source analytics and full-text search engine. It provides a distributed, multitenant-capable architecture which enables you to store, search and analyze large volumes of data faster. Elastic search is freely available under the Apache 2 license, which provides the most flexibility. In this tutorial we will show you how to install Elasticsearch on Debian 10.

Install Elasticsearch on Debian

First, you should login to your Debian system using sudo privileged user or root account. Perform the following steps:

1. Installing Java

Java is the primary requirement to run Elasticsearch on any system, so the first step is to install Java.

Execute the following command to install the OpenJDK package:

sudo apt install default-jdk

Verify the Java installation by checking the Java version:

java -version

It will show the output like below:

openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1deb10u1, mixed mode, sharing)

2. Installing Elasticsearch

The standard Debian 10 repositories does not includes Elasticsearch package, so we will install it from the Elasticsearch APT repository.

Import the repository’s public key using the following wget command:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

It should print OK as an output, that means the key has been successfully imported, and packages from this repository will be considered trusted.

Run the following command to add the Elasticsearch repository to the system:

sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'

Next, update the packages index and install the Elasticsearch engine:

sudo apt update
sudo apt install elasticsearch

After completion of the process, start, and enable the service:

sudo systemctl enable elasticsearch.service --now

3. Configuring Elasticsearch

Configuration files for Elasticsearch are located in /etc/elasticsearch and Java start-up options can be configured in the /etc/default/elasticsearch file.

By default, Elasticsearch is configured to listen on localhost only. There is no authentication layer in Elasticsearch, so it can be accessed by anyone who can access the HTTP API. If you want to allow remote access to your Elasticsearch server, you will need to configure your firewall and allow access to the Elasticsearch port 9200 only from trusted clients.

For instance, if your system has UFW and you want to allow connections only from 192.168.123.45, run the following command:

sudo ufw allow from 192.168.123.45 to any port 9200

Next, you have to edit the Elasticsearch configuration and allow Elasticsearch to listen for external connections.

Open the elasticsearch.yml configuration file:

sudo nano /etc/elasticsearch/elasticsearch.yml

Find the line that contains network.host, uncomment and change the value to 0.0.0.0:

network.host: 0.0.0.0

Restart the Elasticsearch service for the changes to take effect:

sudo systemctl restart elasticsearch

It’s done. You can now connect to the Elasticsearch server from the remote location.

4. Test Elasticsearch Setup

The Elasticsearch service is ready to use. You can test it using curl command-line utility. To verify, use curl to send an HTTP request to port 9200 on localhost:

curl -X GET "http://localhost:9200/?pretty"
{
  "name" : "debian10.localdomain",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "yCOOHdvYR8mHRs5mNXQdDQ",
  "version" : {
    "number" : "7.8.1",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
    "build_date" : "2020-02-29T00:15:25.529771Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Conclusion

This tutorial shown you how to install Elasticsearch on Debian 10. To get more details about Elasticsearch visit the official documentation page.

If you face any problem or having a feedback, feel free to leave a comment below.

Exit mobile version