44. 44
株式会社サイバーエージェント
オートスケールのアクションを一旦無効にしたい時
以下コマンドでtest-scalin-alarmを無効(enableで有効)、閾値超えてもLaunchしない
mon-disable-alarm-actions test-scalein-alarm
確認は以下コマンドで、有効時は↓の赤字がtrue
mon-describe-alarms --show-long
test-scalein-alarm,(nil),ALARM,Threshold Crossed: 1 datapoint (38.21) was less t
han the threshold (40.0).,"{"version":"1.0","queryDate":"2013-06-
06T09:19:10.158+0000","startDate":"2013-06-
16T09:14:00.000+0000","statistic":"Average","period":300,"recentDatapoints":[38.21],"threshold":40.0}",fals
e,(nil),arn:aws:sns:ap-northeast-
1:302441370058:test,(nil),AWS/EC2,CPUUtilization,{AutoScalingGroupName=test-as-
group},300,Average,(nil),1,LessThanThreshold,40.0test-scaleout-alarm,(nil),OK,Threshold Crossed: 1
datapoint (56.391818181818174) was not greater than the threshold
(65.0).,"{"version":"1.0","queryDate":"2013-06-16T09:18:19.823+0000","startDate":"2013-06-
16T09:13:00.000+0000","statistic":Average,"period":300,"recentDatapoints":[56.391818181818174],"thresho
ld":65.0},
運用③:アラーム(トリガ)の一時的に停止
45. 45
株式会社サイバーエージェント
・ASG内の台数をポリシーに沿って増やし(減らし)たい時、テストでポリシーの確認したい時とか
-増やす(ポリシー台数に沿って)
as-execute-policy test-scaleout-policy --auto-scaling-group test-as-group
-減らす
as-execute-policy test-scalein-policy --auto-scaling-group test-as-group
・指定インスタンスを消したい時、インスタンスID指定してAutoScalingGroup内インスタンスを消せる
(min以下は怒られる)
as-terminate-instance-in-auto-scaling-group i-54c7a656 --decrement-desired-capacity
Are you sure you want to terminate this instance? [Ny]y
INSTANCE ad9c84c2-265b-4f9d-8b36-3e33dc16955d InProgress At 2013-06-17T04:29:
27Z instance i-54c7a656 was taken out of service in response to a user request,shrinking the capacity from 3
to 2.
:
運用④:手動で増やす減らす
46. 46
株式会社サイバーエージェント
・行動ログ閲覧したい時、以下はuserrequestによりdesiredcapacityが0->2になったことが分かる。他にも有用
な情報は取れそう。
※Auto Scalingのログってこれくらい
as-describe-scaling-activities
c:ASbin>as-describe-scaling-activities --auto-scaling-group test-as-group --show-long
ACTIVITY,195c3391-93bb-4f54-99f1-cf2b7c97949e,2013-06-17T02:53:00Z,test-as-group,Successful,(nil),"At
2013-06-17T02:52:22Z a user request created an AutoScaling
Group changing the desired capacity from 0 to 2. At 2013-06-17T02:52:27Z an instance was started in
response to a difference between desired and actual capacity, increasing the capacity from 0 to
2.",100,Launching a new EC2 instance: i-30f39232,(nil),2013-06-17T02:52:27.149Z
ACTIVITY,a3de4c39-b073-4593-88e4-c3d0a2444caa,2013-06-17T02:53:01Z,test-as-
group,Successful,(nil),"At 2013-06-17T02:52:22Z a user request created an AutoScaling
Group changing the desired capacity from 0 to 2. At 2013-06-17T02:52:27Z an instance was started in
response to a difference between desired and actual capacity, increasing the capacity from 0 to
2.",100,Launching a new EC2 instance: i-36f39234,(nil),2013-06-17T02:52:27.149Z
運用⑤:Auto Scalingのアクティビティログ
47. 47
株式会社サイバーエージェント
・AutoScalingの機能を一旦止めたい時 as-suspend-processes test-as-group コマンド成功するとOKとでる。確認は↓
as-describe-auto-scaling-groups ※現状インスタンスには影響なし
AUTO-SCALING-GROUP test-as-group test-lc ap-northeast-1c,ap-northeast-1a ue-lb01 2 8 2 Default
INSTANCE i-645c3a66 ap-northeast-1c InService Healthy test-lc
INSTANCE i-d65d3bd4 ap-northeast-1a InService Healthy test-lc
SUSPENDED-PROCESS HealthCheck User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS AddToLoadBalancer User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS Launch User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS RemoveFromLoadBalancerLowPriority User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS AZRebalance User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS ScheduledActions User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS Terminate User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS ReplaceUnhealthy User suspended at 2013-06-16T05:00:03Z test-as-group
SUSPENDED-PROCESS AlarmNotification User suspended at 2013-06-16T05:00:03Z test-as-group
・有効化 as-resume-processes test-as-group コマンド成功するとOKとでる。確認は↓
c:ASbin>as-describe-auto-scaling-groups
AUTO-SCALING-GROUP test-as-group test-lc ap-northeast-1c,ap-northeast-1a ue-lb01 2 8 2 Default
INSTANCE i-645c3a66 ap-northeast-1c InService Healthy test-lc
INSTANCE i-d65d3bd4 ap-northeast-1a InService Healthy test-lc
※suspend中に1台減らしてresumeしたら、1台のunhealthyを認識後1台増加した。
運用⑥:Auto Scalingの無効化
AutoScalingGroupを消しちゃうと、
配下のインスタンスは
全部Terminateされちゃう!