Elasticsearch is a powerful, distributed open-source search and analytics engine built for scalability. It allows you to store, search, and analyze large volumes of data in real-time. Elasticsearch follows a document-oriented data model and offers a query language called Elasticsearch Query DSL for performing complex searches and analysis.
In this tutorial, we will guide you through the process of installing Elasticsearch on Debian 11.
Step 1: Update Operating System
First, update your Debian 11 operating system to ensure that all existing packages are up to date:
# apt update && apt upgrade
Additionally, install the following packages:
# apt install curl wget gnupg apt-transport-https
Step 2: Add Elasticsearch Repository
Since Elasticsearch is not included in the default Debian 11 repository, you need to add the Elasticsearch repository to APT.
Begin by importing the Elasticsearch GPG key:
# wget -qO – https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg –dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
Next, add the Elasticsearch 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
Once the repository is added, update it with the following command:
# apt update
Step 3: Install and Configure Elasticsearch
Now, you can install Elasticsearch using the following command:
# apt install elasticsearch
After the installation is complete, edit the Elasticsearch configuration file located at “/etc/elasticsearch/elasticsearch.yml”:
# nano /etc/elasticsearch/elasticsearch.yml
Add the following content:
cluster.name: LinuxTuto
node.name: Debian 11
path.data: /var/lib/elasticsearch
network.host: 127.0.0.1
xpack.security.enabled: false
Save the changes and start the Elasticsearch service:
# systemctl start elasticsearch
# systemctl enable elasticsearch
To check the status of the Elasticsearch service, run the command:
$ sudo systemctl status elasticsearch.service
Step 4: Test Elasticsearch
To verify that Elasticsearch is running correctly, use the curl command:
# curl -X GET “localhost:9200/”
If Elasticsearch is functioning properly, the output should resemble the following:
{
“name” : “Debian 11”,
“cluster_name” : “LinuxTuto”,
“cluster_uuid” : “ezWPhn_fQLS5dcSiexroQA”,
“version” : {
“number” : “8.7.0”,
“build_flavor” : “default”,
“build_type” : “deb”,
“build_hash” : “09520b59b6bc1057340b55750186466ea715e30e”,
“build_date” : “2023-03-27T16:31:09.816451435Z”,
“build_snapshot” : false,
“lucene_version” : “9.5.0”,
“minimum_wire_compatibility_version” : “7.17.0”,
“minimum_index_compatibility_version” : “7.0.0”
},
“tagline” : “You Know, for Search”
}
This indicates that Elasticsearch is active and running on your server.
Step 5: Uninstall Elasticsearch
To remove Elasticsearch from your system, run the following command:
# apt remove elasticsearch
Conclusion
In this tutorial, we installed the free version of Elasticsearch, which is released under the Elastic license.