Ruby On Rails : EngineYard : Setup elastic search in multi/single server architecture

Engineyard uses CHEF recipes to configure the server instances. You must enable the appropriate chef-recipes according to type of server environment you require.

There are several ways to use this recipe, depending on your environment.

  1. On a solo environment
    include_recipe "elasticsearch::non_util"
  2. On a small cluster: run Elasticsearch on app_master
    include_recipe "elasticsearch::non_util"
  3. On a cluster with dedicated util instances for Elasticsearch
    include_recipe "elasticsearch"

    Name the Elasticsearch instances elasticsearch_0, elasticsearch_1, etc.

In all cases, make sure you create /data/#{appname}/shared/config/elasticsearch.yml on all application and utility instances so that the application knows how to connect to your elasticsearch server(s).

Moreover, you need to symlink the file
/data/#{appname}/shared/config/elasticsearch.yml to
/data/#{appname}/current/config/elasticsearch.yml
just before the application restarts. i.e. you need to put the following code inside deploy hook deploy/after_restart.rb.

# Make sure you create /data/#{appname}/shared/config/elasticsearch.yml on all application and
# utility instances so that the application knows how to connect to your elasticsearch server(s).
on_app_servers_and_utilities do
   # link elasticsearch.yml in current/config to shared/config
   run "ln -nfs #{config.shared_path}/config/elasticsearch.yml #{config.release_path}/config/elasticsearch.yml"
end

Verify

On your instance, run:

curl localhost:9200

Results should be simlar to:

{
  "status" : 200,
  "name" : "Man-Thing",
  "cluster_name" : "YourEnvironmentName",
  "version" : {
    "number" : "1.4.0",
    "build_hash" : "bc94bd81298f81c656893ab1ddddd30a99356066",
    "build_timestamp" : "2014-11-05T14:26:12Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.2"
  },
  "tagline" : "You Know, for Search"
}

Source:  https://github.com/engineyard/ey-cloud-recipes/tree/master/cookbooks/elasticsearch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s