Installing ElasticSearch on Amazon EC2

I wanted to set up ElasticSearch on Amazon EC2 and these are the steps that i followed to do that
  • Connect to your Amazon EC2 instance using SSH and execute following command to download ElasticSearch v 90.9 on my instance
    
    wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.9.tar.gz
    
    It took less than a minute to download the elasticsearch binary on the instance
  • Next i executed following command to unzip the elasticsearch-0.90.9.tar.gz
    
    tar -xf elasticsearch-0.90.9.tar.gz
    
  • After extracting the elasticsearch binaries start it by executing following command
    
    elasticsearch-0.90.9/bin/elasticsearch –f
    
  • After starting the ElasticSearch instance i could use the ES REST API from the SSH console on the same instance
    
    curl -XGET http://localhost:9200/_search
    
  • But since i want to access it from my local machine/outside the instance i had to open the 9200 port on that instances firewall that i could do by changing the security group and adding 9200 and 9300 ports to it
  • Then you can use the public DNS for your EC2 instance and query the REST instance from your local machine like this
    
    curl -XGET http://<yourinstancename>.us-west-1.compute.amazonaws.com:9200/_search
    

2 comments:

Ashish Saraf said...

Hi Sunil , can you share the steps involved in launching a instance , especially security group as I am unable to issue wget command

Varsity Jackets said...

This is a helpful guide to setting up an older version of Elasticsearch on EC2, but keep in mind there are security considerations. Opening ports exposes the instance and using a current version is recommended. For production environments, consider a VPC or a managed service like Amazon OpenSearch Service for improved security and scalability.