无法从远程客户端连接到数字海洋上的kafka服务器

时间:2017-10-17 19:01:31

标签: apache-kafka

我试图测试从一个环境到运行我们的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)

到目前为止采取的步骤:

  • 将advertised.listeners设置为PLAINTEXT://<ipaddress>:9092
  • 添加到每个尝试连接的客户端的/ etc / hosts
  • 添加advertised.host和advertised.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

我可以从本地机器连接到自己,但我在绳索的尽头是如何得到一个愚蠢的小测试信息来接触电线。

我做错了什么?

1 个答案:

答案 0 :(得分: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连接数据发送到该端口。