【问题标题】:AWS Elastic Beanstalk configuration filesAWS Elastic Beanstalk 配置文件
【发布时间】:2013-04-11 16:36:33
【问题描述】:

我有一个在 aws elastic beanstalk 上运行的应用程序。该应用程序需要一个配置文件,我将其用于手动在 ec2 实例上进行测试。

问题是,当自动缩放器决定扩展到更多实例时,应用程序在新实例上没有任何配置文件。

我阅读了有关为实例创建模板的信息。我可以将我的配置文件放在实例上,然后将其复制到新实例中。 这有一个很大的缺点,因为如果我想在运行时更改配置,我必须在所有实例上都这样做。

有没有办法解决这个问题?

【问题讨论】:

    标签: configuration amazon-web-services amazon-elastic-beanstalk


    【解决方案1】:

    嗯,我看到了两个选项: 1. 更改配置文件时,需要在 EB 上进行环境更新。在这种情况下,所有节点都将使用新版本的配置文件进行更新。 2. 而不是文件将您的配置设置到一些数据库,如 simpledb 或 dynamodb。从我的角度来看,如果您想在运行时更改设置,此解决方案更适合您的情况。

    【讨论】:

    • 谢谢,这就是我正在寻找的解决方案。唯一的缺点是速度取决于服务器必须处理多少请求。我使用缓存服务器解决了这个问题,并每 10 分钟更新一次缓存服务器。
    【解决方案2】:

    我同意 Vadim911,DB 将是一个更简单的解决方案。

    但是当您的应用在环境中设置时,您可以使用类似的方法来执行此操作。

    WEB-INF/.ebextensions/commands.config

    commands:
      replace-file:
        command: cp .ebextensions/file.xml /folder/file.xml
    

    来源:infoq

    【讨论】:

      【解决方案3】:

      如果我们更深入:) 最好使用“文件”而不是“命令”:

      files:
          /folder/file.xml:
              mode: 000XXX
              owner: root
              group: users
              content: |
                 <xml>I'm XML</xml>
      

      【讨论】:

        【解决方案4】:

        我建议您将配置文件放在安全的位置,例如 s3 存储桶。将敏感信息远离您的存储库。

        试试这样的:

        # .ebexetensions/safe-config-install.config
        
        files:
          "/tmp/cron-fetch-config.sh":
            mode: "000755"
            owner: root
            group: root
            content: |
              #!/usr/bin/env bash
              for f in /etc/profile.d/*.sh; do source $f; done;
        
              python -c "import boto;boto.connect_s3().get_bucket('my-private-bucket').get_key('secretfolder/secretfile.xml').get_contents_to_filename('/var/app/current/path/to/config.xml');
        
        container_commands:
          install-config:
            command: python -c "import boto;boto.connect_s3().get_bucket('my-private-bucket').get_key('secretfolder/secretfile.xml').get_contents_to_filename('/var/app/ondeck/path/to/config.xml');
        
        commands:
          setup-cron-for-config:
            command: echo -e "* * * * * root /tmp/cron-fetch-config.sh\n" > /etc/cron.d/my_cron
        

        【讨论】:

          猜你喜欢
          • 2019-12-02
          • 2018-04-20
          • 2017-02-28
          • 2020-08-27
          • 2017-05-21
          • 2016-12-08
          • 2021-04-16
          • 2017-11-20
          • 2012-12-14
          相关资源
          最近更新 更多