How to install Elasticsearch on EC2 with Amazon Linux

Published 2014-04-16 on Farid Zakaria's Blog

This is largely a brain dump since I spent some time trying to get elasticsearch working for EC2.


Creating the Instance

  1. Create an IAM role with the needed credentials for the elasticsearch aws plugin. For now, I didn't mess with setting up the fine grained policy and just opted for 'power-user'. A good follow up would be to share a default policy that we can send as a pull-request to the plugin Github.
  2. Create a security group which has at least port 22, 80, 2003 and 2004 open. I'm not sure the complete difference between 2003 and 2004.
  3. Launch the instance!

Installing Elasticsearch

  1. I opt-ed to install Elasticsearch via the RPM because it includes a chkconfig script to start Elasticsearch as a service. You can download the rpm here. Do not turn it on yet!
  2. In the installed directory (/usr/share/elasticsearch for RPM) run the following command: bin/plugin -install elasticsearch/elasticsearch-cloud-aws/2.1.0

Configuring Elasticsaerch

Within the configuration file (/etc/elasticsearch/elasticsearch.yml) perform the following modifications:

  1. pick-a-cluster-name
  2. discovery.type: ec2
  3. discovery.ec2.host_type: public_ip
  4. discovery.ec2.groups:
  5. discovery.ec2.ping_timeout: 5m

The security group option is important otherwise the plugin will cause Elasticsearch to try and discover all hosts within that region and fail if they do not have elasticsearch. Limiting the search to only instances with the specified security group will fix that!


sudo service elasticsearch start