使用插件在本地构建/运行Elasticsearch

时间:2019-10-04 00:43:42

标签: elasticsearch plugins

(在Elasticsearch 6.5.1版上)

如何使用本地插件从源代码构建/运行Elasticsearch?

我尝试了以下命令来安装插件: ./distribution/build/cluster/run\ node0/elasticsear-6.5.1-SNAPSHOT/bin/elasticsearch-plugin install file:/<path_to_plugin_zip>表示已成功安装了插件。

但是,当我通过./gradlew run --debug-jvm运行elasticsearch时,它将在运行ES之前清除该目录的内容。

我将插件安装到该特定目录的原因是,我将调试器放入PluginsService.java文件中,并看到构造函数中的Path pluginsDirectory参数设置为/Users/jreback/Desktop/elasticsearch/distribution/build/cluster/run node0/elasticsearch-6.5.1-SNAPSHOT/plugins

那么,如何在本地ES版本上安装我的插件并运行ES,以便在启动过程时不会删除插件代码?提前谢谢了!

1 个答案:

答案 0 :(得分:0)

FWIW,我通过一些手动代码更改来完成此工作(可能有(或可能是)更推荐的方法,但这对我有用。

在我的ES结帐中,我将以下代码更改为server/src/main/java/org/elasticsearch/env/Environment.java

  • 替换此行:将pluginsFile = homeFile.resolve("plugins");替换为pluginsFile = Paths.get("<path to plugin directory"); (此外,您必须import java.nio.file.Paths位于该文件的顶部)。

上面列出的目录的目录结构应如下所示:

- plugin parent directory (should whatever you put in the Environment.java file)
    - plugin directory (name of the plugin)
        - plugin-descriptor.properties file
        - plugin jar file (generated from building the plugin in some prior step)

然后,当您再次启动ES时,您应该看到它加载了您刚刚在日志中添加的插件。