Thursday, September 3, 2020

ElasticSearch Installation in CentOS and RHEL

#Elasticsearch  #Installation #CentOS #RHEL

What is Elasticsearch?

      Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine tuned relevancy, and powerful analytics that scale with ease. 

Now, we will see how to install the Elasticsearch in CentOS and RHEL servers. Basically, we have to install JAVA has to be prerequisite for Elasticsearch. So first we will install Java and setup the environment variables and then install the Elasticsearch with respect to basic production configuration.

Prerequisite:

To setup the Elasticsearch we require Java need to installed in Elasticsearch stack, using following steps we will be able to install the java.

Step 1:  Installing the openjdk 1.8 in the elasticsearch server
    
     a) update the server and install java with below command.

          $ sudo yum update 
          $ sudo yum install java-1.8.0-openjdk -y

     b) Once installed the java, check the java version using below command

          $ sudo java -version

     c) After validating the java version , configure the java home to use in run time in .bashrc file

          $ sudo update-alternatives --config java

          $ sudo vi .bashrc
           export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre/bin/java
 
     d) Execute the .bashrc to enable the java home 

          $ source .bashrc

Elasticsearch Setup:

Once the Java setup is completed, we need to setup the elasticsearch using below steps

Step 2: Before installing Elasticsearch, add the elastic.co key to the server.

         $ rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

Step 3: Now, Download the Latest RPM of Elasticsearch


Step 4: Install the Downloaded RPM

       $ rpm -ivh elasticsearch-7.9.1-x86_64.rpm

Step 5:  Now go to the configuration directory and edit the elasticsearch.yml configuration file. Enable the below lines in configuration file

      $ cd /etc/elasticsearch/
      $ vim elasticsearch.yml
             bootstrap.memory_lock: true
             xpack.monitoring.enabled: true
             network.host: localhost
             http.port: 9200
             http.max_content_length: 1.6gb

     And Save the file.

Step 6: Now edit the elasticsearch.service file for the memory lock configuration. Uncomment LimitMEMLOCK line or if it is not there please add this line to limit session

     $ vim /usr/lib/systemd/system/elasticsearch.service

           LimitMEMLOCK=infinity

Step 7: Edit the sysconfig configuration file for Elasticsearch.  Uncomment line 60 and make sure the value is 'unlimited'.

     $ vim /etc/sysconfig/elasticsearch
               MAX_LOCKED_MEMORY=unlimited    
       MAX_OPEN_FILES=65535
               MAX_MAP_COUNT=262144
Step 8: Reload systemd, enable Elasticsearch to start at boot time, then start the service.

     $ sudo systemctl daemon-reload
     $ sudo systemctl enable elasticsearch
     $ sudo systemctl start elasticsearch

Step 9: To check the elasticsearch is running or not. Check the listening port with 9200

     $ netstat -lntp 

Step 10: Then check the memory lock to ensure that mlockall is enabled,

     $ curl -XGET 'localhost:9200/_nodes?filter_path=**.mlockall&pretty'
     $ curl -XGET 'localhost:9200/?pretty'




                                                                                                            Next: Kibana Installation in CentOS

No comments:

Post a Comment

Featured Post

Ansible Tool Introduction

                                                                                                                                    Next ...