In this tutorial, we will show you how to install Elasticsearch on Debian 11. For those of you who didn’t know, Elasticsearch is the distributed, RESTful search and analytics engine at the heart of the Elastic Stack. Elasticsearch is well-liked and popular amongst sysadmins and developers as it is a mighty search engine based on the Lucene library. It is generally used as the underlying engine/technology that powers applications with complex search features and requirements.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Elasticsearch on a Debian 11 (Bullseye) server.
Install Elasticsearch on Debian 11 Bullseye
Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following
apt commands in the terminal:
sudo apt update sudo apt upgrade sudo apt install apt-transport-https
Step 2. Installing Java.
Elasticsearch deployment requires that Java 8 or 11 is installed. Run the below commands to install OpenJDK on your system:
sudo apt install default-jdk
Confirm Java installation by checking on the version:
Step 3. Installing Elasticsearch on Debian 11.
Elasticsearch is not available in the standard Debian 11 repositories, now we add the Elasticsearch APT repository to your system:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - sudo sh -c 'echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" > /etc/apt/sources.list.d/elastic-7.x.list'
After that, install the Elasticsearch package using
apt commands below:
sudo apt update sudo apt install elasticsearch
Start and enable the Elasticsearch service:
sudo systemctl enable elasticsearch.service --now
To verify and check if Elasticsearch is running, we can execute the following command:
curl -X GET "localhost:9200"
To view the system message that Elasticsearch logs on your system, type the following command:
sudo journalctl -u elasticsearch
Step 4. Configure Elasticsearch.
By default, Elasticsearch listens only to localhost. To change this, open up the configuration file as follows:
sudo nano /etc/elasticsearch/elasticsearch.yml
Add the following lines at the end of the file:
network.host: 127.0.0.1 http.host: 0.0.0.0 http.port: 9200
Restart the Elasticsearch service with the following command for changes to take effect:
sudo systemctl restart elasticsearch
Step 5. Configure Firewall.
Now enable access to port 9200 from the local firewall:
sudo ufw allow 9200
Congratulations! You have successfully installed Elasticsearch. Thanks for using this tutorial for installing Elasticsearch on Debian 11 (Bullseye) system. For additional help or useful information, we recommend you to check the official Elasticsearch website.