"Kafka Timed out waiting for a node assignment." MSK 上的



规格:

  • 预览中的无服务器亚马逊MSK
  • t2.xlarge EC2实例与Amazon Linux 2
  • 从安装Kafkahttps://dlcdn.apache.org/kafka/3.0.0/kafka_2.13-3.0.0.tgz
  • openjdk版本";11.0.13";2021-10-19升
  • OpenJDK Runtime Environment 18.9(内部版本11.0.13+8-LTS(
  • OpenJDK 64位服务器VM 18.9(版本11.0.13+8-LTS,混合模式,共享(
  • 7.3.3级
  • https://github.com/aws/aws-msk-iam-auth,已成功生成

我还尝试添加IAM身份验证信息,这是Amazon MSK Library for AWS Identity and Access Management推荐的。它说要在config/client.properties中添加以下内容:

# Sets up TLS for encryption and SASL for authN.
security.protocol = SASL_SSL
# Identifies the SASL mechanism to use.
sasl.mechanism = AWS_MSK_IAM
# Binds SASL client implementation.
# sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required;
# Encapsulates constructing a SigV4 signature based on extracted credentials.
# The SASL client bound by "sasl.jaas.config" invokes this class.
sasl.client.callback.handler.class = software.amazon.msk.auth.iam.IAMClientCallbackHandler
# Binds SASL client implementation. Uses the specified profile name to look for credentials.
sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required awsProfileName="kafka-client";

kafka-client是作为实例配置文件附加到EC2实例的IAM角色。

网络:我使用VPC可达性分析器确认安全组配置正确,并且我作为生产者使用的EC2实例可以访问无服务器MSK集群。

我要做的:创建一个主题。

我的尝试方式bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic quickstart-events --bootstrap-server boot-zclcyva3.c2.kafka-serverless.us-east-2.amazonaws.com:9098结果:

Error while executing topic command : Timed out waiting for a node assignment. Call: createTopics
[2022-01-17 01:46:59,753] ERROR org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: createTopics
(kafka.admin.TopicCommand$)

我也在尝试:使用9092的明文端口。(9098是MSK中的IAM身份验证端口,无服务器MSK默认使用IAM身份验证。(

我在SO上发现的关于这个节点分配错误的所有其他帖子都不包括MSK。我尝试了一些建议,比如取消server.properties中侦听器设置的注释,但这并没有改变任何东西。

安装kcat进行故障排除对我来说不起作用,因为亚马逊Linux 2使用的百胜软件包管理器没有现成的安装,而且这些说明在checking for libcurl (by compile)... failed (fail)中对我来说失败了。

问题:解决这个问题的任何其他技巧"节点分配";错误

创建的属性文件不会自动使用;您的命令需要包括--command-config client.properties,该属性文件记录在链接IAM页面的MSK文档中。

提取。。。

ssl.truststore.location=<PATH_TO_TRUST_STORE_FILE>
security.protocol=SASL_SSL
sasl.mechanism=AWS_MSK_IAM
sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required;
sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler

或者,如果明文端口不起作用,那么你就有其他网络问题

除了这些步骤之外,我建议联系MSK的支持,并告诉他们更新";创建主题"页面不再使用Zookeeper,请记住Kafka 3.0(尚未(支持

文档最近更新了,我能够端到端地跟踪它,没有任何问题(IAM政策现在是正确的(

https://docs.aws.amazon.com/msk/latest/developerguide/serverless-getting-started.html

类似于@OneCricketer和AWS IAM文档所说的内容。我使用这些属性作为Java代码的一部分,而不是从命令行传递它们。

以下是我使用IAM凭据创建/删除kafka主题的代码

Properties properties = new Properties();
properties.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapBrokers);
properties.put("security.protocol", "SASL_SSL");
properties.put("sasl.mechanism", "AWS_MSK_IAM");
properties.put("sasl.jaas.config", "software.amazon.msk.auth.iam.IAMLoginModule required;");
properties.put("sasl.client.callback.handler.class", "software.amazon.msk.auth.iam.IAMClientCallbackHandler");
AdminClient adminClient = AdminClient.create(properties); // This creates the admin client 
adminClient.createTopics(topics); // This creates the topics

确保您的IAM角色具有AWS IAM文档中提到的正确权限

最新更新