

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 對 Amazon EC2 Auto Scaling 中的問題進行故障診斷
<a name="CHAP_Troubleshooting"></a>

Amazon EC2 Auto Scaling 提供特定和描述性錯誤，協助您進行故障診斷。您可以在描述擴展活動中找到錯誤訊息。

**Topics**
+ [從擴展活動擷取錯誤訊息](#RetrievingErrors)
+ [關閉擴展活動](#turn-off-scaling-activities)
+ [其他疑難排解資源](#additional-troubleshooting-resources)
+ [Amazon EC2 Auto Scaling 故障診斷：EC2 執行個體啟動失敗](ts-as-instancelaunchfailure.md)
+ [Amazon EC2 Auto Scaling 故障診斷：AMI 問題](ts-as-ami.md)
+ [Amazon EC2 Auto Scaling 故障診斷：負載平衡器問題](ts-as-loadbalancer.md)
+ [Amazon EC2 Auto Scaling 的故障診斷：啟動範本](ts-as-launch-template.md)

## 從擴展活動擷取錯誤訊息
<a name="RetrievingErrors"></a>

若要從擴展活動的描述中擷取錯誤訊息，請使用 [describe-scaling-activities](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/autoscaling/describe-scaling-activities.html) 命令。您有可追溯到 6 週前的擴展活動紀錄。擴展活動依開始時間排序，並會先列出最新的擴展活動。

**注意**  
擴展活動也會顯示在 Amazon EC2 Auto Scaling 主控台的 Auto Scaling 群組的 **Activity** (活動) 索引標籤的活動歷史記錄中。

若要查看特定 Auto Scaling 群組的擴展活動，請使用下列命令。

```
aws autoscaling describe-scaling-activities --auto-scaling-group-name {{my-asg}}
```

以下是範例回應，其中 `StatusCode` 包含目前活動的狀態，`StatusMessage` 包含錯誤訊息。

```
{
    "Activities": [
        {
            "ActivityId": "3b05dbf6-037c-b92f-133f-38275269dc0f",
            "AutoScalingGroupName": "my-asg",
            "Description": "Launching a new EC2 instance: i-003a5b3ffe1e9358e.  Status Reason: Instance failed to complete user's Lifecycle Action: Lifecycle Action with token e85eb647-4fe0-4909-b341-a6c42d8aba1f was abandoned: Lifecycle Action Completed with ABANDON Result",
            "Cause": "At 2021-01-11T00:35:52Z a user request created an AutoScalingGroup changing the desired capacity from 0 to 1.  At 2021-01-11T00:35:53Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 1.",
            "StartTime": "2021-01-11T00:35:55.542Z",
            "EndTime": "2021-01-11T01:06:31Z",
            "StatusCode": "Cancelled",
            "StatusMessage": "Instance failed to complete user's Lifecycle Action: Lifecycle Action with token e85eb647-4fe0-4909-b341-a6c42d8aba1f was abandoned: Lifecycle Action Completed with ABANDON Result",
            "Progress": 100,
            "Details": "{\"Subnet ID\":\"subnet-5ea0c127\",\"Availability Zone\":\"us-west-2b\"...}",
            "AutoScalingGroupARN": "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:283179a2-f3ce-423d-93f6-66bb518232f7:autoScalingGroupName/my-asg"
        },
     ...
    ]
}
```

如需輸出中欄位的說明，請參閱《Amazon EC2 Auto Scaling API 參考》**中的[活動](https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_Activity.html)。

**檢視已刪除群組的擴展活動**  
若要在刪除 Auto Scaling 群組之後檢視擴展活動，請按如下所示將 `--include-deleted-groups` 選項新增至 [describe-scaling-activities](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/autoscaling/describe-scaling-activities.html) 命令。

```
aws autoscaling describe-scaling-activities --auto-scaling-group-name {{my-asg}} --include-deleted-groups
```

以下為回應範例，其中包含已刪除群組的擴展活動。

```
{
    "Activities": [
        {
            "ActivityId": "e1f5de0e-f93e-1417-34ac-092a76fba220",
            "AutoScalingGroupName": "my-asg",
            "Description": "Launching a new EC2 instance.  Status Reason: Your Spot request price of 0.001 is lower than the minimum required Spot request fulfillment price of 0.0031. Launching EC2 instance failed.",
            "Cause": "At 2021-01-13T20:47:24Z a user request update of AutoScalingGroup constraints to min: 1, max: 5, desired: 3 changing the desired capacity from 0 to 3.  At 2021-01-13T20:47:27Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 0 to 3.",
            "StartTime": "2021-01-13T20:47:30.094Z",
            "EndTime": "2021-01-13T20:47:30Z",
            "StatusCode": "Failed",
            "StatusMessage": "Your Spot request price of 0.001 is lower than the minimum required Spot request fulfillment price of 0.0031. Launching EC2 instance failed.",
            "Progress": 100,
            "Details": "{\"Subnet ID\":\"subnet-5ea0c127\",\"Availability Zone\":\"us-west-2b\"...}",
            "AutoScalingGroupState": "Deleted",
            "AutoScalingGroupARN": "arn:aws:autoscaling:us-west-2:123456789012:autoScalingGroup:283179a2-f3ce-423d-93f6-66bb518232f7:autoScalingGroupName/my-asg"
        },
     ...
    ]
}
```

## 關閉擴展活動
<a name="turn-off-scaling-activities"></a>

如果您需要在不干擾擴展政策或排程動作的情況下調查問題，您可以使用下列選項：
+ 透過暫停 和 `AlarmNotification` `ScheduledActions` 程序，防止所有動態擴展政策和排程動作變更群組所需的容量。如需詳細資訊，請參閱[暫停和繼續 Amazon EC2 Auto Scaling 程序](as-suspend-resume-processes.md)。
+ 停用個別動態擴展政策，使其不會變更群組的所需容量，以回應負載變更。如需詳細資訊，請參閱[停用 Auto Scaling 群組的擴展政策](as-enable-disable-scaling-policy.md)。
+ 透過停用政策的縮減部分，將個別目標追蹤擴展政策更新為僅橫向擴展 （新增容量）。此方法可防止群組所需的容量縮減，但允許在負載增加時增加。如需詳細資訊，請參閱[Amazon EC2 Auto Scaling 的目標追蹤擴展政策](as-scaling-target-tracking.md)。
+ 更新您的預測擴展政策以*僅預測*模式。在僅限預測模式下，預測擴展將繼續產生預測，但不會自動增加容量。如需詳細資訊，請參閱[建立 Auto Scaling 群組的預測擴展政策](predictive-scaling-create-policy.md)。

## 其他疑難排解資源
<a name="additional-troubleshooting-resources"></a>

以下頁面提供針對 Amazon EC2 Auto Scaling 問題進行疑難排解的其他資訊。
+ [驗證 Auto Scaling 群組的擴展活動](as-verify-scaling-activity.md) 
+ [在 Amazon EC2 Auto Scaling 主控台中檢視監控圖表](viewing-monitoring-graphs.md) 
+ [Auto Scaling 群組中的執行個體運作狀態檢查](ec2-auto-scaling-health-checks.md) 
+ [lifecycle hook 的考量與限制考量和限制](lifecycle-hooks.md#lifecycle-hook-considerations)
+  [在 Auto Scaling 群組中完成生命週期動作](completing-lifecycle-hooks.md)
+  [使用 Amazon VPC 為您的 Auto Scaling 執行個體提供網際網路連線](asg-in-vpc.md) 
+ [從 Auto Scaling 群組暫時移除執行個體](as-enter-exit-standby.md) 
+ [停用 Auto Scaling 群組的擴展政策](as-enable-disable-scaling-policy.md) 
+  [暫停和繼續 Amazon EC2 Auto Scaling 程序](as-suspend-resume-processes.md) 
+ [控制縮減期間應終止的 Auto Scaling 執行個體](as-instance-termination.md) 
+ [刪除 Auto Scaling 基礎設施](as-process-shutdown.md) 
+ [Auto Scaling 資源和群組的配額](ec2-auto-scaling-quotas.md) 

下列 AWS 資源也可以提供幫助：
+ [AWS 知識中心的 Amazon EC2 Auto Scaling 主題](https://repost.aws/knowledge-center) 
+ [AWS re：Post 上的 Amazon EC2 Auto Scaling 問題](https://repost.aws/tags/TA5Ef3s6KtTiqT0mCRhR79ig/amazon-ec2-auto-scaling)
+ [AWS 運算部落格中的 Amazon EC2 Auto Scaling 文章](https://aws.amazon.com/blogs/compute/category/compute/auto-scaling/) 
+ [《CloudFormation 使用者指南》**中的 CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html) 

疑難排解通常需要專家或小幫手社群的反覆查詢和探索。如果您在嘗試本節中的建議後仍遇到問題，請聯絡 AWS 支援 （在 中 AWS 管理主控台，按一下**支援**、**支援中心**) 或使用 **Amazon EC2 Auto Scaling **標籤在 [AWS re：Post](https://repost.aws/) 上提出問題。