

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Apache ZooKeeper クライアントへの直接アクセスを無効または有効にする
<a name="zookeeper-disable-access"></a>

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://console.aws.amazon.com/msk/home で Amazon MSK コンソールを開きますか?region=us-east-1\#/home/](https://console.aws.amazon.com/msk/home?region=us-east-1#/home/)。

1. クラスターのリストで、ZooKeeper アクセスを無効にするクラスターを選択します。

1. **[プロパティ]** タブを選択し、**[ネットワーク設定]** セクションを探します。

1. **ZooKeeper アクセスを無効にする**を選択します。

**を使用した ZooKeeper アクセスの無効化 AWS CLI**

1. 次の AWS CLI コマンドを実行し、{{ClusterArn}} と {{Current-Cluster-Version}} を ARN とクラスターの最新バージョンに置き換えます。クラスターの最新バージョンを検索するには、[DescribeCluster](https://docs.aws.amazon.com/msk/1.0/apireference/clusters-clusterarn.html#DescribeCluster) オペレーションまたは [describe-cluster](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/kafka/describe-cluster.html) 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}'
   ```

1. `update-connectivity` オペレーションの結果を取得するには、{{ClusterOperationArn}}を `update-connectivity` コマンドの出力で取得した ARN に置き換えて、次のコマンドを実行します。

   ```
   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](https://docs.aws.amazon.com/msk/1.0/apireference/clusters-clusterarn-connectivity.html)」を参照してください。