How To Install Elasticsearch on Rocky Linux 8
In this tutorial, we will show you how to install Elasticsearch on Rocky Linux 8. For those of you who didn’t know, Elasticsearch is a free and open-source analytics engine used for storing, searching, and analyzing big volumes of data in real-time. Elasticsearch is well-liked and popular amongst sysadmins and developers as it is a mighty search engine based on the Lucene library. Elasticsearch is just one part of the ELK stack (Elasticsearch, Logstash, and Kibana) which constitute an open-source log analytics platform.
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 Elasticsearch on Rocky Linux. 8.
Prerequisites
- A server running one of the following operating systems: Rocky Linux 8.
- 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).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Elasticsearch on Rocky Linux 8
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf check-update sudo dnf update
Step 2. Installing Java on Rocky Linux 8.
By default, Java is not available on Rocky Linux 8. base repository. Now run the following command below to install the OpenJDK 11 to your system:
sudo dnf install java-11-openjdk
Use the following command to check whether Java is installed:
java -version
Step 3. Installing Elasticsearch on Rocky Linux 8.
By default, Elasticsearch is not available on Rocky Linux 8 base repository. Now we add the Elasticsearch RPM repository to your Rocky Linux system:
nano /etc/yum.repos.d/elasticsearch.repo
Add the following file:
[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
Save and close the file then, install the ElasticSearch package with the following command below:
sudo dnf install --enablerepo=elasticsearch elasticsearch
By default, the Elasticsearch service is disabled on boot and not active. Now we enable Elasticsearch (to start automatically upon system boot), start, and verify the status using the commands below:
sudo systemctl start elasticsearch sudo systemctl enable elasticsearch sudo systemctl status elasticsearch
Step 4. Configure Elasticsearch.
Now edit the Elasticsearch configuration file “/etc/elasticsearch/elasticsearch.yml
” and set the network.host
to localhost:
nano /etc/elasticsearch/elasticsearch.yml
Add the following configuration:
cluster.name: idroot-cluster node.name: node-1 path.data: /var/lib/elasticsearch network.host: 127.0.0.1
Save and close the file then restart the ElasticSearch service:
sudo systemctl start elasticsearch
Step 5. Testing Elasticsearch.
Once successfully installed, Now we test and see if the installed Elasticsearch is working. Elasticsearch should be running on port 9200. Test this using the curl command as below:
curl -X GET "localhost:9200/"
Output:
[root@idroot.us ~]# curl -X GET "localhost:9200/" { "name" : "node-1", "cluster_name" : "idroot-cluster", "cluster_uuid" : "G0Gde46CQmeilanaBCp9EBmw", "version" : { "number" : "7.13.0", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "5ciye1c6fkud260ce95akp023559635c6f3", "build_date" : "2022-03-19T22:06:26.081071330CI", "build_snapshot" : false, "lucene_version" : "8.8.2", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
Congratulations! You have successfully installed Elasticsearch. Thanks for using this tutorial for installing Elasticsearch on your Rocky Linux 8 system. For additional help or useful information, we recommend you check the official Elasticsearch website.