This is largely a brain dump since I spent some time trying to get elasticsearch working for EC2.
Creating the Instance
- 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.
- 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.
- Launch the instance!
- 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!
- In the installed directory (/usr/share/elasticsearch for RPM) run the following command: bin/plugin -install elasticsearch/elasticsearch-cloud-aws/2.1.0
Within the configuration file (/etc/elasticsearch/elasticsearch.yml) perform the following modifications:
- cluster.name: pick-a-cluster-name
- discovery.type: ec2
- discovery.ec2.host_type: public_ip
- 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