How to Install Elasticsearch on a Linux Machine (Debian-based): A Step-by-Step Guide for Beginners
Elasticsearch is among the world’s leading search and data analytics engines. For anyone involved in programming or data analytics, knowing how to set it up is a crucial skill. In this article, I’ll guide you through a detailed procedure on installing Elasticsearch on a Debian-based Linux machine. This guide is optimized for beginners, so if you’ve never touched Linux or Elasticsearch before, don’t fret!
Prerequisites
Before diving in, ensure you have a Debian-based Linux machine with at least 1 GB of RAM and 10 GB of free space. An active internet connection is needed to download required packages.
1. Update Your Linux Machine
Always start by updating system packages. Open a terminal and punch in:
bash
sudo apt update && sudo apt upgrade
2. Install Java
Elasticsearch requires Java to function. Here’s how you can install it:
bash
sudo apt install openjdk-11-jdk
Post-installation, verify the Java version:
bash
java -version
3. Download and Install Elasticsearch
You can download and install Elasticsearch using the apt
package provided by Elastic:
bash
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - sudo apt-get install apt-transport-https echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list sudo apt-get update && sudo apt-get install elasticsearch
4. Configure Elasticsearch
Before starting Elasticsearch, it’s a good practice to make some basic configurations:
bash
sudo nano /etc/elasticsearch/elasticsearch.yml
Locate and adjust the following lines (if they’re missing, just add them):
yaml
network.host: 0.0.0.0 http.port: 9200
Save and close the file.
5. Start Elasticsearch
Fire up the Elasticsearch service with:
bash
sudo systemctl start elasticsearch
To have Elasticsearch start up during boot:
bash
sudo systemctl enable elasticsearch
6. Test the Installation
To check that Elasticsearch was installed correctly:
bash
curl -X GET "localhost:9200/"
You should see a response detailing Elasticsearch’s version and node information.
Conclusion
Congratulations, you now have Elasticsearch running on your Debian-based Linux machine! Always remember to consult the official documentation for deeper insights and potential updates.