亚马逊网络服务-AWS代码部署+比特桶=失败(错误代码HEALTH_CONSTRAINTS)



我已经根据本文设置了所有内容

https://aws.amazon.com/tw/blogs/apn/announcing-atlassian-bitbucket-support-for-aws-codedeploy/

这是我的env:

实例(amazon-linux的免费层(
-apache 2.4已安装

安全组
-只有22个(只有我的ip可以访问(和80个端口被打开

Iptables已停止

设置了两个角色
-一个用于链接S3<->比特桶(附加自定义策略(
-一个角色用于部署组(附加AWSCodeDeployRole策略(

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "codedeploy.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

尝试部署的脚本
https://s3.amazonaws.com/aws-codedeploy-us-east-1/samples/latest/SampleApp_Linux.zip

权限/var/www/*由拥有755权限的ec2用户所有

代理服务代码部署代理状态=AWS CodeDeploy代理以PID 7200 运行

线索:我的s3存储桶中有一些zip文件,每次部署都会上传。

错误代码:HEALTH_CONSTRAINTS

有人知道部署失败的原因是什么吗?

update1使用iam概要文件重新启动实例后,就可以部署应用程序了。但它仍然失败了,当我点击查看事件时,有如下日志:

Error CodeScriptFailed
Script Namescripts/install_dependencies
MessageScript at specified location: scripts/install_dependencies run as user root failed with exit code 1
Log TailLifecycleEvent - BeforeInstall
Script - scripts/install_dependencies
[stdout]Loaded plugins: priorities, update-motd, upgrade-helper
[stdout]Resolving Dependencies
[stdout]--> Running transaction check
[stdout]---> Package httpd.x86_64 0:2.2.31-1.8.amzn1 will be installed
[stdout]--> Processing Dependency: httpd-tools = 2.2.31-1.8.amzn1 for package: httpd-2.2.31-1.8.amzn1.x86_64
[stdout]--> Processing Dependency: apr-util-ldap for package: httpd-2.2.31-1.8.amzn1.x86_64
[stdout]--> Running transaction check
[stdout]---> Package apr-util-ldap.x86_64 0:1.4.1-4.17.amzn1 will be installed
[stdout]---> Package httpd-tools.x86_64 0:2.2.31-1.8.amzn1 will be installed
[stdout]--> Processing Conflict: httpd24-2.4.23-1.66.amzn1.x86_64 conflicts httpd < 2.4.23
[stdout]--> Processing Conflict: httpd24-tools-2.4.23-1.66.amzn1.x86_64 conflicts httpd-tools < 2.4.23
[stdout]--> Finished Dependency Resolution
[stderr]Error: httpd24-tools conflicts with httpd-tools-2.2.31-1.8.amzn1.x86_64
[stderr]Error: httpd24 conflicts with httpd-2.2.31-1.8.amzn1.x86_64
[stdout] You could try using --skip-broken to work around the problem
[stdout] You could try running: rpm -Va --nofiles --nodigest

谁有什么问题吗?

错误代码HEALTH_CONSTRAINTS意味着失败的实例比预期的多,这是由部署配置定义的。

有关部署失败原因的详细信息,请在部署控制台上https://region.console.aws.amazon.com/codedeploy/home?region=region#/deployments,您可以单击失败的deploymentID,然后它将重定向到部署详细信息页面,该页面包含指定部署中包含的所有实例,每行都包含实例的生命周期事件。然后单击ViewEvents,如果有View Logs链接,您可以看到此实例部署失败的原因。

如果控制台没有足够的信息来满足您的需求,那么实例上的日志可以在less/var/log/aws/codeploy-agent/codeploy.gent.log中找到。它包含最近部署的日志。

之所以会发生这种情况,是因为codeDeploy通过命中实例来检查ec2实例的运行状况。在部署之前,您需要在实例上运行下面的bash脚本,并检查该脚本是否有效。必须启动httpd服务。重新启动实例。

    #!/bin/bash
    sudo su
    yum update -y
    yum install httpd -y
    yum install ruby
    yum install aws-cli
    cd ~
    aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1
    chmod +x ./install
    ./install auto
    echo 'hello world' > /var/www/html/index.html
    hostname >> /var/www/html/index.html
    chkconfig httpd on
    service httpd start

这取决于您的部署配置,但基本上有一个或多个部署失败。

HEALTH_CONSTRAINTS:部署在太多实例上失败,无法在指定的实例运行状况约束内成功部署

http://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ErrorInformation.html

请检查您的部署配置设置。部署的总体失败/成功取决于这些设置。请尝试CodeDeployDefault.AllAtOnce,并根据需要拨入。

此外,请仔细检查AWS CodeDeploy实例运行状况设置,尤其是minimum-healthy-hosts

您要求在appspec.yaml文件中安装的一个依赖项与httpd24工具服务之间似乎存在冲突。

[stderr]Error: httpd24-tools conflicts with httpd-tools-2.2.31-1.8.amzn1.x86_64
[stderr]Error: httpd24 conflicts with httpd-2.2.31-1.8.amzn1.x86_64
[stdout] You could try using --skip-broken to work around the problem

因此,请尝试解决依赖安装问题。您可以尝试在ec2上手动安装依赖项,并找到此冲突的解决方案,当您解决此冲突时,将解决方案带到您的appspec.yaml文件中,并通过代码部署安装依赖项。

相关内容

  • 没有找到相关文章

最新更新