Apache Beam:初始化分区“ topic-1”时超时。 Kafka客户端可能无法连接到服务器

时间:2019-03-08 05:22:28

标签: apache-kafka tls1.2 apache-beam google-kubernetes-engine apache-beam-io

当我的Apache Beam应用程序在启用ACL的情况下连接到我的Kafka集群时,出现此错误。请帮助我解决此问题。

Caused by: java.io.IOException: Reader-4: Timeout while initializing partition 'test-1'. Kafka client may not be able to connect to servers.
    org.apache.beam.sdk.io.kafka.KafkaUnboundedReader.start(KafkaUnboundedReader.java:128)
    org.apache.beam.runners.dataflow.worker.WorkerCustomSources$UnboundedReaderIterator.start(WorkerCustomSources.java:779)
    org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation$SynchronizedReaderIterator.start(ReadOperation.java:361)
    org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:194)
    org.apache.beam.runners.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:159)
    org.apache.beam.runners.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:76)
    org.apache.beam.runners.dataflow.worker.StreamingDataflowWorker.process(StreamingDataflowWorker.java:1228)
    org.apache.beam.runners.dataflow.worker.StreamingDataflowWorker.access$1000(StreamingDataflowWorker.java:143)
    org.apache.beam.runners.dataflow.worker.StreamingDataflowWorker$6.run(StreamingDataflowWorker.java:967)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    java.lang.Thread.run(Thread.java:745)

我在GKE上有一个带有3个节点的Kafka集群。我创建了一个具有复制因子3和分区5的主题。

kafka-topics --create --zookeeper zookeeper:2181 \
  --replication-factor 3 --partitions 5 --topic topic

我为 test_consumer_group 消费者组的主题 test 设置了读取权限。

kafka-acls --authorizer-properties zookeeper.connect=zookeeper:2181 \
  --add --allow-principal User:CN=myuser.test.io --consumer \
  --topic test --group 'test_consumer_group'

在我的Apache Beam应用程序中,设置配置 group.id = test_consumer_group

还在控制台使用者上进行测试,并且效果不佳。

$ docker run --rm   -v `pwd`:/cert   confluentinc/cp-kafka:5.1.0 \
  kafka-console-consumer   --bootstrap-server kafka.xx.xx:19092 \
  --topic topic --consumer.config /cert/client-ssl.properties
[2019-03-08 05:43:07,246] WARN [Consumer clientId=consumer-1, groupId=test_consumer_group]
Received unknown topic or partition error in ListOffset request for
partition test-3 (org.apache.kafka.clients.consumer.internals.Fetcher)

1 个答案:

答案 0 :(得分:0)

好像是您的卡夫卡读者之间的交流问题Kafka client may not be able to connect to servers