We Value Your Time – OpenSource Community
We Value Your Time – OpenSource Community

Install Elasticsearch on CentOS and RHEL

Elasticsearch is one of the most popular and flexible platform for distributed and analysis of data in real time. It has a very powerful APIs available which provides so much flexibility in the search. Its popularity is due to its ease of use, powerful features, and scalability.

Step 1: Install and verify Java

You can install the latest OpenJDK with below command:

[root@elastic-search ~]# yum install java-1.8.0-openjdk.x86_64

Verify Java:

[root@elastic-search ~]# java -version 
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Step 2: Downloading and Installing Elasticsearch

Download the rpm from the official Elasticsearch website from CentOs or RHEL

[root@elastic-search opt]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.rpm
--2019-02-07 07:44:09--  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.rpm
Resolving artifacts.elastic.co (artifacts.elastic.co)...,,, ...
Connecting to artifacts.elastic.co (artifacts.elastic.co)||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 91384332 (87M) [application/octet-stream]
Saving to: ‘elasticsearch-6.3.0.rpm’

100%[====================================================================================================>] 91,384,332  70.6MB/s   in 1.2s   

2019-02-07 07:44:12 (70.6 MB/s) - ‘elasticsearch-6.3.0.rpm’ saved [91384332/91384332]

Install the elasticsearch rpm like below:

[root@elastic-search opt]# yum localinstall elasticsearch-6.3.0.rpm
Loaded plugins: fastestmirror
Examining elasticsearch-6.3.0.rpm: elasticsearch-6.3.0-1.noarch
Marking elasticsearch-6.3.0.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.noarch 0:6.3.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                            Arch                        Version                       Repository                                 Size
 elasticsearch                      noarch                      6.3.0-1                       /elasticsearch-6.3.0                      136 M

Transaction Summary
Install  1 Package

Total size: 136 M
Installed size: 136 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Creating elasticsearch group... OK
Creating elasticsearch user... OK
  Installing : elasticsearch-6.3.0-1.noarch                                                                                               1/1 
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch
  Verifying  : elasticsearch-6.3.0-1.noarch                                                                                               1/1 

  elasticsearch.noarch 0:6.3.0-1                                                                                                              


Enable elasticsearch service on startup so it will start automatically on the desired run level.

[root@elastic-search opt]# sudo systemctl daemon-reload
[root@elastic-search opt]# sudo systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

Step 3: Configuring Elasticsearch

elasticsearch.yml : Elasticsearch server settings. This is where all options, except those for logging, are stored, which is why we are mostly interested in this file.

logging.yml: Provides configuration for logging. In the beginning, you don’t have to edit this file. You can leave all default logging options. You can find the resulting logs in /var/log/elasticsearch by default.

Edit /etc/elasticsearch/elasticsearch.yml to configure Elasticsearch settings

# Use a descriptive name for the node:
 node.name: node-1
# Use a descriptive name for your cluster:
cluster.name: elastic-cluster

Use network.host for configuring your server IP bind address

# Set the bind address to a specific IP (IPv4 or IPv6):

Start Elasticsearch cluster through systemctl

[root@elastic-search opt]# systemctl start elasticsearch

Step 4: Test Elasticsearch cluster

Elasticsearch will be run on port 9200. We can test it with curl, with simple GET request

[root@elastic-search opt]# curl -X GET
  "name" : "node-1",
  "cluster_name" : "elastic-cluster",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "6.3.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "424e937",
    "build_date" : "2018-06-11T23:38:03.357887Z",
    "build_snapshot" : false,
    "lucene_version" : "7.3.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  "tagline" : "You Know, for Search"

U may also like Install Kibana on CentOS and RHEL

Leave a comment

Your email address will not be published. Required fields are marked *