有没有办法使用我的静态 ip 而不是 localhost 来启动 Zookeeper 服务器

Is there a way to start a Zookeeper server using my static ip instead of localhost

我已经开始为一个新项目学习一些大数据工具,现在我正在使用 Kafka 和 Zookeeper。

我将它们都安装在我的本地计算机上,我可以启动它们并开始生成和使用消息,一切正常。现在,我想尝试它有两台机器,一台有 kafka 代理、zookeepr 和生产者,另一台有消费者。我们称它们为机器 A 和机器 B。

机器A已经运行了Zookeeper服务器、broker和producer。机器 B 运行一个消费者。据我所知,我应该能够使用 Zookeeper 将消费者设置为在机器 A 上收听生产者的主题。由于两台机器都在同一个网络上(即我的本地家庭网络),我想我可以更改 kafka 代理 server.properties 以将我的静态 ip 地址用于机器 A,然后让机器 B 上的消费者连接到它.

我的问题是,zookeeper 一直在本地主机上旋转,并连接到 0.0.0.0/0.0.0.0:2181,所以当我的经纪人尝试使用我的静态 IP 地址(即 192)连接到它时。168.x.x),超时。我四处寻找解决方案,但找不到任何告诉我如何配置 Zookeeper 服务器以在不同的 IP 地址上启动的信息。

也许我对这些技术的理解完全错误,但我认为这将是一件相当简单的事情。有谁知道解决这个问题的方法吗?否则如果我做的完全错了,正确的方法是什么

zookeeper keeps spinning up on localhost, and connecting to 0.0.0.0/0.0.0.0:2181

嗯,那就是绑定地址

您还需要(最好)为 Zookeeper 设置静态 IP,然后在 Kafka 的 server.properties 文件中设置 zookeeper.connect 以访问另一台机器的外部地址。

从 Zookeeper 配置文件中,您将确保您拥有 myid 文件并且在 属性 文件中有一行看起来像这样(没有双括号)

server.{{ myid }}={{ ip_address }}:2888:3888

你不会在 Kafka 文档中找到它,但它在 Zookeeper documentation


但是,如果 Kafka 和 Zookeeper 在同一台机器上,则没有必要。

您的外部消费者应该设置 bootstrap.servers 属性 和带端口 9092 的 Kafka IP 地址。

你的问题可能与

有关

例如,从listeners=PLAINTEXT://:9092

开始

Zookeeper 3.3.0 开始(参见高级配置):

clientPortAddress : New in 3.3.0: the address (ipv4, ipv6 or hostname) to listen for client connections; that is, the address that clients attempt to connect to. This is optional, by default we bind in such a way that any connection to the clientPort for any address/interface/nic on the server will be accepted

所以你可以使用:

clientPortAddress=127.0.0.1