How To Install ElasticSearch on CentOS 7 Linux
Enjoying this content? Subscribe to the Channel!
Mastering Data Search: A Beginner’s Guide to Installing ElasticSearch on CentOS 7
Welcome back to Darren’s Tech Tutorials!
If you’re ready to dive into the world of powerful, scalable search and analytics, ElasticSearch is the tool you need. It’s an incredibly versatile open-source engine that forms the heart of the popular ELK stack (ElasticSearch, Logstash, Kibana).
This guide is a step-by-step translation of our popular video tutorial, designed specifically for beginners on a CentOS 7 system. We’ll cover everything from fulfilling the prerequisite Java dependencies to starting the service and locating the crucial configuration file.
Ready to get searching? Let’s begin the installation!
Step 1: Installing the Java Prerequisite (OpenJDK)
ElasticSearch is built on Java, so the first and most crucial step is ensuring you have the Java Runtime Environment (JRE) installed on your CentOS 7 server. We recommend using OpenJDK version 1.8 or later.
This command will download and install the required packages using yum:
sudo yum install java-1.8.0-openjdk -y
Once the installation is complete, you can verify that Java is correctly installed by running:
java -version
You should see output confirming the version of OpenJDK now running on your system.
Step 2: Downloading the ElasticSearch RPM Package
The easiest way to install ElasticSearch on a Red Hat-based system like CentOS 7 is by using the official RPM package. Using the package manager ensures that all necessary dependencies are handled smoothly.
We will use the wget utility to pull the latest stable version of the ElasticSearch RPM file directly to our server.
Note: Always check the official Elastic website for the absolute latest version number if you are installing in a production environment.
For this tutorial, use the following generic command structure (replace the URL if you need a specific version):
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-<VERSION>.rpm
Step 3: Installing ElasticSearch on CentOS 7
With the RPM file downloaded, the installation is straightforward. We will use the rpm command to install the package.
Navigate to the directory where you downloaded the file (usually your home directory) and execute the installation command:
sudo rpm -ivh elasticsearch-<VERSION>.rpm
The installation process will place all necessary files, binaries, and service configuration files in their correct locations on your CentOS system.
Step 4: Starting the ElasticSearch Service
The installation created a service file, allowing us to manage ElasticSearch using the systemd service manager (systemctl).
We need to perform two essential tasks: start the service immediately, and enable it so that ElasticSearch automatically starts every time the server boots up.
- Reload the systemd daemon (if necessary) and start the service:
sudo systemctl daemon-reload
sudo systemctl start elasticsearch
- Enable the service for bootup:
sudo systemctl enable elasticsearch
- Verify the status:
You can check if the service is running correctly using the status command:
sudo systemctl status elasticsearch
You should see an output indicating the service is active (running).
Testing the Installation
To confirm that ElasticSearch is running and accessible on its default port (9200), use curl to query the service from your local host:
curl -X GET "localhost:9200"
If successful, you will receive a JSON response containing metadata about your running ElasticSearch node, including its cluster name and version number. Success!
Step 5: Locating the Configuration File (elasticsearch.yml)
ElasticSearch is highly configurable, and most adjustments—such as setting the network host, cluster name, or memory limits—are done through its primary configuration file.
On CentOS 7, the configuration files are located in the following standard path:
/etc/elasticsearch/
The main configuration file is elasticsearch.yml.
To make changes, you can use your preferred text editor (like vi or nano). For example, to open the file using vi:
sudo vi /etc/elasticsearch/elasticsearch.yml
Pro Tip: If you edit this file to change network settings (e.g., binding ElasticSearch to an external IP address), remember that you must restart the ElasticSearch service for the changes to take effect:
sudo systemctl restart elasticsearch.
Conclusion: You’ve Installed ElasticSearch on CentOS 7!
You did it! In just a few easy steps, you successfully installed all necessary dependencies and set up a functional ElasticSearch node on your CentOS 7 server. You now have the power to index, search, and analyze vast amounts of data!
Now it’s time to start experimenting with indexing data and exploring Kibana (the visualization component of the ELK stack).
If you found this tutorial helpful, be sure to like this post and subscribe to Darren’s Tech Tutorials on YouTube for more clear, accessible technology guides.
Want to keep those Linux commands straight? Don’t forget to grab your Free Linux Cheat Sheet to keep handy during your tech adventures! Happy searching!