Bootstrap, install and configure ElasticSearch with Chef Solo on an Ubuntu EC2 server
Pull request Compare This branch is even with octoly:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
bootstrap.sh
node.json.example
solo.rb

README.md

Bootstrap, install and configure ElasticSearch with Chef Solo on an Ubuntu EC2 server

This is an adaptation of the great tutorial deploying elasticsearch with chef solo written by Karel Minařík.

It's a simple Rake task that launches an EC2 Instance based on Ubuntu. It currently uses the Ubuntu 12.04 LTS (ami-d0f89fb9), but it should work with other Ubuntu version/AMI. A 25gb EBS volume is attached to the AMI to store the Elasticsearch indexes (size is configurable).

It basically installs and configures Elasticsearch through Chef-solo recipes. Elasticsearch is monitored by Monit and Nginx is used as a proxy.

USAGE

Add a node.json file

cp node.json.example node.json

Add your AWS and NGINX credentials, your EC2 security group and your contact email for Monit (search and replace the term "YOUR_" in the node.json file).

Install gems

bundle install

Finally launch the rake task, don't forget to add a NAME for the ES node, AWS_SSH_KEY_ID which is the name of your AWS Key Pair and SSH_KEY which is the local path to your Key Pair

bundle exec rake create NAME=elastisearch-01 AWS_SSH_KEY_ID=aws_key_pair_name SSH_KEY=path/to/aws_key_pair

TESTING

Add some shell variables

USERNAME=YOUR_NGINX_USERNAME
PASSWORD=YOUR_NGINX_PASSWORD
HOST=YOUR_AWS_HOST
curl http://$USERNAME:$PASSWORD@$HOST:8080

Should returns something like this:

{
  "ok" : true,
  "status" : 200,
  "name" : "elasticsearch-2",
  "version" : {
    "number" : "0.90.3",
    "build_hash" : "5c38d6076448b899d758f29443329571e2522410",
    "build_timestamp" : "2013-08-06T13:18:31Z",
    "build_snapshot" : false,
    "lucene_version" : "4.4"
  },
  "tagline" : "You Know, for Search"
}

Anyway, we can index some documents through the proxy just fine:

curl -X POST "http://$USERNAME:$PASSWORD@$HOST:8080/test_chef_cookbook/document/1" -d '{"title" : "Test 1"}'
curl -X POST "http://$USERNAME:$PASSWORD@$HOST:8080/test_chef_cookbook/document/2" -d '{"title" : "Test 2"}'
curl -X POST "http://$USERNAME:$PASSWORD@$HOST:8080/test_chef_cookbook/document/3" -d '{"title" : "Test 3"}'
curl -X POST "http://$USERNAME:$PASSWORD@$HOST:8080/test_chef_cookbook/_refresh"

Let’s try to perform a search:

curl "http://$USERNAME:$PASSWORD@$HOST:8080/_search?pretty"

Launch another instance:

bundle exec rake create NAME=elastisearch-02 AWS_SSH_KEY_ID=aws_key_pair_name SSH_KEY=path/to/aws_key_pair

When finished open in your browser:

http://$USERNAME:$PASSWORD@$HOST:8080/_plugin/paramedic/

With the EC2 autodiscovery function from elasticsearch, these 2 servers (and thus 2 nodes) are now working together. You can confirm by checking the top left corner you should read "NODES 2 DOCS 3", Hurrah !

Authors

Original code and tutorial by Karel Minařík @karmi

Upgraded and adapted for Ubuntu by:

License

Licensed under MIT. Enjoy!