为什么我不能联系卡夫卡/动物园管理员?(在一个码头工人)

时间:2023-01-07 22:45:54

I'm running Kafka (0.10.0.0) in a Docker on a Mac (w/docker-machine). I derived my Dockerfile from Spotify's, which means Kafka and Zookeeper run in the same image.

我在一台Mac (w/ Docker -machine)的Docker上运行Kafka(0.10.0.0)。我从Spotify那里得到了我的Dockerfile,这意味着卡夫卡和Zookeeper在同一个图像中运行。

My instance starts cleanly and poking around inside it appears everything is normal/OK.

我的实例干净利落地开始,在里面到处乱翻,似乎一切都很正常。

Docker maps ports 2181 and 9092 to high-ports 32822 and 32820 in this case. From outside my running Kafka Docker I am able to successfully telnet 192.168.99.100 32822 (where 192.168.99.100 is the IP of my docker-machine). From there I can issue a zookeeper command and get expected output.

Docker将端口2181和9092映射到高端口32822和32820。在运行Kafka Docker之外,我可以成功地telnet 192.168.99.100 32822(其中192.168.99.100是我的Docker -machine的IP)。在那里,我可以发布一个zookeeper命令并得到预期的输出。

It all seems so encouraging, but... I then try this code:

这一切似乎都令人鼓舞,但是……然后我尝试以下代码:

val numPartitions = 4
val replicationFactor = 1
val topicConfig = new java.util.Properties

// zookeeper = "192.168.99.100:32822"
val zkClient = ZkUtils(zookeeper, 10000, 10000, false)
try {
  AdminUtils.createTopic(zkClient, topic, numPartitions, replicationFactor, topicConfig)
} catch {
  case k: kafka.common.TopicExistsException => // do nothing...topic exists
}
zkClient.close()

This produces this error output:

这就产生了这个错误输出:

DEBUG ZkConnection - Creating new ZookKeeper instance to connect to 192.168.99.100:32822.
INFO  ZkEventThread - Starting ZkClient event thread.
INFO  ZooKeeper - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
INFO  ZooKeeper - Client environment:host.name=172.25.42.82
INFO  ZooKeeper - Client environment:java.version=1.8.0_60
INFO  ZooKeeper - Client environment:java.vendor=Oracle Corporation
INFO  ZooKeeper - Client environment:java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
INFO  ZooKeeper - Client environment:java.class.path=/usr/local/Cellar/sbt/0.13.11/libexec/sbt-launch.jar
INFO  ZooKeeper - Client environment:java.library.path=/Users/wmy965/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
INFO  ZooKeeper - Client environment:java.io.tmpdir=/var/folders/ph/ccz4n1qs62n0bn8mqdg94gswt1jlwk/T/
INFO  ZooKeeper - Client environment:java.compiler=<NA>
INFO  ZooKeeper - Client environment:os.name=Mac OS X
INFO  ZooKeeper - Client environment:os.arch=x86_64
INFO  ZooKeeper - Client environment:os.version=10.11.5
INFO  ZooKeeper - Client environment:user.name=wmy965
INFO  ZooKeeper - Client environment:user.home=/Users/wmy965
INFO  ZooKeeper - Client environment:user.dir=/Users/wmy965/git/LateKafka
INFO  ZooKeeper - Initiating client connection, connectString=192.168.99.100:32822 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@55397e3
DEBUG ClientCnxn - zookeeper.disableAutoWatchReset is false
DEBUG ZkClient - Awaiting connection to Zookeeper server
INFO  ZkClient - Waiting for keeper state SyncConnected
INFO  ClientCnxn - Opening socket connection to server 192.168.99.100/192.168.99.100:32822. Will not attempt to authenticate using SASL (unknown error)
WARN  ClientCnxn - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
DEBUG ClientCnxnSocketNIO - Ignoring exception during shutdown input
java.nio.channels.ClosedChannelException
    at sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:780)
    at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:399)
    at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:200)
    at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1110)
