在安装了Ubuntu系统的Elasticsearch中无法安装插件时的解决方法总结

环境

我使用的Ubuntu版本是16。

安装Elasticsearch

我只用了以下的一条命令就进去了。

$ sudo apt-get install elasticsearch

启动Elasticsearch

我使用了下面的指令一键启动。

$ sudo /usr/share/elasticsearch/bin/elasticsearch

在您的网络浏览器中访问以下URL,您可以确认启动情况。

{
  "status" : 200,
  "name" : "Werewolf by Night",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.7.3",
    "build_hash" : "NA",
    "build_timestamp" : "NA",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

安装插件

因为 mobz/elasticsearch-head 和 elasticsearch/elasticsearch-analysis-kuromoji 插件似乎是必需的,所以我试图安装它们。

参考链接:
https://github.com/mobz/elasticsearch-head
https://github.com/elastic/elasticsearch-analysis-kuromoji

运行以下命令。

$ sudo /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head
Exception in thread "main" org.elasticsearch.env.FailedToResolveConfigException: Failed to resolve config path ["/usr/share/elasticsearch/config/elasticsearch.yml"], tried file path ["/usr/share/elasticsearch/config/elasticsearch.yml"], path file ["/usr/share/elasticsearch/config"/"/usr/share/elasticsearch/config/elasticsearch.yml"], and classpath
    at org.elasticsearch.env.Environment.resolveConfig(Environment.java:291)
    at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:95)
    at org.elasticsearch.plugins.PluginManager.main(PluginManager.java:396)

发生错误导致失败。

調查

插件的安装命令就像一个简单的脚本,需要确认其内容。

$ sudo vi /usr/share/elasticsearch/bin/plugin

将最终一行的”exec”更改为”echo”。

echo "$JAVA" $JAVA_OPTS $ES_JAVA_OPTS -Xmx64m -Xms16m -Delasticsearch -Des.path.home=\""$ES_HOME"\" $properties -cp \""$ES_CLASSPATH"\" org.elasticsearch.plugins.PluginManager $args

重新执行命令。

$ sudo /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head
/usr/bin/java -Xmx64m -Xms16m -Delasticsearch -Des.path.home="/usr/share/elasticsearch" -Des.default.path.conf="/usr/share/elasticsearch/config" -Des.default.config="/usr/share/elasticsearch/config/elasticsearch.yml" -cp ":/usr/share/java/lucene-spatial-4.10.4.jar:/usr/share/java/lucene-replicator-4.10.4.jar:/usr/share/java/lucene-queries-4.10.4.jar:/usr/share/java/lucene-demo-4.10.4.jar:/usr/share/java/jna.jar:/usr/share/java/lucene-codecs-4.10.4.jar:/usr/share/java/lucene-analyzers-stempel-4.10.4.jar:/usr/share/java/sigar.jar:/usr/share/java/lucene-analyzers-icu-4.10.4.jar:/usr/share/java/lucene-analyzers-morfologik-4.10.4.jar:/usr/share/java/apache-log4j-extras-1.2.17.jar:/usr/share/java/groovy-all-2.x.jar:/usr/share/java/elasticsearch-1.7.3.jar:/usr/share/java/lucene-suggest-4.10.4.jar:/usr/share/java/log4j-1.2-1.2.17.jar:/usr/share/java/lucene-analyzers-kuromoji-4.10.4.jar:/usr/share/java/lucene-analyzers-phonetic-4.10.4.jar:/usr/share/java/lucene-expressions-4.10.4.jar:/usr/share/java/spatial4j-0.4.1.jar:/usr/share/java/lucene-analyzers-common-4.10.4.jar:/usr/share/java/lucene-misc-4.10.4.jar:/usr/share/java/lucene-benchmark-4.10.4.jar:/usr/share/java/lucene-join-4.10.4.jar:/usr/share/java/lucene-sandbox-4.10.4.jar:/usr/share/java/lucene-queryparser-4.10.4.jar:/usr/share/java/lucene-classification-4.10.4.jar:/usr/share/java/lucene-core-4.10.4.jar:/usr/share/java/lucene-analyzers-smartcn-4.10.4.jar:/usr/share/java/lucene-facet-4.10.4.jar:/usr/share/java/lucene-highlighter-4.10.4.jar:/usr/share/java/lucene-grouping-4.10.4.jar:/usr/share/java/jts.jar:/usr/share/java/lucene-test-framework-4.10.4.jar:/usr/share/java/lucene-analyzers-uima-4.10.4.jar:/usr/share/java/lucene-memory-4.10.4.jar:" org.elasticsearch.plugins.PluginManager "install" "mobz/elasticsearch-head"

当命令提示安装时,尝试直接执行。

