简体   繁体   English

Amazon EC2,Auto-Scaling,AMI,有没有更简单的方法?

[英]Amazon EC2, Auto-Scaling, AMIs, is there an easier way?

I have a production Rails app on my Amazon EC2 instance, and set up a load balancer and auto-scaling (I did this all manually, not using Elastic Beanstalk. I also used Dokku to make deployment easier.). 我在我的Amazon EC2实例上有一个生产Rails应用程序,并设置了一个负载均衡器和自动扩展(我手动完成所有操作,而不是使用Elastic Beanstalk。我还使用Dokku来简化部署。)。 I'm confused though. 我很困惑。 When new instances are needed and built with Auto-scaling, it appears as though I need to build an AMI, and then set the new instances (built via auto-scaling) to use this AMI. 当需要新实例并使用自动缩放构建时,似乎我需要构建AMI,然后设置新实例(通过自动缩放构建)以使用此AMI。

But there must be an easier way. 但是必须有一个更简单的方法。 Am I missing something? 我想念什么吗? With Heroku, you just add a dyno and BAM, you're done. 使用Heroku,你只需添加一个dyno和BAM,你就完成了。 Do I really need to copy my AMI and set it is as my auto-scaling image every time I deploy to production? 每次部署到生产环境时,我是否真的需要复制我的AMI并将其设置为我的自动缩放映像? Is there a command, workflow, or post-deployment script I should be using? 是否有我应该使用的命令,工作流或部署后脚本?

You need to specify a AMI which contains the basic set up of the your production node. 您需要指定一个AMI,其中包含生产节点的基本设置。 The usually best practice is to config the auto scale with a user data script. 通常最好的做法是使用用户数据脚本配置自动缩放。 So when the new AMI boots up during the auto scaling it reads the user data (cloud init/upstart). 因此,当新的AMI在自动扩展期间启动时,它会读取用户数据(cloud init / upstart)。 The user data script can pull the code from the git or what ever source control and run the necessary pre-deployment commands. 用户数据脚本可以从git或源代码控制中提取代码并运行必要的预部署命令。 You can't be copying new AMI config to your auto scaling config every time you deploy the code. 每次部署代码时,都无法将新的AMI配置复制到自动扩展配置。

I hope it makes sense to have a master AMI and so some kind of automation like user data script which run specific commands as soon as it boots the production node and then attaches to ELB. 我希望拥有一个主AMI以及某种类型的自动化是有意义的,例如用户数据脚本,它一旦启动生产节点就运行特定命令,然后连接到ELB。

There is a blog post covering dokku-based deployments using Opsworks here . 有一个博客文章涉及使用Opsworks基于dokku的部署在这里 One of the other Dokku maintainers (Michael Hobbs) uses this setup in production. Dokku的其他维护者之一(Michael Hobbs)在生产中使用此设置。

Note: I am one of the Dokku Maintainers, josegonzalez . 注意:我是Dokku维护者之一, josegonzalez

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM