简体   繁体   English

AWS:如何在自动扩展期间配置EC2实例

[英]AWS: how to configure EC2 instances during auto scale

I'm currently preparing to leverage the features of AWS more, still a few questions arose during my research. 我目前正在准备更多地利用AWS的功能,但是在研究过程中仍然存在一些问题。 I'm currently interested in a combination of AWS autoscaling with multiple auto scale groups (one for each service) as well as deployment with AWS code deploy. 我目前对将AWS自动扩展与多个自动扩展组(每个服务一个)结合在一起以及对AWS代码部署进行部署感兴趣。

I'm wondering what are common practices to configure the EC2 instance which will get spun up when AWS notices that I need a new EC2 instance. 我想知道配置EC2实例的常用方法是什么,当AWS注意到我需要一个新的EC2实例时,该实例会被启动。 I thought about creating a custom AMI where everything is installed that I need for the application to run. 我考虑过创建一个自定义AMI,其中安装了运行该应用程序所需的一切。 Are there other possibilities? 还有其他可能性吗? How would something like Ansible play into in this setup? 在此设置中,像Ansible会如何发挥作用? Also, what if I need to change the instances like install a security update, what is a common practice to do so without sshing to each server instance and doing it manually. 另外,如果我需要更改实例(如安装安全更新)怎么办,通常的做法是不切换到每个服务器实例并手动进行操作。

Thanks 谢谢

There are basically two choices for configuring an Amazon EC2 instance that is created using Auto Scaling: 对于使用Auto Scaling创建的Amazon EC2实例,基本上有两种选择:

  • A fully-configured AMI 完全配置的AMI
  • A User Data script that configures the instance 用于配置实例的用户数据脚本

You could also use a combination of the two -- have most of it configured on an AMI, then do the final configuration via User Data. 您也可以将两者结合使用-将大多数配置在AMI上,然后通过用户数据进行最终配置。

Tools like Puppet, Chef and Ansible are also popular. Puppet,Chef和Ansible等工具也很受欢迎。 They are triggered via User Data script, that then runs Puppet/Chef/Ansible to install software on the instance. 它们通过用户数据脚本触发,然后运行Puppet / Chef / Ansible在实例上安装软件。

The benefit of using a fully-configured AMI is that the instance is available more quickly, which is handy in an auto-scaling situation where you need more capacity fast . 使用完全配置的AMI的好处是实例可以更快地可用,这在需要快速扩展容量的自动扩展情况下非常方便。 The downside is that you must create a new AMI whenever the software has been updated. 缺点是,每当软件更新时,您都必须创建一个新的AMI。 Netflix have automated this process with Aminator , which automatically builds a new AMI when software is updated. Netflix已使用Aminator自动执行此过程,该更新程序会在软件更新时自动构建新的AMI。

The benefit of using a User Data script is that the configuration is fully flexible and you do not need to maintain a library of AMIs. 使用用户数据脚本的好处是配置完全灵活,您无需维护AMI库。

尝试在自动缩放配置期间添加引导脚本。

First of all if you were looking for Provisioning Automation of AWS infra, then go through Ansible , CloudFormation and Terraform , choice is yours. 首先,如果你正在寻找Provisioning Automation AWS红外线,再经过AnsibleCloudFormationTerraform ,任君选择。

You can prepare GoldenImage with all required packages, tools, security configs installed within it. 您可以准备GoldenImage并在其中安装所有必需的软件包,工具和安全配置。 After that you can create Launch Configuration for Auto Scaling Group , within the launch configuration, you can also provide your custom startup scripts . 之后,您可以在Launch Configuration中创建Auto Scaling Group的启动配置,还可以提供自定义startup scripts

Afterworld, if for any ad-hoc task or command execution, ansible is best choice. Afterworld,对于任何ad-hoc任务或命令执行, ansible是最佳选择。

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

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