ZooKeeper 模式 - Amazon Managed Streaming for Apache Kafka

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

ZooKeeper 模式

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

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

使用获取 Apache ZooKeeper 连接字符串 AWS Management Console

  1. 打开亚马逊MSK控制台,网址为https://console.aws.amazon.com/msk/

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

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

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

  1. 如果您不知道集群的 Amazon 资源名称 (ARN),则可以通过列出账户中的所有集群来找到它。有关更多信息,请参阅 列出亚马逊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

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

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