Tuesday, June 21, 2016

Installing Elasticsearch on linux EC2 server


Elasticsearch is a search server based on apache Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License.

Its is used for Fast, Incisive Search against Large Volumes of Data. This article will help you to install elasticsearch on EC2 server.

Step 1 :  create an running instance on AWS under EC2 service. For more information on creating instance click here.

Step 2 : edit security group for the instance under Network & security section of AWS console.Add folowing rule and save the same

Custom TCP Rule
TCP
   9300
0.0.0.0/0
Custom TCP Rule
TCP
   9200
0.0.0.0/0

These ports are needed for elastic search in addition of 80,443,22 for http, https, ssh etc.

Step 3: follow instruction to install elastic search here
 
Step 4:  run the following command on your ec2 server. Remember you need to be root. if you are not type sudo su.
        cd /etc/init.d/
        chkconfig --add elasticsearch
        /etc/init.d/elasticsearch start
 

Step 5: Avoid future issues

having all the memory being used by an instance this was coming from the fact that the instance was creating some hprof files.
To avoid that run this command :
nano /usr/share/elasticsearch/bin/elasticsearch.in.sh

and put a “#” in front of the this line of the file :
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"

In order that  these changes apply, you must restart  ES with this command :
 
service elasticsearch restart
 
 
Step 6:  test Elasticsearch
Run :
    curl -X GET http://localhost:9200/
 
if you see following result. Elasticsearch is working fine.
 
 









No comments: