【发布时间】:2017-10-19 02:18:05
【问题描述】:
我正在尝试测试从一个环境到运行我们的 kafka 服务器的数字海滴的连接。
我正在尝试运行./kafka-console-producer.sh --broker-list <HOST_NAME>:9092 --topic <topic>
而且我一直在得到
[2017-10-17 14:38:59,438] WARN Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2017-10-17 14:38:59,490] WARN Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2017-10-17 14:38:59,542] WARN Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2017-10-17 14:38:59,644] WARN Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) [2017-10-17 14:38:59,696] WARN Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
目前采取的步骤:
- 将adverted.listeners 设置为
PLAINTEXT://<ipaddress>:9092 - 添加到每个尝试连接的客户端的 /etc/hosts
- 添加advertised.host和adverted.port
- 9092 正在接受数字海滴上 ubuntu 安装内的 TCP 连接
- Kafka 在 IPv4 而不是 IPv6 上运行
我的 server.properties 文件的相关部分(HOST_NAME 是实际主机名的别名以保护隐私):
listeners=PLAINTEXT://HOST_NAME:9092
host.name=HOST_NAME
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://HOST_NAME:9092
advertised.host.name=HOST_NAME
advertised.port=9092
我可以从本地机器连接到它自己,但是对于如何让一条愚蠢的小测试消息通过网络传输,我已经束手无策了。
我做错了什么?
【问题讨论】:
-
防火墙规则?您应该允许进入端口 9092 的流量吗?
-
我也应该说,我在 Ubuntu 中添加了防火墙规则。我还需要设置一个特定的数字海洋防火墙吗?
-
不确定,因为我没有使用 Digital Ocean 的经验,但他们应该默认设置防火墙规则。看看this blog
-
我们没有使用他们的云防火墙。我在特定于我们环境的 iptables 中添加了端口,但它仍然无法连接。
-
你能远程登录到
:9092 吗?
标签: apache-kafka