ZooKeeper 模式 - Amazon Managed Streaming for Apache Kafka
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

ZooKeeper 模式

Apache ZooKeeper 是 “一项集中式服务,用于维护配置信息、命名、提供分布式同步和提供群组服务。分布式应用程序以某种形式使用所有这些类型的服务,” 包括Apache Kafka。

如果您的集群正在使用 ZooKeeper 模式,则可以使用以下步骤获取 Apache ZooKeeper 连接字符串。但是,我们建议您使用BootstrapServerString连接到您的集群并执行管理员操作,因为该--zookeeper标志已在 Kafka 2.5 中被弃用,并已从 Kafka 3.0 中删除。

使用获取 Apache ZooKeeper 连接字符串 Amazon Web Services Management Console

  1. https://console.amazonaws.cn/msk/ 打开 Amazon MSK 控制台。

  2. 该表显示了此账户下当前区域的所有集群。选择集群名称以查看其说明。

  3. 集群摘要页面上,选择查看客户端信息。这显示了引导程序代理以及 Apache ZooKeeper 连接字符串。

使用获取 Apache ZooKeeper 连接字符串 Amazon CLI

  1. 如果您不知道集群的 Amazon 资源名称 (ARN),您可以通过列出您账户中的所有集群来找到它。有关更多信息,请参阅 列出 Amazon MSK 集群

  2. 要获取 Apache ZooKeeper 连接字符串以及有关集群的其他信息,请运行以下命令,ClusterArn替换为集群的 ARN。

    aws kafka describe-cluster --cluster-arn ClusterArn

    describe-cluster 命令的输出如以下 JSON 示例所示。

    { "ClusterInfo": { "BrokerNodeGroupInfo": { "BrokerAZDistribution": "DEFAULT", "ClientSubnets": [ "subnet-0123456789abcdef0", "subnet-2468013579abcdef1", "subnet-1357902468abcdef2" ], "InstanceType": "kafka.m5.large", "StorageInfo": { "EbsStorageInfo": { "VolumeSize": 1000 } } }, "ClusterArn": "arn:aws:kafka:us-east-1:111122223333:cluster/testcluster/12345678-abcd-4567-2345-abcdef123456-2", "ClusterName": "testcluster", "CreationTime": "2018-12-02T17:38:36.75Z", "CurrentBrokerSoftwareInfo": { "KafkaVersion": "2.2.1" }, "CurrentVersion": "K13V1IB3VIYZZH", "EncryptionInfo": { "EncryptionAtRest": { "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:555555555555:key/12345678-abcd-2345-ef01-abcdef123456" } }, "EnhancedMonitoring": "DEFAULT", "NumberOfBrokerNodes": 3, "State": "ACTIVE", "ZookeeperConnectString": "10.0.1.101:2018,10.0.2.101:2018,10.0.3.101:2018" } }

    上一 JSON 示例在 describe-cluster 命令输出中显示 ZookeeperConnectString 键。复制与此键对应的值,并保存它以用于在集群上创建主题。

    重要

    您的 Amazon MSK 集群必须处于ACTIVE状态才能获取 Apache ZooKeeper 连接字符串。当集群仍处于 CREATING 状态时,describe-cluster 命令的输出不包含 ZookeeperConnectString。如果发生这种情况,请等待几分钟,然后在集群进入 ACTIVE 状态后再次运行 describe-cluster

使用 API 获取 Apache ZooKeeper 连接字符串

要使用 API 获取 Apache ZooKeeper 连接字符串,请参阅DescribeCluster