How to Install Elasticsearch 8 on Debian 12, 11 or 10

Elasticsearch 8, with its advanced capabilities and enhancements, has emerged as a pivotal tool in data search and analysis. For those keen on leveraging its power on Debian systems, this guide will detail how to install Elasticsearch 8 on Debian 12 Bookworm or the older stable releases of Debian 11 Bullseye or Debian 10 Buster.

Diving into Elasticsearch 8’s Key Offerings:

  • Transitional Reverse Compatibility: With an emphasis on smooth transitions, Elasticsearch 8 offers reverse compatibility with version 7 headers in REST API calls. This feature aids users in progressively updating their codebase during the upgrade process.
  • Advanced kNN Vector Searches: Building on the foundation of Elasticsearch 7, the new dense_vector field in version 8 facilitates quicker kNN searches on expansive datasets, albeit with a minor trade-off in accuracy.
  • PyTorch Machine Learning Integration: Elasticsearch 8 introduces the ability to integrate PyTorch-trained machine learning models. This enhancement paves the way for advanced NLP tasks, including text classification, embedding, and named entity recognition within the Elasticsearch ecosystem.
  • Standardized ECS-Compliant JSON Logs: Aiming for uniformity, Elasticsearch 8’s JSON logs are now ECS-compliant. This change encompasses modifications in stacktrace messages, field names, and Metricbeat ECS data templates to accommodate legacy logging formats.
  • Upgrade to Lucene Version 9: By transitioning to Lucene 9, Elasticsearch 8 amplifies its search functionalities. This upgrade introduces new language features, enhanced support for numeric vectors in kNN searches, and optimized indexing and sorting of multi-dimensional points.

Important Shifts to Note:

  • End of Support for Elasticsearch 6 Mappings: A pivotal change in Elasticsearch 8 is the cessation of support for Elasticsearch 6 mappings. It mandates that all indices on the cluster must originate from Elasticsearch version 7.0 or its subsequent releases.

As we delve deeper into this guide, we’ll elucidate the steps to seamlessly integrate Elasticsearch 8 into your Debian system, ensuring you harness its full potential.

Install Elasticsearch 8 on Debian 12, 11, or 10 via APT

Elasticsearch 8 introduces a myriad of enhancements over its predecessors. This section will walk you through installing it on a Debian Linux system.

Step 1: Update Debian Before Elasticsearch Installation

In the first step, you need to ensure your Debian Linux system is updated. This step will update all the existing software to its latest versions and prepare your system for installation.

Run the following command to update your Debian system:

sudo apt update && sudo apt upgrade

Step 2: Installing Necessary Packages

Before installing Elasticsearch 8 on Debian, we must satisfy specific prerequisites. This involves the installation of a few required packages, such as software-properties-common, apt-transport-https, and curl. These packages facilitate software management and data transfer over the network.

Install the necessary packages by running the following:

sudo apt install software-properties-common apt-transport-https curl -y

Step 3: Add Elasticsearch 8 APT Repository on Debian

Next, we’ll add the Elasticsearch APT repository to our Debian Linux system. Firstly, we’ll import the GPG key for Elasticsearch, which ensures the authenticity of the software you’re installing. Run the following command to import the GPG key:

curl -fSsL | gpg --dearmor | sudo tee /usr/share/keyrings/elasticsearch-8.gpg > /dev/null

Next, let’s import the Elasticsearch repository. This will allow us to install Elasticsearch directly using the apt package manager:

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-8.gpg] stable main" | sudo tee /etc/apt/sources.list.d/elasticsearch-8.list

Step 4: Updating APT Index Cache

We must update the APT package index after adding the Elasticsearch repository to our system. This ensures that APT knows about the new packages from the newly added repository. Run the following command to update the APT index:

sudo apt update

Step 5: Install Elasticsearch 8 on Debian via APT Command

Now that our system is prepped and the APT index is updated, we can install Elasticsearch 8. Use the following command to install Elasticsearch:

sudo apt install elasticsearch

If two entries exist for the same Elasticsearch repository, you will encounter an error during the apt update. If you come across a ‘Duplicate sources.list entry’ error, check the /etc/apt/sources.list.d/elasticsearch-8.x.list for the duplicate entry or locate the duplicate entry amongst the files in /etc/apt/sources.list.d/ and the /etc/apt/sources.list file.

Step 6: Enable Elasticsearch on Debian After Installation

Post-installation, the Elasticsearch service is disabled on boot and inactive by default. To enable the Elasticsearch service and set it to start automatically at boot, use the following systemctl command:

sudo systemctl enable elasticsearch.service --now

Configure Elasticsearch 8 on Debian 12, 11 or 10

The next stage of managing Elasticsearch 8 on your Debian Linux system – configuring it. This is where we tailor the software to match your specific requirements and optimize its performance.

Getting Acquainted with Default Elasticsearch Settings