DEBUG ClientCnxnSocketNIO - Ignoring exception during shutdown output
java.nio.channels.ClosedChannelException
    at sun.nio.ch.SocketChannelImpl.shutdownOutput(SocketChannelImpl.java:797)
    at sun.nio.ch.SocketAdaptor.shutdownOutput(SocketAdaptor.java:407)
    at org.apache.zookeeper.ClientCnxnSocketNIO.cleanup(ClientCnxnSocketNIO.java:207)
    at org.apache.zookeeper.ClientCnxn$SendThread.cleanup(ClientCnxn.java:1185)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1110)
INFO  ClientCnxn - Opening socket connection to server 192.168.99.100/192.168.99.100:32822. Will not attempt to authenticate using SASL (unknown error)
INFO  ClientCnxn - Socket connection established to 192.168.99.100/192.168.99.100:32822, initiating session
DEBUG ClientCnxn - Session establishment request sent on 192.168.99.100/192.168.99.100:32822
INFO  ClientCnxn - Session establishment complete on server 192.168.99.100/192.168.99.100:32822, sessionid = 0x155225c51720000, negotiated timeout = 10000
DEBUG ZkClient - Received event: WatchedEvent state:SyncConnected type:None path:null
INFO  ZkClient - zookeeper state changed (SyncConnected)
DEBUG ZkClient - Leaving process event
DEBUG ZkClient - State is SyncConnected
DEBUG ClientCnxn - Reading reply sessionid:0x155225c51720000, packet:: clientPath:null serverPath:null finished:false header:: 1,8  replyHeader:: 1,1,-101  request:: '/brokers/ids,F  response:: v{}

It looks like I can't connect (presumably to zookeeper). Why not?

看起来我无法连接(大概是和动物园管理员)。为什么不呢?

2 个解决方案

#1


2  

In new kafka streams, the ip of producer must have been knowing by kafka (docker). Kafka send their uuid (you can show this in /etc/hosts inside kafka docker) and espect response from this.

在新的卡夫卡流中,制作人的ip一定是知道卡夫卡(docker)的。Kafka发送他们的uuid(您可以在Kafka docker的/etc/hosts中显示),并对其进行响应。

Summary:

简介:

Map uuid kafka docker to docker-machine in /etc/host of mac OS.

将uuid kafka docker映射到mac OS的/etc/host的docker-machine。

To help you, how to change etc/host file in mac:

为了帮助您,如何更改mac中的etc/host文件:

https://www.tekrevue.com/tip/edit-hosts-file-mac-os-x/

https://www.tekrevue.com/tip/edit-hosts-file-mac-os-x/

#2


0  

Cleaner would be to set advertised.listeners=host-ip:port since advertised.host.name and advertised.port are deprecated in Kafka server.properties file.

清洁器将被设置广告。监听器=主机-ip:从广告开始的端口。端口在Kafka服务器中被弃用。属性文件。

If set host-ip to 0.0.0.0 it will listen requests from anywhere. But it's insecure.

如果将主机-ip设置为0.0.0.0,它将侦听来自任何地方的请求。但它是不安全的。

#1


2  

In new kafka streams, the ip of producer must have been knowing by kafka (docker). Kafka send their uuid (you can show this in /etc/hosts inside kafka docker) and espect response from this.

在新的卡夫卡流中,制作人的ip一定是知道卡夫卡(docker)的。Kafka发送他们的uuid(您可以在Kafka docker的/etc/hosts中显示),并对其进行响应。

Summary:

简介:

Map uuid kafka docker to docker-machine in /etc/host of mac OS.

将uuid kafka docker映射到mac OS的/etc/host的docker-machine。

To help you, how to change etc/host file in mac:

为了帮助您,如何更改mac中的etc/host文件:

https://www.tekrevue.com/tip/edit-hosts-file-mac-os-x/

https://www.tekrevue.com/tip/edit-hosts-file-mac-os-x/

#2


0  

Cleaner would be to set advertised.listeners=host-ip:port since advertised.host.name and advertised.port are deprecated in Kafka server.properties file.

清洁器将被设置广告。监听器=主机-ip:从广告开始的端口。端口在Kafka服务器中被弃用。属性文件。

If set host-ip to 0.0.0.0 it will listen requests from anywhere. But it's insecure.

如果将主机-ip设置为0.0.0.0,它将侦听来自任何地方的请求。但它是不安全的。