无法在Mac Sierra上安装Elasticsearch(10.12.2)

时间:2016-12-14 18:38:56

标签: java elasticsearch homebrew macos-sierra

尝试通过

启动Elasticsearch 5.1.1时

$ elasticsearch

我得到了输出:

Error: Could not find or load main class -Xms2g

我已经调查过:

  1. 我读过如何调用一个类可能是一个错误?但是,我没有接触到这样做。由于我没有安装插件,因此thread没有帮助,也不是我的问题。
  2. 我是通过Homebrew安装的。以下是一些输出:

    $ brew info elasticsearch
    elasticsearch: stable 5.1.1, HEAD
    Distributed search & analytics engine
    https://www.elastic.co/products/elasticsearch
    Conflicts with: elasticsearch@1.7, elasticsearch@2.4
    /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. 我还尝试过最初通过manually extracting the .tar.gz package进行安装。我起初得到了一些Java权限被拒绝的错误,但在为自己运行chown给管理员后,我也遇到了同样的Error: Could not find or load main class类型错误。

  4. 我刚刚将我的Java JDK更新到最新版本:1.8.0_112,并相应地将我的JAVA_HOME变量设置为该目录。

  5. 最新版本的Elasticsearch 2(2.4.3)有效。同时,Elasticsearch v5.0.2失败。

  6. 如何在我的Mac上正确安装Elasticsearch?

3 个答案:

答案 0 :(得分:4)

在.bashrc中注意这一行或类似:

导出GREP_OPTIONS =' - color = always'

这将破坏许多炮弹管道,因此很多跑步者会在没有给你任何线索的情况下失败。

作为系统用户,默认情况下,Ubuntu通常具有此功能。小心并检查shell环境变量。

这个问题在我的服务器上解决了,只是取消了这个变量。

答案 1 :(得分:2)

您的.bash_profile中很可能出现问题。通常弹性在Mac上开箱即用。

答案 2 :(得分:1)

我通常在我的机器上进行升级和使用多个项目的工作是使用以下脚本:

#!/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

请注意BASH_ES_OPTS中的选项,这些选项在版本5中发生了很大变化。我的结构是每个项目的文件夹,包含此脚本和一些文件夹:config,data和logs。 config文件夹包含弹性分发中的文件:elasticsearch.yml,jvm.properties和log4j2.properties。