Install Elasticsearch on OSX Mavericks

I try to install Elasticsearch 1.1.0 on OSX Mavericks, but I got the following errors when I try to run:

:> ./elasticsearch Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.Version at org.elasticsearch.bootstrap.Bootstrap.buildErrorMessage(Bootstrap.java:252) at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:236) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32) 

Also, when I execute the same command with -v arg, I got this error:

 :> ./elasticsearch -v Exception in thread "main" java.lang.NoSuchFieldError: LUCENE_36 at org.elasticsearch.Version.<clinit>(Version.java:42) 

Here is my environment:

Java version

 >: java -version java version "1.8.0" Java(TM) SE Runtime Environment (build 1.8.0-b132) Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode) 

Installation path (downloaded .tar.gz archive from elasticsearch download page and extracted here):

 /usr/local/elasticsearch-1.1.0 

ENV vars:

 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home CLASSPATH=/usr/local/elasticsearch-1.1.0/lib/*.jar:/usr/local/elasticsearch-1.1.0/lib/sigar/*.jar 

UPDATE

I finally make it work, unfortunately, not sure, because I tried a lot of changes :). But here is the list of changes I made can help:

~ / Library / caches

/ Library / caches

  • I deleted CLASSPATH env var.

  • ES_PATH and ES_HOME env vars are not installed either, but I think this is not so important.

Note: it now works if I install using brew.

Thank.

+69
osx-mavericks elasticsearch
Apr 03 '14 at 22:33
source share
4 answers

You really should consider using brew . This is a great tool that will take care of dependencies, version control, and more.

To install Elasticsearch with brew, simply:

 brew update brew install elasticsearch 

Boom! Done.

After that, follow the Elasticsearch instructions:

  • To start Elasticsearch at login:

     ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents 
  • Then download Elasticsearch now:

     launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist 

    Or, if you do not need / need a launch, you can simply run:

     elasticsearch 
+203
Apr 04 '14 at 7:06 on
source share

As there are no very good instructions for "installing" on a Mac:

Short version:

  • Install Java (using the latest version is recommended)
  • Set the JAVA_HOME environment variable.
  • Download the Elasticsearch version (tar or zip).
  • Extract Elasticsearch from the downloaded file.
  • Run bin/elasticsearch from the extracted directory.

Long version:

  • Download Java

    • You only need a JRE if you will not write code on the same machine.

    • I assume that you are getting the latest JDK, which is currently JDK 8 (as you think, and I installed the work on my machine).

  • Download and extract Elasticsearch and extract it to some directory.

    • For example: mkdir -p ~/dev/elasticsearch
    • If necessary, move the downloaded file there:

      mv Downloads/elasticsearch* ~/dev/elasticsearch

    • Extract the downloaded file:

      cd ~/dev/elasticsearch (if you moved it in step 2)

      • If it is zip, then unzip elasticsearch-1.1.0.zip (or if you do not want cd in the directory, just run unzip elasticsearch-1.1.0.zip -d ~/dev/elasticsearch )

      • If it is tar, then tar -xvf elasticsearch-1.1.0.tar.gz (or if you do not want cd to be a directory, just run tar -xvf elasticsearch-1.1.0.tar.gz -C ~/dev/elasticsearch )

    • Clean up (if you want) by deleting the downloaded file:

      rm elasticsearch-1.1.0.*

  • Open the .bash_profile file for your bash profile settings:

    vi ~/.bash_profile

  • In the file, export the environment variable

    export ES_HOME=~/dev/elasticsearch/elasticsearch-1.1.0

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home

    export PATH=$ES_HOME/bin:$JAVA_HOME/bin:$PATH

    • Close and reopen your terminal OR

    • Run source ~/.bash_profile to update environment variables

  • Running Elasticsearch:

    elasticsearch

    • A more traditional way to run it is to do almost all of the above, but not add $ES_HOME/bin to PATH . Then just go to ES_PATH ( cd $ES_PATH , then bin/elasticsearch ) or run $ES_PATH/bin/elasticsearch .

Note. Do not install CLASSPATH no good reason. The scripts will do it for you.

+25
Apr 04 '14 at 3:37
source share

To upgrade ElasticSearch, just run brew upgrade elasticsearch

+2
May 10 '15 at
source share
  • You should try using brew with the latest update:

     brew update 
  • And install Cask java:

     brew cask install java 
  • After that, you can install elasticsearch:

     brew install elasticsearch 
  • And to start elasticsearch, now use:

     brew services start elasticsearch 

    Or you can just run:

     elasticsearch 
+2
Sep 05 '17 at 18:14
source share



All Articles