无法从远程客户端连接到digital ocean上的kafka服务器

wgx48brx  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(659)

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

迄今采取的步骤:
将播发的.listeners设置为 PLAINTEXT://<ipaddress>:9092 添加到每个尝试连接的客户端的/etc/hosts
添加advised.host和advised.port
9092正在接受数字海洋投递上安装的ubuntu内部的tcp连接
Kafka运行的是ipv4而不是ipv6
my server.properties文件的相关部分(主机名是实际主机名的别名,以保护隐私):

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

我可以从localmachine连接到它自己,但是我对如何让一个愚蠢的小测试消息通过电线到达已经束手无策了。
我做错什么了?

6ju8rftf

6ju8rftf1#

通过将此规则添加到我的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服务器上的端口。确认您的本地主机可以向该端口发送tcp连接数据。

相关问题