本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
更新 Network Load Balancer 的目標群組運作狀態設定
根據預設,Network Load Balancer 會監控目標的運作狀態,並將請求路由至運作狀態良好的目標。不過,如果負載平衡器沒有足夠的運作狀態良好的目標,它會自動將流量傳送至所有已註冊的目標 (失敗開啟)。您可以修改目標群組的目標群組運作狀態設定,以定義 DNS 容錯移轉和路由容錯移轉的閾值。如需詳細資訊,請參閱目標群組運作狀態。
- Console
-
更新目標群組運作狀態設定
前往 https://console.aws.amazon.com/ec2/
開啟 Amazon EC2 主控台。 -
在導覽窗格的負載平衡中,選擇目標群組。
-
選擇目標群組的名稱,以開啟其詳細資訊頁面。
-
在屬性索引標籤中,選擇編輯。
-
展開目標群組運作狀況需求。
-
對於組態類型,我們建議您選擇統一組態,這會為 DNS 容錯移轉和路由容錯移轉設定相同的閾值。
-
對於狀態良好的狀態要求,請執行下列其中一項:
-
選擇最小運作狀況目標計數,然後輸入從 1 到目標群組目標數目上限的數字。
-
選擇最小狀態良好目標百分比,然後輸入 1 到 100 之間的數字。
-
-
資訊文字指出是否為目標群組啟用跨區域負載平衡。如果停用跨區域負載平衡,您可以啟用它,以確保您有足夠的容量。在目標選取組態下,更新跨區域負載平衡。
下列文字表示已停用跨區域負載平衡:
Healthy state requirements apply to each zone independently.
下列文字表示已啟用跨區域負載平衡:
Healthy state requirements apply to the total targets across all applicable zones.
-
選擇儲存變更。
- AWS CLI
-
更新目標群組運作狀態設定
使用 modify-target-group-attributes 指令。下列範例會將兩個運作狀態不佳的動作的運作狀態良好閾值設定為 50%。
aws elbv2 modify-target-group-attributes \ --target-group-arn
target-group-arn
\ --attributes \ "Key=target_group_health.dns_failover.minimum_healthy_targets.percentage,Value=50
" \ "Key=target_group_health.unhealthy_state_routing.minimum_healthy_targets.percentage,Value=50
" - CloudFormation
-
修改目標群組運作狀態設定
更新 AWS::ElasticLoadBalancingV2::TargetGroup 資源。下列範例會將兩個運作狀態不佳的動作的運作狀態良好閾值設定為 50%。
Resources: myTargetGroup: Type: 'AWS::ElasticLoadBalancingV2::TargetGroup' Properties: Name: my-target-group Protocol: TCP Port: 80 TargetType: ip VpcId: !Ref myVPC TargetGroupAttributes: - Key: "target_group_health.dns_failover.minimum_healthy_targets.percentage" Value: "
50
" - Key: "target_group_health.unhealthy_state_routing.minimum_healthy_targets.percentage" Value: "50
"
建立目標群組
設定運作狀態檢查