本文介绍了如何通过Auto Scaling防止EC2实例终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果该实例位于中间,我想通过功能来阻止EC2实例终止

I would like to prevent EC2 instance termination by Auto Scaling feature if that instance is in the middle of some sort of processing.

背景:

假设我有一个Auto Scaling组,当前正在运行5个实例。
我会创建有关平均CPU使用率的警报...
假设有4个实例处于空闲状态,并且一个实例正在执行大量处理...
平均CPU负载将触发警报,并且结果将执行缩小策略。

Background:
Suppose I have an Auto Scaling group that currently has 5 instances running.I create an alarm on average CPU usage... Suppose 4 of the instances are idle and one is doing some heavy processing...The average CPU load will trigger the alarm and as a result the scale-down policy will execute.

如何获得Auto Scaling来终止其中一个空闲实例,而不是正在处理中的实例?

How do I get Auto Scaling to terminate one of the idle instances and not the one that is in the middle of the processing?

推荐答案

更新



用于控制Auto Scaling在扩展时是否可以终止特定实例(请参阅入门博客)发表进行遍历):

Update

As noted by Ryan Walls (+1), AWS meanwhile provides Instance Protection to control whether Auto Scaling can terminate a particular instance when scaling in (see the introductory blog post Instance Protection for Auto Scaling for a walk through):

值得注意的是,这种实例保护仅适用于事件中的常规Auto Scaling标度:

It's worth noting that this instance protection only applies to regular Auto Scaling scale in events:

,该功能可通过AWS管理控制台(菜单操作->实例保护->设置保护级别),AWS CLI(命令)和API( API操作)。

As usual, the feature is available via the AWS Management Console (menu Actions->Instance Protection->Set Scale In Protection)), the AWS CLI (set-instance-protection command), and the API (SetInstanceProtection API action).

后两个选项允许自动化例如,在运行大量处理作业之前,需要先启用实例保护,并在完成后禁用实例保护,以使实例有资格再次终止。

The latter two options allow automation of the scenario at hand, i.e. one would need to enable instance protection before running 'heavy processing' jobs, and disable instance protection once they are finished so that the instance is eligible for termination again.

此功能当前不适用于自动缩放 .com / ec2 / rel = nofollow noreferrer> Amazon EC2 实例-虽然您确实能够,不包括这样的(相当高级的)概念:

This functionality is currently not available for Auto Scaling of Amazon EC2 instances - while you are indeed able to Configure [an] Instance Termination Policy for Your Auto Scaling Group, the available policies do not include such a (fairly advanced) concept:


  • OldestInstance > —如果要终止Auto Scaling组中最旧的实例,请指定此选项。 [...]

  • OldestInstance — Specify this if you want the oldest instance in your Auto Scaling group to be terminated. [...]

NewestInstance —如果要终止上次启动的实例,请指定此项。 [...]

NewestInstance — Specify this if you want the last launched instance to be terminated. [...]

OldestLaunchConfiguration -如果您希望使用最早的启动配置启动的实例为$ b $,请指定此项b终止。 [...]

OldestLaunchConfiguration — Specify this if you want the instance launched using the oldest launch configuration to be terminated. [...]

ClosestToNextInstanceHour —如果您希望最接近完成计费时间的实例为$,请指定此项b $ b终止。 [...]

ClosestToNextInstanceHour — Specify this if you want the instance that is closest to completing the billing hour to be terminated. [...]

默认-如果您希望Auto Scaling使用默认终止策略来选择要终止的实例,请指定此项。

Default — Specify this if you want Auto Scaling to use the default termination policy to select instances for termination.

这篇关于如何通过Auto Scaling防止EC2实例终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 02:52