{"id":3728,"date":"2014-11-09T15:42:26","date_gmt":"2014-11-09T20:42:26","guid":{"rendered":"http:\/\/hoolihan.net\/blog-tim\/?p=3728"},"modified":"2014-11-10T16:04:07","modified_gmt":"2014-11-10T21:04:07","slug":"running-a-local-elasticsearch-cluster-for-development","status":"publish","type":"post","link":"http:\/\/hoolihan.net\/blog-tim\/2014\/11\/09\/running-a-local-elasticsearch-cluster-for-development\/","title":{"rendered":"Running a Local ElasticSearch Cluster for Development"},"content":{"rendered":"<p><a href=\"http:\/\/www.elasticsearch.org\/\">ElasticSearch<\/a> is a document database built on <a href=\"http:\/\/lucene.apache.org\/\">Lucene<\/a>, a full text-search engine. It clusters and is useful in a variety of scenarios. If you want to run it locally and test some of the clustering feature, here are some things I learned from my experience. <\/p>\n<p>Install with your preferred package manager, or from source. In my case I use <a href=\"http:\/\/brew.sh\/\">homebrew<\/a>, so install is as easy as:<\/p>\n<p><code>brew install elasticsearch<\/code><\/p>\n<p>You can run multiple nodes from one install. First, you will want to tweak the config. For me, the elasticsearch.yml config file was located in \/usr\/local\/Cellar\/elasticsearch\/1.4.0\/config\/, but that may vary based on your OS, package manager, or version.<\/p>\n<p>Mainly, I set a value for cluster. name:<\/p>\n<p><code>cluster.name: some_cluster_name_of_your_choosing<br \/>\nmarvel.agent.enabled: false<\/code><\/p>\n<p>By default, elasticsearch joins any cluster with the same name, so you do not want to run on the default or you will be syncing with other local developers on your network.<\/p>\n<p>Then you want to configure your startup mechanism. For some users, that would mean configuring the elasticsearch file in \/etc\/init.d, but for OS X homebrew users, my startup file is ~\/Library\/LaunchAgents\/homebrew.mxcl.elasticsearch.plist. First, setup extra nodes. In OS X, that means making copies of the LaunchAgent file in the same directory with unique names. It&#8217;s worth noting if you&#8217;re using homebrew, that the original LaunchAgent plist file is a symlink and you&#8217;ll want to copy the contents to a new file. I numbered my extra nodes, so the filenames were homebrew.mxcl.elasticsearch2.plist, and so on. I altered the plist file to have a couple of extra arguments, specified in the ProgramArguments node. I removed the xml nodes that specify keeping the worker alive. The results were:<\/p>\n<script src=\"https:\/\/gist.github.com\/ec1adcd284d6a74c84af.js\"><\/script>\n<p>I set custom node names and ports via the plist file. Note that on a Linux based machine, you would later the service to run multiple ElasticSearch nodes with those custom parameters.<\/p>\n<p>Finally, since I didn&#8217;t want to run those scripts individually each time, I create a script to launch all nodes at once. Note that you&#8217;ll want to add execute permissions and put it somewhere in your path. <\/p>\n<script src=\"https:\/\/gist.github.com\/b8c19e0f9ced5dbd88aa.js\"><\/script>\n<p>Finally, I recommend installing Marvel, particulary for Sense, a nice tool for running commands on ElasticSearch. You can install Marvel with this command in the ElasticSearch root directory (for me, \/usr\/local\/Cellar\/elasticsearch\/1.4.0\/):<\/p>\n<p><code>bin\/plugin -i elasticsearch\/marvel\/latest<\/code><\/p>\n<p>Now you can bring the cluster up with <code>es_cluster<\/code><\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ElasticSearch is a document database built on Lucene, a full text-search engine. It clusters and is useful in a variety of scenarios. If you want to run it locally and test some of the clustering feature, here are some things I learned from my experience. Install with your preferred package manager, or from source. In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55,18],"tags":[],"class_list":["post-3728","post","type-post","status-publish","format-standard","hentry","category-data","category-programming"],"_links":{"self":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts\/3728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/comments?post=3728"}],"version-history":[{"count":0,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/posts\/3728\/revisions"}],"wp:attachment":[{"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/media?parent=3728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/categories?post=3728"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hoolihan.net\/blog-tim\/wp-json\/wp\/v2\/tags?post=3728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}