How To Setup Elasticsearch 6.4 On RHEL/CentOS 6/7?

Kapendra Singh
3 min readJun 27, 2021

Originally published at https://kapendra.com.

What is Elasticsearch?

Elasticsearch is a search engine based on Lucene. It is useful in a distributed environment and helps in a multitenant-capable full-text search engine. While you query something from elasticsearch it will provide you with an HTTP web interface and schema-free JSON documents. it provides the ability for full-text search. Elasticsearch is developed in Java and is released as open-source under the terms of the Apache 2 license.

Scenario:

1. Server IP: 192.168.56.101
2. Elasticsearch: Version 6.4
3. OS: CentOS 7.5
4. RAM: 4 GB

Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

With the help of this guide, you will be able to set up Elasticsearch single node cluster on CentOS, Red Hat, and Fedora systems.

Step 1: Install and Verify Java

Java is the primary requirement for installing Elasticsearch. So, make sure you have Java installed on your system.

[root@el1 kapendra]# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

If you don’t have Java installed on your system, then run the below command

[root@el1 kapendra]# yum install java-1.8.0-openjdk

Step 2: Setup Elasticsearch

For this guide, I am downloading the latest elasticsearch tar from its official website so follow the below step

[root@el1 kapendra]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.2.tar.gz
[root@el1 kapendra]# tar -xzf elasticsearch-6.4.2.tar.gz
[root@el1 kapendra]# tar -xzf elasticsearch-6.4.2.tar.gz
[root@el1 kapendra]# mv elasticsearch-6.4.2 /usr/local/elasticsearch

Step 5: Permission and User

We need a user for running elasticsearch (root is not recommended).

[root@el1 kapendra]# useradd elasticsearch
[root@el1 kapendra]# chown -R elasticsearch.elasticsearch /usr/local/elasticsearch/

Step 6: Setup Ulimits

Now to get a Running system we need to make some changes of ulimits else we will get an error like “max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]” so to overcome this issue make below changes you should run.

[root@el1 kapendra]# ulimit -n 65536
[root@el1 kapendra]# ulimit -u 2048

Or you may edit the file to make changes permanent

[root@el1 kapendra]# vim /etc/security/limits.conf
elasticsearch - nofile 65536
elasticsearch soft nofile 64000
elasticsearch hard nofile 64000
elasticsearch hard nproc 4096
elasticsearch soft nproc 4096

Save files using :wq

Step 7: Configure Elasticsearch

Now make some configuration change like cluster name or node name to make our single node cluster live.

[root@el1 kapendra]# cd /usr/local/elasticsearch/

Now, look for the below keywords in the file and change according to you need

[root@el1 elasticsearch]# vim conf/elasticsearch.ymlcluster.name: kapendra-cluster-1
node.name: kapendra-node-1
http.port: 9200

to set this value to your IP or make it 0.0.0.0 id need to be accessible from anywhere from the network. Else put your IP of localhost

network.host: 0.0.0.0

There is one more thing if you have any dedicated mount pint for data then changes the value for

#path.data: /path/to/data to your mount point.

Your configuration should look like the above.

Step 8: Starting Elasticsearch Cluster

As the Elasticsearch setup is completed. Let the start Elasticsearch cluster with elastic search user so first switch to elasticsearch user and then run the cluster

[root@el1 kapendra]# su - elasticsearch
[elasticsearch@el1 ~]$ /usr/local/elasticsearch/bin/elasticsearch
[1] 22278

Step 9: Verify Setup

You have all done it, just need to verify the setup. Elasticsearch works on port default port 9200, open your browser to point your server on port 9200, You will find something like below output

http://localhost:9200 or http://192.168.56.101:9200

with the end of this article, you have successfully set up Elasticsearch single node cluster. In the next few articles, we will try to cover few commands and their setup in the docker container for development environments on local machines.

Originally published at https://kapendra.com.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Kapendra Singh
Kapendra Singh

Written by Kapendra Singh

Love to write technical stuff with personal experience as I am working as a Senior DevOps Specialist. and believe in “every day is a learning day”

No responses yet

Write a response