Skip to content

Commit

Permalink
fixed a bug in elasticsearch.in.sh (conf dir was pointing to work dir…
Browse files Browse the repository at this point in the history
…), rakefile is a little cleaner and easier to understand, adding notes for upcoming blog post
  • Loading branch information
Jacob Perkins committed Jan 23, 2011
1 parent 0aa2b10 commit 22da118
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
25 changes: 12 additions & 13 deletions Rakefile
@@ -1,13 +1,12 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby


require 'rubygems' require 'rubygems'
require 'wukong'
require 'configliere' ; Configliere.use(:commandline, :env_var, :define) require 'configliere' ; Configliere.use(:commandline, :env_var, :define)


WORK_DIR=File.expand_path(File.dirname(__FILE__)) WORK_DIR=File.expand_path(File.dirname(__FILE__))
Settings.define :src, :default => "#{WORK_DIR}/src", :description => "Java source dir" Settings.define :src, :default => "#{WORK_DIR}/src", :description => "Java source dir"
Settings.define :target, :default => "#{WORK_DIR}/build", :description => "Build target, this is where compiled classes live" Settings.define :target, :default => "#{WORK_DIR}/build", :description => "Build target, this is where compiled classes live"
Settings.define :main_class, :default => "ElasticBulkLoader", :description => "Main java class to run" Settings.define :jar_name, :default => "wonderdog", :description => "Name of the target jar"
Settings.define :hadoop_home, :default => "/usr/lib/hadoop", :description => "Path to hadoop installation", :env_var => "HADOOP_HOME" Settings.define :hadoop_home, :default => "/usr/lib/hadoop", :description => "Path to hadoop installation", :env_var => "HADOOP_HOME"
Settings.define :es_home, :default => "/usr/local/share/elasticsearch", :description => "Path to elasticsearch installation",:env_var => "ES_HOME" Settings.define :es_home, :default => "/usr/local/share/elasticsearch", :description => "Path to elasticsearch installation",:env_var => "ES_HOME"
Settings.resolve! Settings.resolve!
Expand All @@ -31,20 +30,20 @@ end


def srcs options def srcs options
sources = Dir[ sources = Dir[
"#{options.src}/*.java", "#{options.src}/**/*.java",
].inject([]){|sources, src| sources << src; sources} ].inject([]){|sources, src| sources << src; sources}
sources.join(' ') sources.join(' ')
end end


# jar_dir = File.join(options.target, options.jar_name)
# FIXME: Needs to be idempotent ... directory jar_dir
#
task :compile do task :compile => jar_dir do
puts "Compiling #{options.src} ..." sh "javac -cp #{classpath(options)} -d #{jar_dir} #{srcs(options)}"
snakeized = options.main_class.underscore end
mkdir_p File.join(options.target, snakeized)
system "javac -cp #{classpath(options)} -d #{options.target}/#{snakeized} #{srcs(options)}" task :jar => :compile do
system "jar -cvf #{options.target}/#{snakeized}.jar -C #{options.target}/#{snakeized} . " sh "jar -cvf #{jar_dir}.jar -C #{jar_dir} . "
end end


task :default => [:compile] task :default => [:jar]
2 changes: 1 addition & 1 deletion config/elasticsearch.in.sh
@@ -1,4 +1,4 @@
export ES_CONF_DIR=${ES_WORK_DIR-/etc/elasticsearch} export ES_CONF_DIR=${ES_CONF_DIR-/etc/elasticsearch}
export ES_WORK_DIR=${ES_WORK_DIR-/mnt/elasticsearch/work} export ES_WORK_DIR=${ES_WORK_DIR-/mnt/elasticsearch/work}
export ES_DATA_DIR=${ES_DATA_DIR-/mnt/elasticsearch/data} export ES_DATA_DIR=${ES_DATA_DIR-/mnt/elasticsearch/data}


Expand Down
28 changes: 25 additions & 3 deletions notes.txt
@@ -1,10 +1,32 @@
<h2>Install and start ElasticSearch</h2> <h2>Getting Started with ElasticSearch</h2>


<pre class="brush: bash"> <pre class="brush: bash">
$: wget http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.14.2.zip $: wget http://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.14.2.zip
$: sudo mv elasticsearch-0.14.2 /usr/local/share/ $: sudo mv elasticsearch-0.14.2 /usr/local/share/
$: sudo ln -s /usr/local/share/elasticsearch-0.14.2 /usr/local/share/elasticsearch $: sudo ln -s /usr/local/share/elasticsearch-0.14.2 /usr/local/share/elasticsearch
$: /usr/local/share/elasticsearch/bin/elasticsearch
</pre> </pre>


You'll probably want to change the configuration for your particular setup but that should at least get you started. Next you'll want to make sure there is an 'elasticsearch' user and that there are suitable data, work, and log directories that 'elasticsearch' owns:

<pre class="brush: bash">
$: sudo useradd elasticsearch
$: sudo mkdir -p /var/log/elasticsearch /var/run/elasticsearch/{data,work}
$: sudo chown -R elasticsearch /var/{log,run}/elasticsearch
</pre>

Go ahead and copy the example configuration:

<pre class="brush: bash">
$: sudo mkdir -p /etc/elasticsearch
$: sudo cp config/elasticsearch-example.yml /etc/elasticsearch/elasticsearch.yml
$: sudo cp config/logging.yml /etc/elasticsearch/
$: sudo cp config/elasticsearch.in.sh /etc/elasticsearch/
</pre>

and make changes to 'elasticsearch.yml' such that it points to the correct data, work, and log directories. Also, you'll want to change the number of 'recovery_after_nodes' and 'expected_nodes' in elasticsearch.yml to however many nodes (machines) you actually expect to have in your cluster. You'll probably also want to do a quick once-over of elasticsearch.in.sh and make sure the jvm settings, etc are sane for your particular setup. Finally, to startup do:

<pre class="brush: bash">
sudo -u elasticsearch /usr/local/share/elasticsearch/bin/elasticsearch -Des.config=/etc/elasticsearch/elasticsearch.yml
</pre>

You should now have a happily running (reasonably configured) elasticsearch data node.

0 comments on commit 22da118

Please sign in to comment.