如何解决 Amazon ECS 中的“[AWS service] was unable to place a task because no container instance met all of its requirements”([AWS 服务] 无法放置任务,因为没有容器实例满足其所有要求。)错误?

2 分钟阅读
0

我想要在 Amazon Elastic Container Service (Amazon ECS) 中放置一个任务。然而,我收到如下错误:"[AWS service] was unable to place a task because no container instance met all of its requirements."([AWS 服务] 无法放置任务,因为没有容器实例满足其所有要求。)

简短描述

您可能会由于以下某个原因收到此错误提示:

  • 在您的集群中未找到任何容器实例
  • 该任务所需的端口已被占用
  • 内存不足以完成任务
  • 可用于您的容器实例的 CPU 单元不足
  • 没有足够的弹性网络接口(ENI)连接点
  • 容器实例缺少必需属性

有关这些问题的更多信息,请参阅服务事件消息

注意:如果您没有收到上述错误消息,请根据您收到的以下错误消息之一选择文章:

解决方案

**注意:**如果在运行 AWS CLI 命令时收到错误,请确保您使用的是最新版本的 AWS CLI

要解决此错误,请根据您的使用场景选择解决方案:

  • 如果集群中未注册任何容器实例,则将容器实例添加到集群
  • 如果任务所需的端口被占用,则将容器实例添加到集群,或者减少所需任务的数量。
    **注意:**如果可能,请考虑使用动态端口映射,以允许任务使用容器实例上的任何可用端口。
  • 如果容器实例没有足够的内存用于任务,则减少任务定义中的内存量。或者,在集群中启动更多容器实例。有关更多信息,请参阅服务事件消息中的内存不足一节。本节位于此部分的下方:service (service-name) was unable to place a task because no container instance met all of its requirements(服务 (service-name) 无法放置任务,因为没有容器实例满足其所有要求。)
  • 如果容器实例没有足够的 CPU 单元,则调整 CPU 所需的任务,或者在集群中启动更多容器实例
    有关更多信息,请参阅服务事件消息中的 CPU 不足一节。本节位于此部分的下方:service (service-name) was unable to place a task because no container instance met all of its requirements(服务 (service-name) 无法放置任务,因为没有容器实例满足其所有要求。)。或者,请参阅如何解决 Amazon ECS 中的“The closest matching container-instance container-instance-id has insufficient CPU units available”错误?
  • 如果容器实例没有任何可用的弹性网络接口连接点,则将更多容器实例添加到您的集群。有关更多信息,请参阅服务事件消息中的没有足够的可用 ENI 附加点一节。本节位于此部分的下方:service (service-name) was unable to place a task because no container instance met all of its requirements(服务 (service-name) 无法放置任务,因为没有容器实例满足其所有要求。)。如果问题仍然存在,请考虑使用 awsvpcTrunking 来提高 Amazon Elastic Compute Cloud(Amazon EC2)实例上的弹性网络接口密度。
  • 如果容器实例缺少必需属性,则请参阅服务事件消息中的容器实例缺少必需属性一节。本节位于此部分的下方:service (service-name) was unable to place a task because no container instance met all of its requirements(服务 (service-name) 无法放置任务,因为没有容器实例满足其所有要求。)。要查找缺失的属性,请运行 ecs-cli check-attributes 命令。
ecs-cli check-attributes --task-def Task_Definition --container-instances Container_Instance --cluster Cluster_Name

注意:对于 Task_Definition 名称,输入您的任务定义的名称。对于 Container_Instance,输入容器实例的名称。对于 Cluster_Name,输入集群的名称。

  • 您可以将 Amazon ECS 服务配置为在与容器实例子网不同的子网上运行。在这种情况下,即使任务因缺失属性错误而失败,ecs-cli-check-attributes 命令的输出也会针对缺失的属性显示 None(无)。确保您的服务和容器实例的子网匹配。为此,请在容器实例所在的子网中重新创建 Amazon ECS 服务。有关更多信息,请参阅任务定义参数Amazon ECS 容器代理配置

例如,如果您运行以下命令:

ecs-cli check-attributes --task-def task:1 --container-instances 650cf1df296749e1bce1b9e0cebb588a --cluster test-cluster

输出应类似于:

Container Instance  Missing Attributes
tes-cluster         None

有关更多信息,请运行以下命令:

ecs-cli --help

相关信息

Amazon ECS 任务联网

服务限制逻辑

AWS 官方
AWS 官方已更新 1 年前