使用“是”安装X-Pack时,安装Elasticsearch的Shell脚本会引发错误

时间:2016-10-28 11:39:46

标签: shell elasticsearch elasticsearch-5

我正在开发一个shell脚本,它会自动安装最新的Elasticsearch 5.0.0 GA版本和X-Pack插件。

这就是我所拥有的:

#!/bin/bash

# ========= ES INSTALL =========
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
apt-get update && apt-get install -y elasticsearch

# ===== ES PLUGINS INSTALL =====
yes | ./usr/share/elasticsearch/bin/elasticsearch-plugin install x-pack

在X-Pack安装上,我收到以下错误:

Exception in thread "main" java.nio.file.FileAlreadyExistsException: /usr/share/elasticsearch/bin/x-pack
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
        at java.nio.file.Files.createDirectory(Files.java:674)
        at org.elasticsearch.plugins.InstallPluginCommand.installBin(InstallPluginCommand.java:519)
        at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:482)
        at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:207)
        at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:190)
        at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
        at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:69)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96)
        at org.elasticsearch.cli.Command.main(Command.java:62)
        at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:42)

如果我在没有yes |的情况下调用X-Pack安装命令,那么一切正常。 yes |有什么问题?

1 个答案:

答案 0 :(得分:2)

看起来你需要回复'你的是'

echo "y" | sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install x-pack