How to Install Elasticsearch on a Linux Machine (Red Hat Family): A Step-by-Step Guide for Beginners
If you’re familiar with Red Hat-based Linux distributions, such as CentOS, Fedora, or Red Hat Enterprise Linux, you may know that package installation can differ from Debian-based distributions. In this guide, I’ll walk you through installing Elasticsearch on a Red Hat family Linux distribution.
Prerequisites
Ensure you’re running a Red Hat-based machine with at least 1 GB of RAM and 10 GB of free storage. An internet connection is also essential to fetch required packages.
1. Update Your Linux Machine
It’s always a good starting point to update your system:
bash
sudo yum update
2. Install Java
Elasticsearch needs Java to operate:
bash
sudo yum install java-11-openjdk-devel
After the installation, you can check the Java version:
bash
java -version
3. Download and Install Elasticsearch
Elastic provides an RPM repository for their software installation on Red Hat family:
bash
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
Then, create a file named elasticsearch.repo
under /etc/yum.repos.d/
:
bash
sudo nano /etc/yum.repos.d/elasticsearch.repo
And input the following lines:
makefile
[elasticsearch-7.x] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
You can then install Elasticsearch:
bash
sudo yum install elasticsearch
4. Configure Elasticsearch
Open Elasticsearch’s configuration file:
bash
sudo nano /etc/elasticsearch/elasticsearch.yml
Adjust or add the following lines:
yaml
network.host: 0.0.0.0 http.port: 9200
Save and close the file.
5. Start Elasticsearch
Kick-start Elasticsearch using:
bash
sudo systemctl start elasticsearch
And to make it boot at startup:
bash
sudo systemctl enable elasticsearch
6. Test the Installation
To ensure Elasticsearch is up and running:
bash
curl -X GET "localhost:9200/"
If you receive a response detailing Elasticsearch’s version, you’re all set!
Conclusion
You’ve successfully installed Elasticsearch on a Red Hat family Linux distribution! As always, refer to the official documentation for advanced settings and updates.