AWS CodeDeploy 无法同时跨多个可用区部署?
AWS CodeDeploy is impossible to deploy across multiple Availability Zones at the same time?
如下截图,好像只在一个可用区成功。
我检查了 codedeploy 日志是否有一个失败的实例,我发现有一个错误,我认为它被识别为一个本地实例。
2018-01-10 04:40:22 INFO [codedeploy-agent(2696)]: On Premises config file does not exist or not readable
2018-01-10 04:40:43 ERROR [codedeploy-agent(2696)]: CodeDeploy Instance Agent Service: CodeDeploy Instance Agent Service: error during start or run: InstanceMetadata::InstanceMetadataError - Not an EC2 instance and region not provided in the environment variable AWS_REGION. Please specify your region using environment variable AWS_REGION.......
我为这个问题搜索了大约三天,但 AWS 文档中没有提及。在生产环境中,我计划使用附加到自动缩放组的两个可用区。我想知道我是否忽略了除 CodeDeploy 之外的其他东西......我应该检查什么?提前谢谢你。
[更新]
我更新了 ASG 和 ASG 配置屏幕截图。没有什么特别的,它是香草和默认过程。我从 AWS 支持中心等了 5 天,但仍在等待回复。
弹性伸缩组-----
Auto Scaling 组启动配置 -----
最后,我发现了为什么 codedeploy 在 Windows 2016 跨多个可用区失败。此外,这个问题似乎是 Windows 2016 EC2 本身的问题,而不是 ASG 或 codedeploy(我尚未在 linux 上对其进行测试)。我找到了 2 个解决方案,
- 单击 Ec2LaunchSettings 中的按钮 "Shutdown with Syspre" 安全关闭服务器。然后你就可以像往常一样创建AMI了。
- 运行 C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 - 手动调度脚本。参数“-Schedule”是必需的。然后你就可以像往常一样创建AMI了。
第一种方法是一种直观方便的方式(GUI),第二种方法适用于自动化powershell脚本。我已经确认这两种方法都可以成功部署到多个可用区。 codedeployagent记录的日志没有错误。
更具体地说,codedeployagent在部署时留下了各种日志,我发现agent似乎使用了来自169.254.169.254的meta-info。当我失败时,日志显示 "You are On-Premise Instance."。部署失败可能是因为实例无法获取元信息。在下面的文档中,我得到了很多帮助,列出了我所有的解决方案。
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch.html
特别是在文档中
.....In Windows PowerShell, run the following command so that the system schedules the script to run as a Windows Scheduled Task. The script runs one time during the next boot and then disables these tasks from running again....
C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule
如下截图,好像只在一个可用区成功。
我检查了 codedeploy 日志是否有一个失败的实例,我发现有一个错误,我认为它被识别为一个本地实例。
2018-01-10 04:40:22 INFO [codedeploy-agent(2696)]: On Premises config file does not exist or not readable
2018-01-10 04:40:43 ERROR [codedeploy-agent(2696)]: CodeDeploy Instance Agent Service: CodeDeploy Instance Agent Service: error during start or run: InstanceMetadata::InstanceMetadataError - Not an EC2 instance and region not provided in the environment variable AWS_REGION. Please specify your region using environment variable AWS_REGION.......
我为这个问题搜索了大约三天,但 AWS 文档中没有提及。在生产环境中,我计划使用附加到自动缩放组的两个可用区。我想知道我是否忽略了除 CodeDeploy 之外的其他东西......我应该检查什么?提前谢谢你。
[更新] 我更新了 ASG 和 ASG 配置屏幕截图。没有什么特别的,它是香草和默认过程。我从 AWS 支持中心等了 5 天,但仍在等待回复。
弹性伸缩组-----
Auto Scaling 组启动配置 -----
最后,我发现了为什么 codedeploy 在 Windows 2016 跨多个可用区失败。此外,这个问题似乎是 Windows 2016 EC2 本身的问题,而不是 ASG 或 codedeploy(我尚未在 linux 上对其进行测试)。我找到了 2 个解决方案,
- 单击 Ec2LaunchSettings 中的按钮 "Shutdown with Syspre" 安全关闭服务器。然后你就可以像往常一样创建AMI了。
- 运行 C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 - 手动调度脚本。参数“-Schedule”是必需的。然后你就可以像往常一样创建AMI了。
第一种方法是一种直观方便的方式(GUI),第二种方法适用于自动化powershell脚本。我已经确认这两种方法都可以成功部署到多个可用区。 codedeployagent记录的日志没有错误。
更具体地说,codedeployagent在部署时留下了各种日志,我发现agent似乎使用了来自169.254.169.254的meta-info。当我失败时,日志显示 "You are On-Premise Instance."。部署失败可能是因为实例无法获取元信息。在下面的文档中,我得到了很多帮助,列出了我所有的解决方案。
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch.html
特别是在文档中
.....In Windows PowerShell, run the following command so that the system schedules the script to run as a Windows Scheduled Task. The script runs one time during the next boot and then disables these tasks from running again....
C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule