Elastic Beanstalk - 实例上的命令失败。发生意外错误 [错误代码:0000000001]

Posted

技术标签:

【中文标题】Elastic Beanstalk - 实例上的命令失败。发生意外错误 [错误代码:0000000001]【英文标题】:Elastic Beanstalk - Command failed on instance.An unexpected error has occurred [ErrorCode: 0000000001] 【发布时间】:2020-10-07 03:58:07 【问题描述】:

我第一次尝试将 django 应用程序部署到弹性 beanstalk。该应用程序使用 django 频道。

这些是我的配置文件:

option_settings:  
  aws:elasticbeanstalk:container:python:     
    WSGIPath: "dashboard/dashboard/wsgi.py"
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: "dashboard/dashboard/settings.py"
    PYTHONPATH: /opt/python/current/app/dashboard:$PYTHONPATH

  aws:elbv2:listener:80:
    DefaultProcess: http
    ListenerEnabled: 'true'
    Protocol: HTTP
    Rules: ws
  aws:elbv2:listenerrule:ws:
    PathPatterns: /websockets/*
    Process: websocket
    Priority: 1
  aws:elasticbeanstalk:environment:process:http:
    Port: '80'
    Protocol: HTTP
  aws:elasticbeanstalk:environment:process:websocket:
    Port: '5000'
    Protocol: HTTP

container_commands:
  00_pip_upgrade:
    command: "source /opt/python/run/venv/bin/activate && pip install --upgrade pip"
    ignoreErrors: false
  01_migrate:
    command: "django-admin.py migrate"
    leader_only: true
  02_collectstatic:
    command: "django-admin.py collectstatic --noinput"
  03_wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'

当我运行 eb create django-env 时,我得到以下日志:

Creating application version archive "app-200617_112710".
Uploading: [##################################################] 100% Done...
Environment details for: django-env
  Application name: dashboard
  Region: us-west-2
  Deployed Version: app-200617_112710
  Environment ID: e-rdgipdg4z3
  Platform: arn:aws:elasticbeanstalk:us-west-2::platform/Python 3.7 running on 64bit Amazon Linux 2/3.0.2
  Tier: WebServer-Standard-1.0
  CNAME: UNKNOWN
  Updated: 2020-06-17 10:27:48.898000+00:00
Printing Status:
2020-06-17 10:27:47    INFO    createEnvironment is starting.
2020-06-17 10:27:49    INFO    Using elasticbeanstalk-us-west-2-041741961231 as Amazon S3 storage bucket for environment data.
2020-06-17 10:28:10    INFO    Created security group named: sg-0942435ec637ad173
2020-06-17 10:28:25    INFO    Created load balancer named: awseb-e-r-AWSEBLoa-19UYXEUG5IA4F
2020-06-17 10:28:25    INFO    Created security group named: awseb-e-rdgipdg4z3-stack-AWSEBSecurityGroup-17RVV1ZT14855
2020-06-17 10:28:25    INFO    Created Auto Scaling launch configuration named: awseb-e-rdgipdg4z3-stack-AWSEBAutoScalingLaunchConfiguration-H5E4G2YJ3LEC
2020-06-17 10:29:30    INFO    Created Auto Scaling group named: awseb-e-rdgipdg4z3-stack-AWSEBAutoScalingGroup-1I2C273N6RN8S
2020-06-17 10:29:30    INFO    Waiting for EC2 instances to launch. This may take a few minutes.
2020-06-17 10:29:30    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-west-2:041741961231:scalingPolicy:8d4c8dcf-d77d-4d18-92d8-67f8a2c1cd9e:autoScalingGroupName/awseb-e-rdgipdg4z3-stack-AWSEBAutoScalingGroup-1I2C273N6RN8S:policyName/awseb-e-rdgipdg4z3-stack-AWSEBAutoScalingScaleDownPolicy-1JAUAII3SCELN
2020-06-17 10:29:30    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-west-2:041741961231:scalingPolicy:0c3d9c2c-bc65-44ed-8a22-2f9bef538ba7:autoScalingGroupName/awseb-e-rdgipdg4z3-stack-AWSEBAutoScalingGroup-1I2C273N6RN8S:policyName/awseb-e-rdgipdg4z3-stack-AWSEBAutoScalingScaleUpPolicy-XI8Z22SYWQKR
2020-06-17 10:29:30    INFO    Created CloudWatch alarm named: awseb-e-rdgipdg4z3-stack-AWSEBCloudwatchAlarmHigh-572C6W1QYGIC
2020-06-17 10:29:30    INFO    Created CloudWatch alarm named: awseb-e-rdgipdg4z3-stack-AWSEBCloudwatchAlarmLow-1RTNBIHPHISRO
2020-06-17 10:33:05    ERROR   [Instance: i-01576cfe5918af1c3] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
2020-06-17 10:33:05    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-06-17 10:34:07    ERROR   Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

ERROR: ServiceError - Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

错误非常模糊,我不知道自己做错了什么。

【问题讨论】:

您是否从实例中获得了完整的日志?也许他们有更多信息? @Marcin 我不确定如何获取更多日志。当我转到us-east-2.console.aws.amazon.com/elasticbeanstalk/… 时,我什至没有看到列出的任何环境。 所以环境创建失败,即使消息说“创建环境操作完成”?和实例?如果你去ec2控制台? @Marcin 好吧,我的错,我看到的是 us-east-2 而不是创建环境的 us-west-2。现在会尝试检查日志,但是日志文件很多 【参考方案1】:

我遇到了类似的问题。我使用 psycopg2-binary 而不是 psycopg2 并创建了一个新环境。现在健康状况正常

【讨论】:

你到底是怎么切换的?【参考方案2】:

由于这引起了一些关注,我建议您在 aws 控制台上检查您的 Elastic Beanstalk 日志,因为该错误是完全通用的并且可能是任何错误。我建议主要检查 cmd 执行和活动日志。

就我而言,这是因为我在 requirements.txt 中列出了以下内容,并且它们无法在 EC2 上安装:

mkl-fft==1.1.0
mkl-random==1.1.0
mkl-service==2.3.0
pypiwin32==223
pywin32==228

从 requirements.txt 中删除这些修复了问题

【讨论】:

以上是关于Elastic Beanstalk - 实例上的命令失败。发生意外错误 [错误代码:0000000001]的主要内容,如果未能解决你的问题,请参考以下文章

Elastic Beanstalk - 实例上的命令失败。发生意外错误 [错误代码:0000000001]

AWS Elastic Beanstalk “所有实例上的服务受损。”

新 EC2 实例 (Elastic Beanstalk) 上的 Composer 失败

AWS Elastic Beanstalk VPC - 从 ELB 到实例的 HTTPS

AWS Elastic Beanstalk Flask 应用程序:Toolkit 找不到出现在 EC2 实例上的资源

如何更新 Elastic Beanstalk 上的 pg_dump