$ sudo /usr/bin/java -Xmx64m -Xms16m -Delasticsearch -Des.path.home="/usr/share/elasticsearch" -Des.default.path.conf="/usr/share/elasticsearch/config" -Des.default.config="/usr/share/elasticsearch/config/elasticsearch.yml" -cp ":/usr/share/java/lucene-spatial-4.10.4.jar:/usr/share/java/lucene-replicator-4.10.4.jar:/usr/share/java/lucene-queries-4.10.4.jar:/usr/share/java/lucene-demo-4.10.4.jar:/usr/share/java/jna.jar:/usr/share/java/lucene-codecs-4.10.4.jar:/usr/share/java/lucene-analyzers-stempel-4.10.4.jar:/usr/share/java/sigar.jar:/usr/share/java/lucene-analyzers-icu-4.10.4.jar:/usr/share/java/lucene-analyzers-morfologik-4.10.4.jar:/usr/share/java/apache-log4j-extras-1.2.17.jar:/usr/share/java/groovy-all-2.x.jar:/usr/share/java/elasticsearch-1.7.3.jar:/usr/share/java/lucene-suggest-4.10.4.jar:/usr/share/java/log4j-1.2-1.2.17.jar:/usr/share/java/lucene-analyzers-kuromoji-4.10.4.jar:/usr/share/java/lucene-analyzers-phonetic-4.10.4.jar:/usr/share/java/lucene-expressions-4.10.4.jar:/usr/share/java/spatial4j-0.4.1.jar:/usr/share/java/lucene-analyzers-common-4.10.4.jar:/usr/share/java/lucene-misc-4.10.4.jar:/usr/share/java/lucene-benchmark-4.10.4.jar:/usr/share/java/lucene-join-4.10.4.jar:/usr/share/java/lucene-sandbox-4.10.4.jar:/usr/share/java/lucene-queryparser-4.10.4.jar:/usr/share/java/lucene-classification-4.10.4.jar:/usr/share/java/lucene-core-4.10.4.jar:/usr/share/java/lucene-analyzers-smartcn-4.10.4.jar:/usr/share/java/lucene-facet-4.10.4.jar:/usr/share/java/lucene-highlighter-4.10.4.jar:/usr/share/java/lucene-grouping-4.10.4.jar:/usr/share/java/jts.jar:/usr/share/java/lucene-test-framework-4.10.4.jar:/usr/share/java/lucene-analyzers-uima-4.10.4.jar:/usr/share/java/lucene-memory-4.10.4.jar:" org.elasticsearch.plugins.PluginManager "install" "mobz/elasticsearch-head"
-> Installing mobz/elasticsearch-head...
Trying https://github.com/mobz/elasticsearch-head/archive/master.zip...
Downloading ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Installed mobz/elasticsearch-head into /usr/share/elasticsearch/plugins/head

好像成功了…(^_^;)
当我尝试在浏览器中进行访问时,页面正确地显示出来了。

安装elasticsearch/elasticsearch-analysis-kuromoji。

尝试以与之前相同的方式更改插件名称并安装,但是还是失败了。

$ sudo /usr/bin/java -Xmx64m -Xms16m -Delasticsearch -Des.path.home="/usr/share/elasticsearch" -Des.default.path.conf="/usr/share/elasticsearch/config" -Des.default.config="/usr/share/elasticsearch/config/elasticsearch.yml" -cp ":/usr/share/java/lucene-spatial-4.10.4.jar:/usr/share/java/lucene-replicator-4.10.4.jar:/usr/share/java/lucene-queries-4.10.4.jar:/usr/share/java/lucene-demo-4.10.4.jar:/usr/share/java/jna.jar:/usr/share/java/lucene-codecs-4.10.4.jar:/usr/share/java/lucene-analyzers-stempel-4.10.4.jar:/usr/share/java/sigar.jar:/usr/share/java/lucene-analyzers-icu-4.10.4.jar:/usr/share/java/lucene-analyzers-morfologik-4.10.4.jar:/usr/share/java/apache-log4j-extras-1.2.17.jar:/usr/share/java/groovy-all-2.x.jar:/usr/share/java/elasticsearch-1.7.3.jar:/usr/share/java/lucene-suggest-4.10.4.jar:/usr/share/java/log4j-1.2-1.2.17.jar:/usr/share/java/lucene-analyzers-kuromoji-4.10.4.jar:/usr/share/java/lucene-analyzers-phonetic-4.10.4.jar:/usr/share/java/lucene-expressions-4.10.4.jar:/usr/share/java/spatial4j-0.4.1.jar:/usr/share/java/lucene-analyzers-common-4.10.4.jar:/usr/share/java/lucene-misc-4.10.4.jar:/usr/share/java/lucene-benchmark-4.10.4.jar:/usr/share/java/lucene-join-4.10.4.jar:/usr/share/java/lucene-sandbox-4.10.4.jar:/usr/share/java/lucene-queryparser-4.10.4.jar:/usr/share/java/lucene-classification-4.10.4.jar:/usr/share/java/lucene-core-4.10.4.jar:/usr/share/java/lucene-analyzers-smartcn-4.10.4.jar:/usr/share/java/lucene-facet-4.10.4.jar:/usr/share/java/lucene-highlighter-4.10.4.jar:/usr/share/java/lucene-grouping-4.10.4.jar:/usr/share/java/jts.jar:/usr/share/java/lucene-test-framework-4.10.4.jar:/usr/share/java/lucene-analyzers-uima-4.10.4.jar:/usr/share/java/lucene-memory-4.10.4.jar:" org.elasticsearch.plugins.PluginManager "install" "elasticsearch/elasticsearch-analysis-kuromoji"
-> Installing elasticsearch/elasticsearch-analysis-kuromoji...
Trying https://github.com/elasticsearch/elasticsearch-analysis-kuromoji/archive/master.zip...
Downloading ...............................DONE
Installed elasticsearch/elasticsearch-analysis-kuromoji into /usr/share/elasticsearch/plugins/analysis-kuromoji
Usage:
    -u, --url     [plugin location]   : Set exact URL to download the plugin from
    -i, --install [plugin name]       : Downloads and installs listed plugins [*]
    -t, --timeout [duration]          : Timeout setting: 30s, 1m, 1h... (infinite by default)
    -r, --remove  [plugin name]       : Removes listed plugins
    -l, --list                        : List installed plugins
    -v, --verbose                     : Prints verbose messages
    -s, --silent                      : Run in silent mode
    -h, --help                        : Prints this help message

 [*] Plugin name could be:
     elasticsearch/plugin/version for official elasticsearch plugins (download from download.elasticsearch.org)
     groupId/artifactId/version   for community plugins (download from maven central or oss sonatype)
     username/repository          for site plugins (download from github master)

