gpt4 book ai didi

amazon-web-services - Auto Scaling 组中的更新策略无法更新实例

转载 作者:行者123 更新时间:2023-12-03 07:26:04 26 4
gpt4 key购买 nike

我在 CloudFormation 中使用了以下设置来创建自动缩放组:

"myautoscalinggroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"UpdatePolicy" : {
"AutoScalingRollingUpdate" : {
"MinInstancesInService" : "1",
"MaxBatchSize" : "2",
"WaitOnResourceSignals" : "true",
"PauseTime" : "PT5M"
}
},
"Properties": {
"AvailabilityZones": [
"ap-southeast-2b",
"ap-southeast-2a"
],
"Cooldown": "300",
"DesiredCapacity": { "Ref" : "InstanceCount"},
"HealthCheckGracePeriod": "300",
"HealthCheckType": "EC2",
"MaxSize": "5",
"MinSize": "1",
"VPCZoneIdentifier": { "Ref" : "WebServerSubnets" },
"LaunchConfigurationName": {
"Ref": "mylaunchconfiguration"
},
"LoadBalancerNames": [
{
"Ref": "myloadbalancer"
}
],
"TerminationPolicies": [
"Default"
]
}
},
"mylaunchconfiguration": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"Comment": "Get web page",
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
"yum" : {
"httpd" : []
}
},
"sources" : {
"/var/www/html" : "address to web-site contents"
},
"services" : {
"sysvinit" : {
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
}
}
}
}
},
"Properties": {
"ImageId": "ami-fd9cecc7",
"InstanceType": "t2.micro",
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y aws-cfn-bootstrap\n",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource mylaunchconfiguration ",
" --region ", { "Ref" : "AWS::Region" }, "\n",

"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource myautoscalinggroup ",
" --region ", { "Ref" : "AWS::Region" }, "\n"

]]}},
"KeyName": "myKey",
"SecurityGroups": [{ "Ref" : "mySecurityGroup" }],
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"VolumeSize": 8
}
}
]
}
}

但是当我使用新的启动配置更新堆栈时,更新策略无法更新实例。但是,当我手动终止实例时,AutoScalingGroup 会启动并使用更新的 LaunchConfiguration 启动新实例。关于如何使更新策略发挥作用有什么想法吗?

谢谢

最佳答案

LaunchConfiguration 元数据的更改不会触发 AutoScaling UpdatePolicy。您需要更改 LaunchConfiguration 属性才能触发 UpdatePolicy。最简单的方法是对 UserData 进行简单的更改。

关于amazon-web-services - Auto Scaling 组中的更新策略无法更新实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31600299/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com