View a markdown version of this page

停用或啟用直接 Apache ZooKeeper 用戶端存取 - Amazon Managed Streaming for Apache Kafka

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

停用或啟用直接 Apache ZooKeeper 用戶端存取

您可以在 Amazon MSK 佈建叢集上停用直接 Apache ZooKeeper 用戶端存取,以確認您的應用程式不依賴直接 ZooKeeper 連線。停用 ZooKeeper 存取時,用戶端無法再連線到連接埠 2181 (純文字) 和 2182 (TLS) 上的 Apache ZooKeeper 節點。您可以隨時重新啟用 ZooKeeper 存取。

注意

此功能僅適用於搭配標準代理程式使用 ZooKeeper 中繼資料模式的 Amazon MSK 佈建叢集。它不適用於下列叢集類型:

  • 在 KRaft 中繼資料模式中執行的叢集

  • 使用 Express 代理程式的叢集。ZooKeeper 存取是在 Express 叢集中自動管理,無法手動設定。

  • Amazon MSK Serverless 叢集

使用主控台停用 ZooKeeper 存取
  1. 登入 AWS 管理主控台,並在 https://https://console.aws.amazon.com/msk/home 開啟 Amazon MSK 主控台?region=us-east-1#/home/

  2. 在叢集清單中,選擇您要停用 ZooKeeper 存取的叢集。

  3. 選擇屬性索引標籤,然後尋找網路設定區段。

  4. 選擇停用 ZooKeeper 存取

使用 停用 ZooKeeper 存取 AWS CLI
  1. 執行下列 AWS CLI 命令,將 ClusterArnCurrent-Cluster-Version 取代為 ARN 和目前版本的叢集。若要尋找叢集的目前版本,請使用 DescribeCluster 操作或 describe-cluster AWS CLI 命令。範例版本為KTVPDKIKX0DER

    aws kafka update-connectivity --cluster-arn ClusterArn --current-version Current-Cluster-Version --zookeeper-access '{"Enabled": false}'

    update-connectivity 命令的輸出如以下 JSON 範例所示。

    { "ClusterArn": "arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2", "ClusterOperationArn": "arn:aws:kafka:us-east-1:012345678012:cluster-operation/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2/0123abcd-abcd-4f7f-1234-9876543210ef" }
    注意

    若要重新啟用 ZooKeeper 存取,請--zookeeper-access改用具有下列值的類似 AWS CLI 命令:

    '{"Enabled": true}'
  2. 如要取得 update-connectivity 操作的結果,請執行下列命令,使用您在 update-connectivity 命令輸出中取得的 ARN 取代 ClusterOperationArn

    aws kafka describe-cluster-operation --cluster-operation-arn ClusterOperationArn

    describe-cluster-operation 命令的輸出如以下 JSON 範例所示。

    { "ClusterOperationInfo": { "ClientRequestId": "982168a3-939f-11e9-8a62-538df00285db", "ClusterArn": "arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2", "CreationTime": "2026-01-15T21:08:57.735Z", "OperationArn": "arn:aws:kafka:us-east-1:012345678012:cluster-operation/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2/0123abcd-abcd-4f7f-1234-9876543210ef", "OperationState": "UPDATE_COMPLETE", "OperationType": "UPDATE_CONNECTIVITY", "SourceClusterInfo": { "ZookeeperAccess": { "Enabled": true } }, "TargetClusterInfo": { "ZookeeperAccess": { "Enabled": false } } } }

    如果 OperationState 具有值 UPDATE_IN_PROGRESS,請稍候一段時間,然後再次執行 describe-cluster-operation 命令。

使用 Amazon MSK API 停用 ZooKeeper 存取
  • 若要使用 API 在叢集上停用或啟用 ZooKeeper 存取,請參閱 UpdateConnectivity