简体   繁体   English

AWS ECS代理在启动时找不到/etc/resolv.conf,也无法将实例添加到ECS集群

[英]AWS ECS agent cannot find /etc/resolv.conf when launching and cannot add instances to an ECS cluster

I am trying to follow the instructions here to add an instance to my AWS ECS cluster. 我正在尝试按照此处的说明将实例添加到我的AWS ECS集群。

So I: 所以我:

  1. Created an autoscaling launch configuration for autoscaled instances ( AMI : ami-a28476c2 us-west-2 ) 为自动扩展实例创建了自动扩展启动配置( AMIami-a28476c2 us-west-2
  2. The instance boots from the autoscale group with no issues, but never joins my ECS cluster default as the docs say it should. 实例从autoscale组启动,没有问题,但从未按照文档所述加入我的ECS集群default
  3. I sshed into the instance and cat the logs and see: 我进入实例并查看日志,然后看到:

    [ec2-user@ip-172-31-47-157 ~]$ cat /var/log/ecs/ecs-init.log.2016-05-10-03 2016-05-10T03:31:21Z [INFO] pre-start 2016-05-10T03:31:22Z [INFO] start 2016-05-10T03:31:22Z [INFO] No existing agent container to remove. [ec2-user @ ip-172-31-47-157〜] $ cat /var/log/ecs/ecs-init.log.2016-05-10-03 2016-05-10T03:31:21Z [INFO]开始2016-05-10T03:31:22Z [INFO]开始2016-05-10T03:31:22Z [INFO]没有要删除的现有代理容器。 2016-05-10T03:31:22Z [INFO] Starting Amazon EC2 Container Service Agent 2016-05-10T03:31:23Z [ERROR] could not start Agent: API error (500): Cannot start container dbee780d6770f62afc3266ba14b77957a5e6054f94e89b2ced77f9636c4be64b: open /etc/resolv.conf: no such file or directory 2016-05-10T03:31:22Z [INFO]启动Amazon EC2容器服务代理2016-05-10T03:31:23Z [ERROR]无法启动代理:API错误(500):无法启动容器dbee780d6770f62afc3266ba14b77957a5e6054f94e89b2ced77f9636c4be64b:打开/ etc / resolv.conf:没有这样的文件或目录

So it looks like the ECS agent is failing because it can't find /etc/resolv.conf . 因此,似乎ECS代理失败了,因为它找不到/etc/resolv.conf I have no idea why this is since I'm following the docs verbatim. 我不知道为什么会这样,因为我一直在逐字关注文档。

Has anyone tried this in the past? 以前有人尝试过吗? I'm not sure how to go about debugging this. 我不确定如何进行调试。

I have solved this. 我已经解决了。 Using the help at this page, I found that something (don't know what the cause was) was firewalling the instance. 使用页面上的帮助,我发现某个实例(不知道是什么原因)正在对实例进行防火墙保护。

In my autoscaling launch configuration, I added the following code to user-data section: 在自动缩放启动配置中,我将以下代码添加到user-data部分:

#!/bin/bash
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
echo "nameserver 8.8.4.4" | sudo tee -a /etc/resolv.conf

which creates the missing file ( /etc/resolv.conf ) and tells the instance to use the Google DNS servers (presumably any DNS servers you want). 它会创建丢失的文件( /etc/resolv.conf ),并告诉实例使用Google DNS服务器(可能是您想要的任何DNS服务器)。

And all works great now. 现在一切都很好。

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

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