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

0
52
views
How To Setup Elasticsearch On RHEL/CentOS 6/7?

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 clusters 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.

[[email protected] 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

[[email protected] 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

[[email protected] kapendra]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.2.tar.gz
[[email protected] kapendra]# tar -xzf elasticsearch-6.4.2.tar.gz
[[email protected] kapendra]# tar -xzf elasticsearch-6.4.2.tar.gz
[[email protected] 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).

[[email protected] kapendra]# useradd elasticsearch
[[email protected] 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.

[[email protected] kapendra]# ulimit -n 65536
[[email protected] kapendra]# ulimit -u 2048

Or you may edit the file to make changes permanent

[[email protected] 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 changes like cluster name or node name to make our single node cluster live.

[[email protected] kapendra]# cd /usr/local/elasticsearch/

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

[[email protected] elasticsearch]# vim conf/elasticsearch.yml

cluster.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.

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

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

[[email protected] kapendra]# su - elasticsearch
[[email protected] ~]$ /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.