Install and Configure Elasticsearch on Debian 11

In this guide, we want to teach you How To Install and Configure Elasticsearch on Debian 11.

Elasticsearch is a distributed, open-source search and analytics engine built on Apache Lucene and developed in Java. It started as a scalable version of the Lucene open-source search framework and then added the ability to horizontally scale the Lucene indices.

Elasticsearch allows you to store, search, and analyze huge volumes of data quickly and in near real-time and give back answers in milliseconds. It’s able to achieve fast search responses because instead of searching the text directly, it searches an index. It uses a structure based on documents instead of tables and schemas and comes with extensive REST APIs for storing and searching the data. At its core, you can think of Elasticsearch as a server that can process JSON requests and give you back JSON data.

Install and Configure Elasticsearch on Debian 11

To install Elasticsearc, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Debian 11.

Now follow the steps below to complete this guide.

Install Java on Debian 11

Elasticsearch needs Java to be installed on your server.

First, update your local package index with the following command:

sudo apt update

Then, use the following command to install the OpenJDK 11 on your Debian 11:

sudo apt install openjdk-11-jdk

Verify your Java installation with the following command:

java -version

In your output you will see:

Output
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-post-Debian-1deb11u1, mixed mode, sharing)

Also, you need to be sure the JAVA_HOME environment variable is configured. You can use the following command:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 

Install Elasticsearch on Debian 11

To install Elasticsearch, you need to add its repository to your Debian 11.

Run the following command to install the apt transport HTTPS:

sudo apt install apt-transport-https 

The Debian package for Elasticsearch v8.3.1 can be downloaded from the website and installed as follows: 

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.3.1-amd64.deb
sudo dpkg -i elasticsearch-8.3.1-amd64.deb
When your installation is completed, start and enable your Elasticsearch service with the following commands:
# sudo systemctl start elasticsearch.service
# sudo systemctl enable elasticsearch.service
Verify your service is active and running on your server:
sudo systemctl status elasticsearch.service
Output
● elasticsearch.service - Elasticsearch
Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor>
Active: active (running) since Wed 2022-07-06 08:33:50 EDT; 2min 6s ago
Docs: https://www.elastic.co
Main PID: 4217 (java)
Tasks: 85 (limit: 2340)
Memory: 1.4G
CPU: 1min 3.733s
CGroup: /system.slice/elasticsearch.service
├─4217 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+U>
├─4277 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.c>
└─4301 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x

Configure Elasticsearch

At this point, you need to make some basic configuration changes.

Open the Elasticsearch configuration file with your favorite text editor, here we use vi:

sudo vi /etc/elasticsearch/elasticsearch.yml 

At the file, search for the network.host directive and uncomment it by removing the hashtag and setting it to 0.0.0.0 to listen on all interfaces and make it available publicly. You can use your LAN address for LAN access only:

network.host: 0.0.0.0

Also, find the lines below and uncomment them and replace the names with your own:

cluster.name: myCluster1
node.name: "myNode1"

Then, find the discovery.seed_hosts directive and set it to your Node name:

discovery.seed_hosts: ["myNode1"]

When you are done, save and close the file.

Now restart Elasticsearch on Debian 11 with the following command:

sudo systemctl restart elasticsearch.service 
Here you can connect to your Elasticsearch by typing your server’s IP address in your web browser followed by 9200:
http://server-ip-address:9200

Conclusion

At this point, you learn to Install and Configure Elasticsearch on Debian 11.
Hope you enjoy using it.
Please subscribe to us on Facebook and Twitter.
Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular