安装Elasticsearch的zip格式插件

因为需要安装手头的zip格式插件,所以留下此备忘录。

    • Elasticsearchのバージョンは7.7.0です。

 

    実行環境はUbuntu18.04です。

途径

只需要输入以下命令即可(压缩文件名已更改):

/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch /tmp/plugin.zip

在Dockerfile中进行安装

使用Dockerfile可以在构建Docker镜像时预先安装插件。可以创建以下内容的Dockerfile。

FROM docker.elastic.co/elasticsearch/elasticsearch:7.7.0
COPY plugin.zip /tmp
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/plugin.zip
    • Dockerfileと同じディレクトリ上で、プラグインのzipがある状態にしておきます。

docker build -t custom-elasticsearch . と実行することでイメージをビルドできます。
実行時はelasticsearchの仕様上、9200番と9300番のポートを開けておく必要があります。以下のコマンドで実行します。(ノードが1つの場合)

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node"  custom-elasticsearch

補充:关于–batch

“Batch模式是一个插件的安装方式,特别适用于在Dockerfile中进行构建时,以便省略安装过程中的确认步骤。如果未添加Batch模式,将会触发以下异常。”

Exception in thread "main" java.lang.IllegalStateException: unable to read from standard input; is standard input open and a tty attached?
    at org.elasticsearch.cli.Terminal$SystemTerminal.readText(Terminal.java:273)
    at org.elasticsearch.plugins.PluginSecurity.prompt(PluginSecurity.java:74)
    at org.elasticsearch.plugins.PluginSecurity.confirmPolicyExceptions(PluginSecurity.java:67)
    at org.elasticsearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:878)
    at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:254)
    at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:224)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
    at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:91)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
    at org.elasticsearch.cli.Command.main(Command.java:90)
    at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)

请提供以下资料作为参考。

    Install Elasticsearch with Docker | Elasticsearch Reference [7.9] | Elastic
广告
将在 10 秒后关闭
bannerAds