有没有办法使用自动缩放在AWS要停止不终止实例? [英] Is there a way to STOP not TERMINATE instances using auto-scaling in AWS?

查看:115
本文介绍了有没有办法使用自动缩放在AWS要停止不终止实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待在使用AWS自动伸缩扩展我的基础设施向上和向下基于各种性能指标(CPU等)。我知道如何处理此问题;不过,我不喜欢这样的情况下被终止,而不是当它被缩小停止。这意味着,当我缩减了,我必须从头开始一个新的实例,并重新安装我的软件,等我宁愿只是开始/停止我的情况下,根据需要,而不是建立/终止。有没有办法做到这一点?

I am looking at using AWS auto-scaling to scale my infrastructure up and down based on various performance metrics (CPU, etc.). I understand how to set this up; however, I don't like that instances are terminated rather than stopped when it is scaled down. This means that when I scale back up, I have to start from scratch with a new instance and re-install my software, etc. I'd rather just start/stop my instances as needed rather than create/terminate. Is there a way to do this?

推荐答案

没有,那是不可能的停止的下自动缩放实例。当缩放政策触发去除一个实例,自动缩放的将永远终止的实例。

No, it is not possible to Stop an instance under Auto Scaling. When a Scaling Policy triggers the removal of an instance, Auto Scaling will always Terminate the instance.

然而,这里的一些想法,以应付终止的概念...

However, here's some ideas to cope with the concept of Termination...

方法1:使用pre配置的AMI

您可以与您想要安装的软件,数据和设置配置Amazon EC2实例。然后,选择在管理控制台和选择创建图片操作。这将创建一个新的亚马逊机器映像(AMI)。然后,您可以配置自动缩放启动一个新的实例时使用此AMI。每一个新的实例将包含完全相同的磁盘内容。

You can configure an Amazon EC2 instance with your desired software, data and settings. Then, select the EC2 instance in the Management Console and choose the Create Image action. This will create a new Amazon Machine Image (AMI). You can then configure Auto Scaling to use this AMI when launching a new instance. Each new instance will contain exactly the same disk contents.

值得一提的是,EBS从AMI启动非常快。而不是跨越的第一接入复制整个AMI的启动盘,它复制它。这意味着新的实例就可以开始行动,立即,而不是等待整个磁盘进行复制。

It's worth mentioning that EBS starts up very quickly from an AMI. Instead of copying the whole AMI to the boot disk, it copies it across on "first access". This means the new instance can start-up immediately rather than waiting for the whole disk to be copied.

选项2:使用启动(用户数据)的脚本

每个Amazon EC2实例有一个用户数据字段,这是从实例访问。 脚本可以通过用户数据区传递,然后将其执行的实例启动时。该脚本可以用于安装软件,下载数据,并配置实例

Each Amazon EC2 instance has a User Data field, which is accessible from the instance. A script can be passed through the User Data field, which is then executed when the instance starts. The script could be used to install software, download data and configure the instance.

该脚本可以做一些很简单的,就像下载从源$ C ​​$ C库中的配置脚本,然后执行脚本。这意味着,机器配置可以集中管理和版本控制。要更新您的应用程序?只要启动一个新的实例与更新的脚本,并扔掉旧的实例(这是比更新一个应用程序要容易得多)。

The script could do something very simple, like download a configuration script from a source code repository, then execute the script. This means that machine configuration can be centrally managed and version-controlled. Want to update your app? Just launch a new instance with the updated script and throw away the old instance (which is much easier than "updating" an app).

方法3:添加/删除实例的自动伸缩群

,而不是使用缩放策略来为自动缩放组启动/终止情况下,也能够连接/分离的特定实例。因此,你可以模拟自动缩放:

Rather than using Scaling Policies to Launch/Terminate instances for an Auto Scaling group, it is possible to attach/detach specific instances. Thus, you could 'simulate' auto scaling:

  • When you want to scale-down, detach an instance from the Auto Scaling group, then stop it.
  • When you want to add an instance, start the instance then attach it to the Auto Scaling group.

这将需要自己的code,但它是非常简单的(基本上是两个API调用)。您将负责跟踪到安装/拆卸该实例。

This would require your own code, but it is very simple (basically two API calls). You would be responsible for keeping track of which instance to attach/detach.

这篇关于有没有办法使用自动缩放在AWS要停止不终止实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