我已经使用这些步骤设置了自动缩放...
$ elb-create-lb autoscalelb --headers --listener "lb-port=80,instance-port=80,protocol=http" --listener "lb-port=443,instance-port=443,protocol=tcp" --availability-zones us-east-1d
$ elb-describe-lbs autoscalelb
$ elb-register-instances-with-lb autoscalelb --instances i-ee364697
$ elb-configure-healthcheck autoscalelb --headers --target "TCP:80" --interval 5 --timeout 3 --unhealthy-threshold 2 --healthy-threshold 4
$ as-create-launch-config autoscalelc --image-id ami-baba68d3 --instance-type t1.micro
$ as-create-auto-scaling-group autoscleasg --availability-zones us-east-1d --launch-configuration autoscalelc --min-size 1 --max-size 5 --desired-capacity 1 --load-balancers autoscalelb
$ as-describe-auto-scaling-groups autoscleasg
$ as-put-scaling-policy MyScaleUpPolicy --auto-scaling-group autoscleasg --adjustment=1 --type ChangeInCapacity --cooldown 300
$ mon-put-metric-alarm MyHighCPUAlarm --comparison-operator GreaterThanThreshold --evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" --period 600 --statistic Average --threshold 80 --alarm-actions arn:aws:autoscaling:us-east-1:616259365041:scalingPolicy:46c2d3b3-7f29-42b6-ab64-548f45de334f:autoScalingGroupName/autoscleasg:policyName/MyScaleUpPolicy --dimensions "AutoScalingGroupName=autoscleasg"
$ as-put-scaling-policy MyScaleDownPolicy --auto-scaling-group autoscleasg --adjustment=-1 --type ChangeInCapacity --cooldown 300
$ mon-put-metric-alarm MyLowCPUAlarm --comparison-operator LessThanThreshold --evaluation-periods 1 --metric-name CPUUtilization --namespace "AWS/EC2" --period 600 --statistic Average --threshold 50 --alarm-actions arn:aws:autoscaling:us-east-1:616259365041:scalingPolicy:30ccd42c-06fe-401a-8b8f-a4e49bbb9c7d:autoScalingGroupName/autoscleasg:policyName/MyScaleDownPolicy --dimensions "AutoScalingGroupName=autoscleasg"
之后我运行这个命令:
$ as-describe-auto-scaling-groups autoscleasg --headers
回应:
AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES LOAD-BALANCERS MIN-SIZE MAX-SIZE DESIRED-CAPACITY AUTO-SCALING-GROUP autoscleasg autoscalelc us-east-1d
autoscalelb 1 5 1 INSTANCE INSTANCE-ID AVAILABILITY-ZONE STATE STATUS LAUNCH-CONFIG INSTANCE i-acf48bd5 us-east-1d InService Healthy autoscalelc
然后:
$ elb-describe-instance-health autoscalelb --headers
它显示:
INSTANCE_ID INSTANCE_ID STATE DESCRIPTION
REASON-CODE INSTANCE_ID i-ee364697 InService N/A
N/A INSTANCE_ID i-acf48bd5 OutOfService Instance has failed at least the UnhealthyThreshold number of health checks consecutively. Instance
我的第一个问题是:
当主实例没有负载时,它会自动创建一个额外的实例。
其次, 新创建的实例始终处于 OutOfService 状态。
如果我使用以下命令将最小大小更改为 0:
$ as-update-auto-scaling-group autoscleasg --launch-configuration autoscalelc --availability-zones us-east-1d --min-size 0 --max-size 5
并尝试使用 xen 对实例施加负载:
自动缩放不创建任何实例。即使我在最多 5 个 session 上运行上述命令,CPU 利用率达到 100%,但仍然没有创建任何实例。
请帮助我...
最佳答案
我不确定您想要实现什么,但如果您想使用自动缩放功能根据流量增加或减少添加更多实例,则需要使用负载均衡器参数(即延迟):
将您的更改为:
--namespace='AWS/ELB'
--metric-name 延迟
--period 60(这非常快)
--threshold 2.0(这非常低)
为了测试它是否有效,我使用 Apache Bench,在多个微实例上运行以下命令
$ ab -n 10000 -c 10 http://<your ELB>.us-east-1.elb.amazonaws.com/index.php
关于amazon-web-services - 自动缩放:新创建的实例总是 OutOfService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11086376/