調用我的 AWS CloudFormation 堆疊或使用 Amazon ElastiCache 的 AWS API 呼叫時,請求失敗並收到類似下列內容的錯誤: "Status Code: 400; Error Code: ###",如何對此錯誤進行疑難排解?
簡短描述
當您直接或使用 CloudFormation 堆疊開始 AWS API 請求時,AWS 會執行初始語法檢查。這些檢查會確認請求已完成,且具有所有的必要參數。以下是在您傳送 Amazon ElastiCache 的 API 請求時發生 400 錯誤的常見原因:
- 由於 API 請求限流,您的請求遭拒。
- AWS 沒有足夠的可用容量來完成您的請求。
- 請求中指定的區域或可用區域不支援快取節點。
- 您使用了無效的參數組合。
- 您使用了無效或超出範圍的輸入參數值。
- API 遺失必要的參數或動作。
- 您正在嘗試移除另一個 ElastiCache 資源或 AWS 服務目前使用的資源。
解決方法
識別您收到的特定 ElastiCache 調用 API 錯誤。然後,依照針對該錯誤列出的疑難排解步驟進行操作。
**注意:**如需可能錯誤及其描述的清單,請參閱 ElastiCache 調用 API 參考中的常見錯誤。
錯誤代碼: 限流
錯誤:"Rate exceeded (Service: AmazonElastiCache; Status Code: 400; Error Code: Throttling; Request ID: ###)"
此錯誤表示您的請求因 API 請求限流而遭拒。這些帳戶層級的 API 呼叫並非特定於任何服務。
**注意:**您無法增加或修改特定呼叫的限制。AWS 確保 API 呼叫不會超過允許的最大 API 請求率。這包括來自應用程式、對命令列介面的呼叫,或者 AWS 管理主控台的 API 呼叫。
請使用下列方式避免此錯誤:
- 使用指數退避和抖動重試您的呼叫。
- 在一段時間內平均分配您的 API 呼叫,而不是在短時間內進行多個 API 呼叫。
錯誤代碼: InsufficientCacheClusterCapacity
錯誤:"cache.### (VPC) is not currently supported in the availability zone ###.Retry the launch with no availability zone or target: ###.(Service: AmazonElastiCache; Status Code: 400; Error Code: InsufficientCacheClusterCapacity; Request ID: ###)"。
此錯誤表示 AWS 目前沒有足夠的可用隨選容量,以完成您的請求。如需詳細資訊,請參閱錯誤訊息: InsufficidentCacheClusterCapacity。
如果您收到此錯誤,請執行下列操作:
- 請稍候幾分鐘,然後再次提交您的請求。容量頻繁變化。
- 使用另一個快取節點類型,然後再次提交您的請求。
- 使用另一個子網路和可用區域,然後再次提交您的請求。
錯誤代碼: SubnetInUse
錯誤:"The subnet ID subnet-### is in use (Service: AmazonElastiCache; Status Code: 400; Error Code: SubnetInUse; Request ID: ###)"。
如果您嘗試從目前具有關聯執行個體的 Elasticache 子網路群組中移除子網路,即會發生此錯誤。您必須從子網路移除所有相關資源,然後再次提交您的請求。如需詳細資訊,請參閱 DeleteCacheSubnetGroup。
錯誤代碼: InvalidParameterValue
此錯誤表示參數值無效、不受支援,或者無法用於您的請求中。檢查請求呼叫的每個參數。例如,如果您使用了不受支援的參數值,則可能看到下列錯誤訊息之一:
- "Invalid AuthToken provided.(Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterValue"; Request ID: ###)"。
此錯誤表示將 AUTH 與 ElastiCache for Redis 搭配使用時,auth-token 設定不符合限制。如需詳細資訊,請參閱使用 Redis AUTH 命令驗證使用者身分。
- "The snapshot window and maintenance window must not overlap.(Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterValue; Request ID: ###)"。
無法同時設定快照時段和維護時段。將操作時段調整為另一個期間,以避免此錯誤。
- "The number of replicas per node group must be within 0 and 5.(Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterValue; Request ID: ###)"。
ElastiCache Redis 支援一個主要複本,每個碎片 0 至 5 個複本。如果您新增超過 5 個複本節點,則會收到此錯誤。如需詳細資訊,請參閱了解 Redis 複寫。
錯誤代碼: InvalidParameterCombination
此錯誤表示您的請求呼叫包含錯誤的參數組合或遺失參數。如果發生這種情況,您可能會看到下列錯誤訊息之一:
- "Cannot find version 5.0.0 for redis (Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: ###)"。
此錯誤表示請求呼叫中指出的 Redis 版本不受支援。如需詳細資訊,請參閱支援的 ElastiCache for Redis 版本和支援的 ElastiCache for Memcached 版本。
- "Cannot restore redis from 6.0.5 to 5.0.6.(Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: ###)"。
使用備份建立新 Redis 叢集時,ElastiCache for Redis 不支援降級的 Redis 引擎版本。ElastiCache for Redis 也不支援在執行的 Redis 叢集上降級 Redis 引擎。使用備份建立新 Redis 叢集時,Redis 引擎版本必須大於或等於目前的引擎版本。
- "When using automatic failover, there must be at least 2 cache clusters in the replication group.(Service: AmazonElastiCache; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: ###)"。
您可以在至少有一個可用讀取複本的 Redis 叢集中,開啟自動容錯移轉選項。確認您的 Redis 複寫群組具有多個複本節點,然後再次提交您的請求。如需詳細資訊,請參閱使用 Multi-AZ 最大程度減少 ElastiCache for Redis 中的停機。
相關資訊
ElastiCache 的配額
Amazon ElastiCache 錯誤訊息
疑難排解 – Amazon ElastiCache for Redis
對 AWS CLI 錯誤進行疑難排解