【问题标题】:Installing repository-se plugin on Elasticsearch在 Elasticsearch 上安装 repository-se 插件
【发布时间】:2019-02-21 20:43:24
【问题描述】:

当然,我们让 EKS 和工作节点在 AWS 上运行。我们正在使用 gcr.io/google_containers/elasticsearch:v6.3.0。但是现在我们想要添加 curator 来拍摄 ES 索引的快照并将它们存储在 S3 存储桶中。对于这个 ES 需要一个 repository-s3 插件。

所以我们决定扩展这个图像,并在安装插件的情况下创建我们自己的图像。 Dockerfile 是:

FROM gcr.io/google_containers/elasticsearch:v6.3.0
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3

这会返回:

Step 2/2 : RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
 ---> Running in 8d96a792a7e3
Exception in thread "main" java.lang.IllegalArgumentException: Could not resolve placeholder 'MINIMUM_MASTER_NODES'
    at org.elasticsearch.common.settings.PropertyPlaceholder.parseStringValue(PropertyPlaceholder.java:116)
    at org.elasticsearch.common.settings.PropertyPlaceholder.replacePlaceholders(PropertyPlaceholder.java:69)
    at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1263)
    at org.elasticsearch.common.settings.Settings$Builder.replacePropertyPlaceholders(Settings.java:1213)
    at org.elasticsearch.node.InternalSettingsPreparer.initializeSettings(InternalSettingsPreparer.java:128)
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:107)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:95)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
    at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:79)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
    at org.elasticsearch.cli.Command.main(Command.java:90)
    at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:48)
The command '/bin/sh -c /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3' returned a non-zero code: 1

当我尝试在正在运行的 es 实例上安装插件时,也会发生同样的事情。

我可以 sudo 到 elasticsearch 用户并再次运行该命令,但它仍然会出现相同的问题:

似乎环境缺少以下变量,因为当我使用 ARG 在 Dockerfile 中添加它们时,它似乎完成了图像(当然这些值是硬编码的,但只是为了证明这一点):

MINIMUM_MASTER_NODES
HTTP_PORT
NODE_DATA
NODE_MASTER
NODE_NAME
TRANSPORT_PORT

不确定我在整个故事中遗漏了什么。

【问题讨论】:

    标签: amazon-web-services elasticsearch kubernetes dockerfile


    【解决方案1】:

    插件安装程序希望从配置中设置或读取这些变量。这些是 Elasticsearch 配置中的参数。哪个是您的elasticsearch.ymljvm.optionslog4j2.properties 文件所在的目录?你可以试试:

    1. ES_PATH_CONF=/path/to/my/config /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3

    2. 在运行脚本之前设置环境变量:

      export MINIMUM_MASTER_NODES=<value>
      export HTTP_PORT=<value>
      export NODE_DATA=<value>
      export NODE_MASTER=<value>
      export NODE_NAME=<value>
      export TRANSPORT_PORT=<value>
      /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
      
    3. 在构建映像时,使用 Dockerfile 中的 ENV 关键字添加这些参数。 Dockerfile:

      FROM gcr.io/google_containers/elasticsearch:v6.3.0
      ENV MINIMUM_MASTER_NODES=<value>
      ENV HTTP_PORT=<value>
      ENV NODE_DATA=<value>
      ENV NODE_MASTER=<value>
      ENV NODE_NAME=<value>
      ENV TRANSPORT_PORT=<value>
      RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3
      

    【讨论】:

      【解决方案2】:

      如下配置 Dockerfile 就可以了。使用 ARG 而不是 ENV 很重要,因为 ARG 仅在构建时使用。在运行时是 elasticsearch 提供环境变量,所以我们不必担心。

      FROM gcr.io/google_containers/elasticsearch:v6.3.0
      ARG MINIMUM_MASTER_NODES=${MINIMUM_MASTER_NODES}
      ARG HTTP_PORT=${HTTP_PORT}
      ARG NODE_DATA=${NODE_DATA}
      ARG NODE_MASTER=${NODE_MASTER}
      ARG NODE_NAME=${NODE_NAME}
      ARG TRANSPORT_PORT=${TRANSPORT_PORT}
      RUN su elasticsearch -c "/usr/share/elasticsearch/bin/elasticsearch-plugin install --batch repository-s3"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-04
        • 2014-06-29
        • 1970-01-01
        • 2016-07-24
        相关资源
        最近更新 更多