This tutorial discusses how to install ElasticSearch 7.x on CentOS 7 / RHEL 7. Elasticsearch is an open source search and analytics engine that allows you to store, search, and analyze big volumes of data in real time. Elasticsearch powers millions of Applications that rely on intensive search operations such as e-commerce platforms and big data applications.
The latest release of ElasticSearch as of this article update is 7. We will cover the minimum steps you’ll need to install ElasticSearch 7 on CentOS 7 / RHEL 7 Linux system. So let’s get started.
Step 1: Update the system
The server you’re working on should be updated before you install ElasticSearch 7.x on CentOS 7 / RHEL 7. Just run the commands below to update it.
sudo yum -y update
sudo rebootStep 2: Install Java / OpenJDK
ElasticSearch requires Java installed for it to run. The default Java installable on CentOS 7 / RHEL 7 is Java 8. Here are the commands to use for the installation.
sudo yum -y install vim java-11-openjdk java-11-openjdk-develConfirm installation by checking version of Java:
$ java -version
openjdk version "11.0.16.1" 2022-08-12 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.16.1.1-1.el7_9) (build 11.0.16.1+1-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.16.1.1-1.el7_9) (build 11.0.16.1+1-LTS, mixed mode, sharing)Step 3: Add ElasticSearch Yum repository
Add the repository for downloading ElasticSearch 7 packages to your CentOS 7 system.
cat <<EOF | sudo tee /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOFIf you want to install Elasticsearch 6, replace all occurrences of 7 with 6. Once the repository is added, clear and update your YUM package index.
sudo yum clean all
sudo yum makecacheStep 4: Install ElasticSearch 7 package
Finally install ElasticSearch 7.x on your CentOS 7 / RHEL 7 machine. Note that we’ve added an open source repository. Commercial flavor is available on the other repository.
sudo yum -y install elasticsearch-ossConfirm ElasticSearch 7 installation:
$ rpm -qi elasticsearch-oss
Name        : elasticsearch-oss
Epoch       : 0
Version     : 7.10.2
Release     : 1
Architecture: x86_64
Install Date: Tue 18 Oct 2022 07:10:22 PM UTC
Group       : Application/Internet
Size        : 420252496
License     : ASL 2.0
Signature   : RSA/SHA512, Wed 13 Jan 2021 03:45:21 AM UTC, Key ID d27d666cd88e42b4
Source RPM  : elasticsearch-oss-7.10.2-1-src.rpm
Build Date  : Wed 13 Jan 2021 12:54:36 AM UTC
Build Host  : packer-virtualbox-iso-1600176624
Relocations : /usr
Packager    : Elasticsearch
Vendor      : Elasticsearch
URL         : https://www.elastic.co/
Summary     : Distributed RESTful search engine built for the cloud
...Configure Java memory Limits
You can set JVM options like memory limits by editing the file: /etc/elasticsearch/jvm.options
Example below sets initial/maximum size of total heap space
$ sudo vi /etc/elasticsearch/jvm.options
.....
-Xms1g
-Xmx1gIf your system has less memory, you can configure it to use small megabytes of ram.
-Xms256m
-Xmx512mStart and enable elasticsearch service on boot:
sudo systemctl enable --now elasticsearchConfirm that the service is running.
$ systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-10-18 19:11:16 UTC; 22s ago
     Docs: https://www.elastic.co
 Main PID: 1687 (java)
   CGroup: /system.slice/elasticsearch.service
           └─1687 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true...
Oct 18 19:11:03 cent7.mylab.io systemd[1]: Starting Elasticsearch...
Oct 18 19:11:16 cent7.mylab.io systemd[1]: Started Elasticsearch.Check if you can connect to ElasticSearch Service.
$ curl http://127.0.0.1:9200 
{
  "name" : "cent7.mylab.io",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "hwrxesk0S8CtFo8V5zYNBg",
  "version" : {
    "number" : "7.10.2",
    "build_flavor" : "oss",
    "build_type" : "rpm",
    "build_hash" : "747e1cc71def077253878a59143c1f785afa92b9",
    "build_date" : "2021-01-13T00:42:12.435326Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}You should be able to create an index with curl.
$ curl -X PUT "http://127.0.0.1:9200/test_index"
{"acknowledged":true,"shards_acknowledged":true,"index":"test_index"}Step 5: Install Kibana 7 on CentOS 7 / RHEL 7
Related ElasticSearch Packages such as Kibana, Logstash e.t.c can be installed from the repository added.
sudo yum install kibana-oss logstashAfter a successful installation, configure Kibana:
$ sudo vi /etc/kibana/kibana.yml
server.host: "0.0.0.0"
server.name: "kibana.example.com"
elasticsearch.url: "http://localhost:9200"Change other settings as desired then start kibana service:
sudo systemctl enable --now kibanaIf you have an active firewall, you’ll need to allow access to Kibana port:
sudo firewall-cmd --add-port=5601/tcp --permanent
sudo firewall-cmd --reloadAccess http://ip-address:5601 to open Kibana Dashboard:
 
     
     
    
     
     
    