LoginSignup
2
1

More than 3 years have passed since last update.

Elasticsearchにzip形式のプラグインをインストールする

Last updated at Posted at 2020-09-04

手元にあったzip形式のプラグインをインストールする必要があったので、メモとして残しておきます。

  • Elasticsearchのバージョンは7.7.0です。
  • 実行環境はUbuntu18.04です。

方法

以下のコマンドを打つだけです。(zip名は変えてあります)

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

Dockerfile上でインストールする

Dockerfileを利用して、docker imageをビルドする際にプラグインを予めインストールしておくことも可能です。以下のような内容の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というのはプラグインのインストールの「Batch Mode」というもので、特にDockerfileでビルドする際には、インストール時の確認を省略するために必須です。もし付けなかった場合は以下の例外が発生します。

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)

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1