On a fresh Elasticsearch installation, the software places its processed and stored data within the /var/lib/elasticsearch directory. If there is a need for configuration modifications, /etc/elasticsearch is your go-to directory. In cases where Java start-up options need tweaking, these settings can be adjusted in the /etc/default/elasticsearch configuration file.

These standard settings fit standalone servers where Elasticsearch operates exclusively on localhost. However, if your sights are set on establishing an Elasticsearch cluster or permitting remote connections, modifications to the default configuration are necessary.

Refining the Elasticsearch Configuration File

The Elasticsearch configuration file contains many parameters that can be adjusted to meet your unique needs. To open this file, execute the following command:

sudo nano /etc/elasticsearch/elasticsearch.yml

An important parameter is, which designates the name of the cluster your node belongs to. By default, this is “elasticsearch”, but in a production environment, a more distinct name is advisable.

Here’s an example: my_application

The option is another significant one that sets the name of the Elasticsearch node. This name is essential for smooth administration and management, especially when working with multiple nodes.

Here’s an example: node-1

Configure Elasticsearch 8 with HTTPS on Debian

The following covers the process of configuring HTTPS for your Elasticsearch installation. It is crucial to understand that encryption is essential to securing data. Configuring Elasticsearch to use HTTPS ensures that data is transmitted securely between Elasticsearch nodes and clients.

Step 1: Generate SSL Certificates

The first step in configuring Elasticsearch for HTTPS is to generate an SSL certificate. This certificate is what’s going to encrypt the data between your server and clients. Elasticsearch has a built-in tool called elasticsearch-certutil that you can use to generate a self-signed certificate. Run the following command:

sudo /usr/share/elasticsearch/bin/elasticsearch-certutil cert --silent --pem -out config/elastic-certificates.p12

This will create a .p12 file in the config directory. This file contains both the private key and the public certificate. It is essential to protect this file and ensure it’s not accessible to unauthorized users.

Step 2: Update Elasticsearch 8 Configuration

Next, you need to update the Elasticsearch configuration file located at /etc/elasticsearch/elasticsearch.yml to include the paths to your certificate and private key. Open the configuration file and add the following lines: true certificate elastic-certificates.p12 elastic-certificates.p12

These settings enable SSL for the transport layer, specify that we use certificates for SSL verification, and define the paths to the certificate and private key.

Allowing Remote Access (Optional)

Elasticsearch, by default, is configured to listen only to localhost. However, in cases where remote access is required, this can be adjusted. Look for the Network section, and uncomment the line by removing the # in front. Replace the existing value with your internal private IP address or external IP address.

Here’s an example:


In this example, has been uncommented and adjusted to an internal private IP address.

For security, specifying individual IP addresses is advisable. However, for multiple internal or external IP addresses connecting to the server, you could change the network interface to listen to all by setting it to

After making the necessary changes, save the configuration file (CTRL+O to save, CTRL+X to exit).

To enforce the configuration file changes, restart the Elasticsearch service with the command:

sudo systemctl restart elasticsearch

Modifying the UFW Firewall Rules for Remote Connections

If you’ve configured Elasticsearch to allow remote connections, adjusting your firewall rules to accommodate these connections is vital. The Uncomplicated Firewall (UFW) can assist with this.

You can permit a specific IP address to connect to Elasticsearch by executing this command:

sudo ufw allow from <IP Address> to any port 9200

Don’t forget to replace <IP Address> with the actual IP address you wish to allow connections from. This command will open port 9200 for the specified IP address, permitting it to interact with Elasticsearch.

For example, if you wish to allow the IP address to connect, the command would be:

sudo ufw allow from to any port 9200

Following this, your Debian server will permit traffic from to access Elasticsearch through port 9200. It’s important to remember that the security of your servers is paramount, so ensure that you only grant access to trusted IP addresses.

Verifying Elasticsearch 8 Configuration on Debian 12, 11 or 10

After modifying your Elasticsearch configuration, verifying that the changes have been implemented correctly and that your Elasticsearch instance is functioning as expected is vital.

Checking the Elasticsearch 8 Service Status

First, check the status of your Elasticsearch service to confirm that it’s active and running. You can do this with the following command:

sudo systemctl status elasticsearch

This command will output information about the Elasticsearch service, including whether it’s active and running. If not, you may need to troubleshoot the issue or review your configuration changes.

Testing Remote Access (Optional)

If you’ve enabled remote access, you can test it by trying to connect to your Elasticsearch instance from a remote machine. Remember that the IP address you’re connecting from must be allowed in your firewall rules, as discussed in the previous section.

You can use the curl command for this purpose:

curl https://<Your_Elasticsearch_IP>:9200

Replace <Your_Elasticsearch_IP> with the IP address of your Elasticsearch server. If successful, this command should return information about your Elasticsearch instance.

Validating Data Integrity

Finally, it’s essential to verify the integrity of your Elasticsearch data, especially if you’ve made changes to the data directory in your configuration. Elasticsearch provides APIs that you can use to check the status of your data.

For example, to get the status of all indices, use the following command:

curl -X GET "https://localhost:9200/_cat/indices?v=true&pretty"

