DebianDebian Based

How To Install Elasticsearch on Debian 12

Install Elasticsearch on Debian 12

In this tutorial, we will show you how to install Elasticsearch on Debian 12. Elasticsearch, a highly scalable open-source full-text search and analytics engine, has become a cornerstone in the realm of data analysis and search operations. Its ability to store, search, and analyze large volumes of data quickly and in near real-time has made it a go-to solution for many businesses and organizations.

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 the step-by-step installation of the Elasticsearch on a Debian 12 (Bookworm).

Prerequisites

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You will need an active internet connection to download the Elasticsearch package.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Elasticsearch on Debian 12 Bookworm

Step 1. Keeping your system up-to-date is a fundamental best practice in system administration. It ensures that you have the latest security patches, bug fixes, and software features. To update your package lists for upgrades and new package installations, open your terminal and execute the following command:

sudo apt update
sudo apt upgrade

 This command fetches the latest updates from all configured sources in your Debian system.

Step 2. Installing Java.

Elasticsearch is built using Java, and hence, a compatible Java version is a prerequisite for its operation. For this guide, we will install OpenJDK-11, a free and open-source implementation of the Java Platform, Standard Edition (Java SE). Execute the following command to install OpenJDK-11:

sudo apt install openjdk-11-jdk

Once the installation is complete, you can verify it by checking the Java version:

java -version

Step 3. Installing Elasticsearch on Debian 12.

To install Elasticsearch, we first need to add its repository to our system. This process involves importing the GPG key for Elasticsearch, which ensures the authenticity and integrity of the software packages. Execute the following command to import the GPG key:

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

Next, add the Elasticsearch repository to your system with the following command:

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

This command adds the repository to your system’s list of sources, enabling you to install Elasticsearch directly using the apt package manager.

With the Elasticsearch repository added to your system, you can now proceed with the installation. First, update your package lists again to fetch the latest packages from the newly added Elasticsearch repository:

sudo apt update

Then, install Elasticsearch with the following command:

sudo apt install elasticsearch

This command installs Elasticsearch and all its dependencies. Once the installation is complete, you can verify it by checking the Elasticsearch version:

/usr/share/elasticsearch/bin/elasticsearch --version

Step 4. Configuring Elasticsearch.

After installing Elasticsearch, it’s time to configure it according to your needs. The main configuration file for Elasticsearch is located at /etc/elasticsearch/elasticsearch.yml. Open this file in a text editor of your choice:

sudo nano /etc/elasticsearch/elasticsearch.yml

In this file, you can configure various settings like the number of shards and replicas, the network host, and the maximum memory allocation. Make sure to save and close the file after making any changes.

Once you have configured Elasticsearch, you can start the service using the following command:

sudo systemctl start elasticsearch

This command starts the Elasticsearch service. To ensure that Elasticsearch starts automatically at boot, enable it with the following command:

sudo systemctl enable elasticsearch

Step 5. Configure Firewall.

First, ensure that UFW is installed on your system. If it’s not, you can install it using the following command:

sudo apt install ufw

Once UFW is installed, you can configure it to allow traffic on port 9200. This is the default port that Elasticsearch uses for HTTP communication. Use the following command to open this port:

sudo ufw allow 9200/tcp

After setting the rule, you need to enable the firewall if it’s not already enabled. You can do this with the following command:

sudo ufw enable

Step 6. Testing the Installation.

After starting the Elasticsearch service, it’s a good idea to test the installation to ensure everything is working as expected. You can request a cluster health status report from Elasticsearch using the following command:

curl -X GET "localhost:9200/_cat/health?v&pretty"

If Elasticsearch is running correctly, this command will return a report detailing the health status of your Elasticsearch cluster.

Congratulations! You have successfully installed Elasticsearch. Thanks for using this tutorial to install the latest version of Elasticsearch on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Elasticsearch website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button