

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

# Amazon MSK 叢集的穩定狀態重新平衡
<a name="intelligent-rebalancing-self-balancing-paritions"></a>

穩定狀態重新平衡是智慧型重新平衡功能的一部分，此功能預設為針對具有 Express 代理程式的所有新 MSK 佈建叢集開啟。當您向上或向下擴展叢集時，Amazon MSK 會自動處理分割區管理，方法是將分割區分配到新的代理程式，並從代理程式移動分割區以移除。為了確保工作負載在代理程式間的最佳分佈，智慧型重新平衡會使用 Amazon MSK 最佳實務來判斷自動啟動代理程式重新平衡的閾值。

您可以視需要暫停和恢復穩定狀態重新平衡。穩定狀態重新平衡會持續監控您的叢集，並執行下列動作：
+ 追蹤中介裝置資源用量 (CPU、網路、儲存）。
+ 自動調整分割區放置，不會影響資料可用性。
+ 與標準代理程式相比，快速代理程式完成重新平衡操作的速度快上 180 倍。
+ 維護叢集效能。

**Topics**

------
#### [ Pause and resume steady state rebalancing in AWS 管理主控台 ]

1. 開啟 Amazon MSK 主控台，網址為 [https://console.aws.amazon.com/msk/home?region=us-east-1\$1/home/](https://console.aws.amazon.com/msk/home?region=us-east-1#/home/)。

1. 在**叢集**頁面上，選擇 Express 型叢集。如需建立佈建 Express 型叢集的詳細資訊，請參閱 [步驟 1：建立 MSK 佈建叢集](create-cluster.md)。

1. 在叢集詳細資訊頁面上，確認**智慧型重新平衡**狀態為**作用中**。如果智慧型重新平衡不可用或狀態已**暫停**，請建立新的 Express 型叢集。

1. 在**動作**下拉式清單中，選擇**編輯智慧型重新平衡**。

1. 在**編輯智慧型重新平衡**頁面上，執行下列動作：

   1. 選擇**已暫停**。

   1. 選擇**儲存變更**。

------
#### [ Pause and resume steady state rebalancing using AWS CLI ]

若要**ACTIVE**使用 將叢集的重新平衡狀態設定為 AWS CLI，請使用 [update-rebalancing](https://docs.aws.amazon.com/cli/latest/reference/kafka/update-rebalancing.html) 命令，如下列範例所示。在此命令中，使用 `rebalancing` 參數指定狀態。

```
aws msk update-rebalancing --cluster-arn arn:aws:kafka:us-east-1:123456789012:cluster/myCluster/abcd1234-5678-90ef-ghij-klmnopqrstuv-1 --current-version ABCDEF1GHIJK0L --rebalancing "{\"Rebalancing\":{\"Status\":\"ACTIVE\"}}"
```

------
#### [ Pause and resume steady state rebalancing using AWS SDK ]

您也可以使用 [UpdateRebalancingRequest](https://docs.aws.amazon.com/msk/1.0/apireference/clusters-clusterarn-rebalancing.html#UpdateRebalancing) API 設定叢集的重新平衡狀態，以程式設計方式修改代理程式計數。下列範例示範如何將重新平衡狀態設定為 **ACTIVE**和 **PAUSED**。

```
final UpdateRebalancingRequest updateRebalancingRequest = new UpdateRebalancingRequest()
    .withClusterArn(arn:aws:kafka:us-east-1:123456789012:cluster/myCluster/abcd1234-5678-90ef-ghij-klmnopqrstuv-1)
    .withCurrentVersion(ABCDEF1GHIJK0L)
    .withRebalancing(new Rebalancing().withStatus("ACTIVE"));
```

```
final UpdateRebalancingRequest updateRebalancingRequest = new UpdateRebalancingRequest()
    .withClusterArn(arn:aws:kafka:us-east-1:123456789012:cluster/myCluster/abcd1234-5678-90ef-ghij-klmnopqrstuv-1)
    .withCurrentVersion(ABCDEF1GHIJK0L)
    .withRebalancing(new Rebalancing().withStatus("PAUSED"));
```

------