【问题标题】:Cannot Connect from remote client to kafka server on digital ocean无法从远程客户端连接到数字海洋上的 kafka 服务器
【发布时间】: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


【解决方案1】:

通过将此规则添加到我的 iptables 配置中,修改远程主机上的 iptables 配置解决了这个问题:

-A INPUT -s [hosts went here] -p tcp -m state --state NEW -m tcp --dport 9092 -j ACCEPT

我必须允许 TCP 连接到远程主机上的端口 9092。我们的基础架构团队阻止了开发环境中除特定端口外的所有端口,这些端口阻止了开发人员使用 telnet。

总结一下:使用 iptable 配置打开远程 kafka 服务器上的端口。确认您的 localhost 可以将 tcp 连接数据发送到该端口。

【讨论】:

    猜你喜欢
    • 2021-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多