Kafka连接到节点ubuntukafka:9092(id:0 rack:null)出错(org.apache.kafka.clients.NetworkClient)java.net.UnknownHostException: [英] Kafka Error connecting to node ubuntukafka:9092 (id: 0 rack: null) (org.apache.kafka.clients.NetworkClient) java.net.UnknownHostException:

查看:945
本文介绍了Kafka连接到节点ubuntukafka:9092(id:0 rack:null)出错(org.apache.kafka.clients.NetworkClient)java.net.UnknownHostException:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在每个ubuntu的VirtualBox guest虚拟机上都有两台服务器.我可以从主机到两者以及两者之间通过SSH进行连接,以便它们都具有natnetwork.

I have two servers on VirtualBox guests each ubuntu. I can SSH from my main machine to both, and between the two so they all have the natnetwork.

我在一个服务器kafka上运行,如下所述:

I ran on one server kafka as described here:

https://kafka.apache.org/quickstart

于是我提出了单节点Zookeper然后卡夫卡开始了.我添加了测试主题.(全部在MachineA上.10.75.1.247)

So I brought up singlenode zookeper Kafka then started. I added the test topic. (All on MachineA . 10.75.1.247)

我正在尝试从另一台计算机上列出该节点上的主题:

I am trying to list the topics on that node from another machine:

bin/kafka-topics.sh --list --bootstrap-server 10.75.1.247:9092

来自MachineB(10.75.1.2)

from MachineB (10.75.1.2)

这样做会导致错误一遍又一遍:

doing that, causes the error over and over:

[2019-09-16 23:57:07,864] WARN [AdminClient clientId=adminclient-1] Error connecting to node ubuntukafka:9092 (id: 0 rack: null) (org.apache.kafka.clients.NetworkClient)
java.net.UnknownHostException: ubuntukafka
    at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:797)
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298)
    at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:104)
    at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.currentAddress(ClusterConnectionStates.java:403)
    at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.access$200(ClusterConnectionStates.java:363)
    at org.apache.kafka.clients.ClusterConnectionStates.currentAddress(ClusterConnectionStates.java:151)
    at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:943)
    at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:288)
    at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.sendEligibleCalls(KafkaAdminClient.java:925)
    at org.apache.kafka.clients.admin.KafkaAdminClient$AdminClientRunnable.run(KafkaAdminClient.java:1140)
    at java.base/java.lang.Thread.run(Thread.java:834)

它确实解析名称(用ubuntukafka代替ubuntukafkanode),但失败.

it does resolve the name (says ubuntukafka instead of ubuntukafkanode) but fails.

我想念什么?我使用kafka错误吗?我以为我可以拥有一台不错的kafka服务器,所有其他带有数据的服务器也可以产生信息.那么其他许多消费者可以从中读取信息吗?

What am I missing? Am I using kafka wrong? I thought I could have a nice kafka server where all my other servers with data can produce information too. Then many other consumers can read the information from?

最终我想测试的是是否可以将消息发送到我的kafka服务器:

Ultimately what I wanted to test was if I could send messages to my kafka server:

bin/kafka-console-producer.sh --broker-list 10.75.1.247:9092 --topic test

甚至以后再使用python向服务器生成消息.

And even then use python later to produce messages to the server.

from kafka import KafkaProducer

producer = KafkaProducer(bootstrap_servers='10.75.1.247:9092')
for _ in range(100):
    try:
        producer.send('test', b'some_message_bytes')
    except:
        print('doh')

推荐答案

通常,您的主机名似乎无法解析. ping ubuntukafka 是否有效?如果没有,那么您将需要调整通过 advertised.listeners 返回的Kafka,使其成为外部IP而不是主机名

Generally, seems your hostnames aren't resolvable. Does ping ubuntukafka work? If not, then you'll need to adjust what you're making Kafka return via advertised.listeners to be the external IP rather than the hostname

listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://10.75.1.247:9092

这篇关于Kafka连接到节点ubuntukafka:9092(id:0 rack:null)出错(org.apache.kafka.clients.NetworkClient)java.net.UnknownHostException:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