Message:
   Error while installing plugin, reason: IllegalArgumentException: Plugin installation assumed to be site plugin, but contains source code, aborting installation.

如果稍微搜索一下,就会发现我们在安装elasticsearch/elasticsearch-analysis-kuromoji时,需要指定版本号,所以我们将”elasticsearch/elasticsearch-analysis-kuromoji”部分改为”elasticsearch/elasticsearch-analysis-kuromoji/2.7.0″,然后再次运行。

$ sudo /usr/bin/java -Xmx64m -Xms16m -Delasticsearch -Des.path.home="/usr/share/elasticsearch" -Des.default.path.conf="/usr/share/elasticsearch/config" -Des.default.config="/usr/share/elasticsearch/config/elasticsearch.yml" -cp ":/usr/share/java/lucene-spatial-4.10.4.jar:/usr/share/java/lucene-replicator-4.10.4.jar:/usr/share/java/lucene-queries-4.10.4.jar:/usr/share/java/lucene-demo-4.10.4.jar:/usr/share/java/jna.jar:/usr/share/java/lucene-codecs-4.10.4.jar:/usr/share/java/lucene-analyzers-stempel-4.10.4.jar:/usr/share/java/sigar.jar:/usr/share/java/lucene-analyzers-icu-4.10.4.jar:/usr/share/java/lucene-analyzers-morfologik-4.10.4.jar:/usr/share/java/apache-log4j-extras-1.2.17.jar:/usr/share/java/groovy-all-2.x.jar:/usr/share/java/elasticsearch-1.7.3.jar:/usr/share/java/lucene-suggest-4.10.4.jar:/usr/share/java/log4j-1.2-1.2.17.jar:/usr/share/java/lucene-analyzers-kuromoji-4.10.4.jar:/usr/share/java/lucene-analyzers-phonetic-4.10.4.jar:/usr/share/java/lucene-expressions-4.10.4.jar:/usr/share/java/spatial4j-0.4.1.jar:/usr/share/java/lucene-analyzers-common-4.10.4.jar:/usr/share/java/lucene-misc-4.10.4.jar:/usr/share/java/lucene-benchmark-4.10.4.jar:/usr/share/java/lucene-join-4.10.4.jar:/usr/share/java/lucene-sandbox-4.10.4.jar:/usr/share/java/lucene-queryparser-4.10.4.jar:/usr/share/java/lucene-classification-4.10.4.jar:/usr/share/java/lucene-core-4.10.4.jar:/usr/share/java/lucene-analyzers-smartcn-4.10.4.jar:/usr/share/java/lucene-facet-4.10.4.jar:/usr/share/java/lucene-highlighter-4.10.4.jar:/usr/share/java/lucene-grouping-4.10.4.jar:/usr/share/java/jts.jar:/usr/share/java/lucene-test-framework-4.10.4.jar:/usr/share/java/lucene-analyzers-uima-4.10.4.jar:/usr/share/java/lucene-memory-4.10.4.jar:" org.elasticsearch.plugins.PluginManager "install" "elasticsearch/elasticsearch-analysis-kuromoji/2.7.0"
-> Installing elasticsearch/elasticsearch-analysis-kuromoji/2.7.0...
Trying http://download.elasticsearch.org/elasticsearch/elasticsearch-analysis-kuromoji/elasticsearch-analysis-kuromoji-2.7.0.zip...
Downloading .........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Installed elasticsearch/elasticsearch-analysis-kuromoji/2.7.0 into /usr/share/elasticsearch/plugins/analysis-kuromoji

…达到了目标(^_^;)

嗯,接下来我们要做什么呢…

广告
将在 10 秒后关闭
bannerAds