在不同服务器上运行Kafka和Kafka-connect时,无法连接到kafka集群

时间:2020-04-30 08:04:42

标签: apache-kafka apache-kafka-connect

我在不同的服务器上运行Kafka和Kafka-connect(假设服务器A和serverB)

用于kafka connect的serverA

# vi /home/kafka/config/connect-distributed.properties

bootstrap.servers=serverB:9092
rest.host.name=localhost
rest.port=8083

用于kafka的serverB

# vi server.properties 

broker.id=1
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://serverA:9092
delete.topic.enable = true

但是,当我在serverA上运行kafka connect时,出现了错误。

[2020-04-30 16:59:37,053] ERROR Stopping due to error (org.apache.kafka.connect.cli.ConnectDistributed:84)
org.apache.kafka.connect.errors.ConnectException: Failed to connect to and describe Kafka cluster. Check worker's broker connection and security properties.
        at org.apache.kafka.connect.util.ConnectUtils.lookupKafkaClusterId(ConnectUtils.java:64)
        at org.apache.kafka.connect.util.ConnectUtils.lookupKafkaClusterId(ConnectUtils.java:45)
        at org.apache.kafka.connect.cli.ConnectDistributed.startConnect(ConnectDistributed.java:95)
        at org.apache.kafka.connect.cli.ConnectDistributed.main(ConnectDistributed.java:78)
Caused by: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Call(callName=listNodes, deadlineMs=1588233577048) timed out at 1588233577049 after 1 attempt(s)
        at org.apache.kafka.common.internals.KafkaFutureImpl.wrapAndThrow(KafkaFutureImpl.java:45)
        at org.apache.kafka.common.internals.KafkaFutureImpl.access$000(KafkaFutureImpl.java:32)
        at org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:89)
        at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:260)
        at org.apache.kafka.connect.util.ConnectUtils.lookupKafkaClusterId(ConnectUtils.java:58)
        ... 3 more
Caused by: org.apache.kafka.common.errors.TimeoutException: Call(callName=listNodes, deadlineMs=1588233577048) timed out at 1588233577049 after 1 attempt(s)
Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment.

仅供参考,如果我在kafka服务器(serverB)上运行kafka connect,它可以正常工作。但是,我想在其他服务器上运行它们。

如何将kafka-connect连接到kafka?

1 个答案:

答案 0 :(得分:1)

在您的server.properties中,您有

advertised.listeners=PLAINTEXT://serverA:9092

但Kafka会使用

bootstrap.servers=serverB:9092

代替

bootstrap.servers=serverA:9092