Unable to install Elasticsearch on Mac Sierra (10.12.2)

1.2k views Asked by At

When attempting to start Elasticsearch 5.1.1 via

$ elasticsearch

I get the output:

Error: Could not find or load main class -Xms2g

I've looked into:

  1. I read it may be an error in how a class is called? But I'm not exposed to doing that. This thread doesn't help and isn't really my problem as I'm not installing a plugin.
  2. I installed via Homebrew. Here is some output from that:

    $ brew info elasticsearch
    elasticsearch: stable 5.1.1, HEAD
    Distributed search & analytics engine
    https://www.elastic.co/products/elasticsearch
    Conflicts with: [email protected], [email protected]
    /usr/local/Cellar/elasticsearch/5.1.1 (98 files, 35.2M) *
      Built from source on 2016-12-14 at 09:23:56
    From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/elasticsearch.rb
    ==> Requirements
    Required: java >= 1.8 ✔
    ==> Caveats
    Data:    /usr/local/var/elasticsearch/elasticsearch_GabbAHH/
    Logs:    /usr/local/var/log/elasticsearch/elasticsearch_GabbAHH.log
    Plugins: /usr/local/Cellar/elasticsearch/5.1.1/libexec/plugins/
    Config:  /usr/local/etc/elasticsearch/
    plugin script: /usr/local/Cellar/elasticsearch/5.1.1/libexec/bin/plugin
    
    To have launchd start elasticsearch now and restart at login:
      brew services start elasticsearch
    Or, if you don't want/need a background service you can just run:
      elasticsearch
    
    $ brew doctor
    Please note that these warnings are just used to help the Homebrew maintainers
    with debugging if you file an issue. If everything you use Homebrew for is
    working fine: please don't worry and just ignore them. Thanks!
    Warning: You have unlinked kegs in your Cellar
    Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
    those kegs to fail to run properly once built. Run `brew link` on these:
      mongodb
      ruby
    
  3. I also tried originally installing via manually extracting the .tar.gz package. I at first got some Java permission denied errors, but after running a chown to admin for myself I also got this same Error: Could not find or load main class type error.

  4. I just updated my Java JDK to the latest: 1.8.0_112 and set my JAVA_HOME variable to that directory accordingly.

  5. The most recent version of Elasticsearch 2 (2.4.3) works. Meanwhile, Elasticsearch v5.0.2 fails.

What can I do to have Elasticsearch properly installed on my Mac?

3

There are 3 answers

0
Jettro Coenradie On BEST ANSWER

You most likely have a problem in your .bash_profile. Usually elastic starts out of the box on a mac.

0
Luis Angel Fernandez On

Watch out with this line in your .bashrc or similar:

export GREP_OPTIONS='--color=always'

That will break many shell's pipes, so many runners will fail without giving you any clue.

Distros as Ubuntu usually have this enabled by default for system users. Be careful and check that shell environment variable.

This problem was solved on my servers by just unsetting this variable.

3
Jettro Coenradie On

What I usually do to make upgrading and using multiple projects on my machine is using the following script:

#!/bin/bash

CURRENT_PROJECT=$(pwd)
CONFIG=$CURRENT_PROJECT/config
DATA=$CURRENT_PROJECT/data
LOGS=$CURRENT_PROJECT/logs

BASH_ES_OPTS="-Epath.conf=$CONFIG -Epath.data=$DATA -Epath.logs=$LOGS"

ELASTICSEARCH=$HOME/Development/elastic/elasticsearch/elasticsearch-5.1.1

$ELASTICSEARCH/bin/elasticsearch $BASH_ES_OPTS

Notice the options in BASH_ES_OPTS, these are the ones that changes a lot in version 5. My structure is a folder per project with this script and a few folders: config, data and logs. The config folder contains the files from the elastic distribution: elasticsearch.yml, jvm.properties and log4j2.properties.