This command lists all indices in your Elasticsearch instance and their health status. Check the health status of your indices to ensure that your data is safe and accessible.

Remember, maintaining the integrity and security of your data should always be a top priority. Always double-check your changes, validate your configuration, and monitor your Elasticsearch instance regularly. This will help you maintain a reliable, efficient, and secure data management system with Elasticsearch.

Interacting with Elasticsearch 8 via cURL on Debian 12, 11, or 10

This section will explore some common commands to interact with your Elasticsearch instance. We’ll use the curl command line tool, a flexible library for transferring data using different protocols.

Deleting an Index

An Elasticsearch index is a set of documents that have similar characteristics. If you have an index named samples that you wish to delete, you can accomplish that with the following command:

curl -X DELETE 'https://localhost:9200/samples'

This command sends an HTTP DELETE request to the specified URL, which tells Elasticsearch to delete the samples index.

Listing all Indices

To retrieve a list of all indices in your Elasticsearch instance, use the _cat/indices endpoint with a GET request like this:

curl -X GET 'https://localhost:9200/_cat/indices?v'

The response will list all indices, including the index’s health, status, size, and number of documents.

Fetching Documents from an Index

To fetch all documents from a specific index, say sample, use the _search endpoint:

curl -X GET 'https://localhost:9200/sample/_search'

This command retrieves all documents stored in the sample index.

Searching with URL Parameters

You can use Lucene’s query syntax for basic text searches. For instance, if you wanted to find documents where the school field is Harvard, you would use:

curl -X GET https://localhost:9200/samples/_search?q=school:Harvard

This command sends a GET request to the _search endpoint, using the q parameter for the query.

Searching with Elasticsearch Query DSL

For more complex queries, you might prefer to use Elasticsearch’s Query DSL, which allows you to use JSON to define queries. This format is more readable and more accessible to debug for complex queries. Here’s an example:

curl -XGET --header 'Content-Type: application/json' https://localhost:9200/samples/_search -d '{
      "query" : {
        "match" : { "school": "Harvard" }

This command does the same as the previous one but uses JSON for the query definition. This way, the command is more readable, especially when dealing with more complex queries.

Adding and Updating Documents

To add a new document to an index, you can use the PUT method along with the _doc endpoint. For example, to add a document with an ID of 1 and a school field of Harvard to the samples index, you would use:

curl -XPUT --header 'Content-Type: application/json' https://localhost:9200/samples/_doc/1 -d '{
   "school" : "Harvard"

To update a document, you can use the POST method with the _update endpoint. For instance, to add a students field to the document we just created, you would use:

curl -XPOST --header 'Content-Type: application/json' https://localhost:9200/samples/_doc/1/_update -d '{
"doc" : {
               "students": 50000}

This command tells Elasticsearch to update the document with an ID of 1 in the samples index, adding a students field with a value of 50000.

These commands are only a tiny sample of what you can accomplish with Elasticsearch. The Elasticsearch Query DSL

Manage Elasticsearch 8 on Debian 12, 11 or 10

This segment delves into the Elasticsearch 8 removal process from your Debian Linux server. You may want to do this for several reasons – perhaps the software no longer suits your requirements, or you’re planning on switching to an alternative solution. Regardless of your reasons, the steps outlined below will walk you through the process.

Elasticsearch 8 Removal From Debian

Eradicating Elasticsearch from your server involves a simple command. However, remember that this action is irreversible and will delete all associated data. Here’s the command to execute:

sudo apt remove elasticsearch

Running the above command will effectively uninstall Elasticsearch, freeing up any previously allocated system resources.

Remove Elasticsearch APT Repository

Post uninstallation, the Elasticsearch repository remains in your system. If you’re sure about not reinstalling Elasticsearch in the future, you might as well get rid of the repository to avoid unnecessary clutter. Here’s how to remove the Elasticsearch repository:

sudo rm /etc/apt/sources.list.d/elasticsearch-8.list

The above command will delete the Elasticsearch 8 repository from your Debian Linux server.

Refreshing Repository List

The final step is to refresh the apt package list. This step is essential to ensure your system doesn’t consider Elasticsearch 8 for future updates or installations. The command to update your repository list is as follows:

sudo apt update

Final Summary

In this guide, we’ve walked through the crucial steps of setting up and configuring Elasticsearch 8 on a Debian system. We’ve detailed the Elasticsearch default settings’ significance and how to tailor them to our needs. We’ve explained how to enhance our setup by adjusting the cluster name and node name and enabling remote access for improved manageability. We delved into security aspects, focusing on controlling access via IP and configuring firewall rules. Finally, we highlighted the importance of verification, ensuring our configurations are correctly implemented, and our data integrity remains intact.

Elasticsearch 8, with its wide-ranging capabilities and adaptable configuration options, remains a powerful tool for managing, processing, and analyzing vast amounts of data in real time. Understanding and optimizing these configurations is fundamental to harnessing Elasticsearch’s full potential, whether in a standalone setup or within a cluster.

Leave a Comment