安装Elasticsearch的Shell脚本在安装带有“是”的X-Pack时会引发错误

问题描述:

我正在使用自动安装最新的Elasticsearch 5.0.0 GA版本和X-Pack插件的shell脚本。安装Elasticsearch的Shell脚本在安装带有“是”的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) 

如果我称之为X-Pack安装命令,而不yes |则一切正常。 yes |有什么问题?

看起来你需要“回声”你“是”

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

感谢您的答复,我来试试! – maestro