首页 > 解决方案 > 无法在本地机器上启动 kafka

问题描述

我已经下载了适用于 Windows 的 kafka 2.4.0 二进制文件。当我使用 server.properties 文件使用 kafka-server-start.bat 从命令行启动 kafka 时,出现以下错误:

[2020-02-04 15:37:33,775] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (host.docker.internal/10.177.172.141:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-02-04 15:37:34,931] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (host.docker.internal/10.177.172.141:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-02-04 15:37:36,122] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (host.docker.internal/10.177.172.141:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-02-04 15:37:37,364] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (host.docker.internal/10.177.172.141:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2020-02-04 15:37:38,692] WARN [Controller id=0, targetBrokerId=0] Connection to node 0 (host.docker.internal/10.177.172.141:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

从 Zookeeper 日志我得到这些错误:

[2020-02-04 15:37:23,056] INFO Client attempting to establish new session at /127.0.0.1:51457 (org.apache.zookeeper.server.ZooKeeperServer)
[2020-02-04 15:37:23,071] INFO Established session 0x100000298ee0000 with negotiated timeout 6000 for client /127.0.0.1:51457 (org.apache.zookeeper.server.ZooKeeperServer)
[2020-02-04 15:37:23,198] INFO Got user-level KeeperException when processing sessionid:0x100000298ee0000 type:create cxid:0x1 zxid:0x12c txntype:-1 reqpath:n/a Error Path:/consumers Error:KeeperErrorCode = NodeExists for /consumers (org.apache.zookeeper.server.PrepRequestProcessor)
[2020-02-04 15:37:23,214] INFO Got user-level KeeperException when processing sessionid:0x100000298ee0000 type:create cxid:0x2 zxid:0x12d txntype:-1 reqpath:n/a Error Path:/brokers/ids Error:KeeperErrorCode = NodeExists for /brokers/ids (org.apache.zookeeper.server.PrepRequestProcessor)
[2020-02-04 15:37:23,230] INFO Got user-level KeeperException when processing sessionid:0x100000298ee0000 type:create cxid:0x3 zxid:0x12e txntype:-1 reqpath:n/a Error Path:/brokers/topics Error:KeeperErrorCode = NodeExists for /brokers/topics (org.apache.zookeeper.server.PrepRequestProcessor)

我安装了 docker,但它没有运行。server.properties 文件保持不变。我无法理解和调试它为什么连接到“host.docker.internal”。

注意:Kafka 成功运行过一次。我记得我在运行 kafka 时强制关闭了 Windows。我不知道这是否是问题。我尝试了较低版本的kafka,我仍然得到同样的错误。

标签: windowsapache-kafka

解决方案


为什么它连接到“host.docker.internal

很可能,您的 Windows 主机文件已使用该属性进行了更新。

您需要编辑您server.properties的使用

listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://127.0.0.1:9092

推荐阅读