2017-05-08 66 views
2

幾天前我試圖在沒有Docker的情況下運行Kafka,我再次失敗了。這很難安裝。所以,我決定使用Docker,然後我再次失敗。可能是什麼問題呢?如何在OS X上使用Docker運行Kafka?


我跑以下命令:

git clone https://github.com/confluentinc/cp-docker-images 
cd cp-docker-images/examples/kafka-single-node 
docker-compose up 

順便說一句,這是我的:

  • 泊塢版本:17.03.1-CE
  • 碼頭工人組成的版本: 1.11.2,build dfed245

我下載了OS X的新Docker here

邊注意:OS X的新Docker使用與以前不同的體系結構,因此解決了OS X中Docker的許多以前的問題。因此,我相信,匯合Docker文檔中討論的大多數問題將更容易解決。


錯誤日誌:

kafka_1  | [2017-05-08 21:00:37,382] WARN [Controller-1-to-broker-1-send-thread], Controller 1 epoch 1 fails to send request (type: UpdateMetadataRequest=, controllerId=1, controllerEpoch=1, partitionStates={}, liveBrokers=(id=1, endPoints=(host=localhost, port=29092, listenerName=ListenerName(PLAINTEXT), securityProtocol=PLAINTEXT), rack=null)) to broker localhost:29092 (id: 1 rack: null). Reconnecting to broker. (kafka.controller.RequestSendThread) 
kafka_1  | java.io.IOException: Connection to 1 was disconnected before the response was read 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:114) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:112) 
kafka_1  | at scala.Option.foreach(Option.scala:257) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:112) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:108) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$.recursivePoll$1(NetworkClientBlockingOps.scala:136) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$.kafka$utils$NetworkClientBlockingOps$$pollContinuously$extension(NetworkClientBlockingOps.scala:142) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$.blockingSendAndReceive$extension(NetworkClientBlockingOps.scala:108) 
kafka_1  | at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:196) 
kafka_1  | at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:188) 
kafka_1  | at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) 
kafka_1  | [2017-05-08 21:00:37,484] INFO [Controller-1-to-broker-1-send-thread], Controller 1 connected to localhost:29092 (id: 1 rack: null) for sending state change requests (kafka.controller.RequestSendThread) 
kafka_1  | [2017-05-08 21:00:37,486] ERROR Processor got uncaught exception. (kafka.network.Processor) 
kafka_1  | java.lang.NoClassDefFoundError: Could not initialize class kafka.network.RequestChannel$ 
kafka_1  | at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:111) 
kafka_1  | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:513) 
kafka_1  | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:505) 
kafka_1  | at scala.collection.Iterator$class.foreach(Iterator.scala:893) 
kafka_1  | at scala.collection.AbstractIterator.foreach(Iterator.scala:1336) 
kafka_1  | at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) 
kafka_1  | at scala.collection.AbstractIterable.foreach(Iterable.scala:54) 
kafka_1  | at kafka.network.Processor.processCompletedReceives(SocketServer.scala:505) 
kafka_1  | at kafka.network.Processor.run(SocketServer.scala:433) 
kafka_1  | at java.lang.Thread.run(Thread.java:745) 
kafka_1  | [2017-05-08 21:01:07,516] WARN [Controller-1-to-broker-1-send-thread], Controller 1 epoch 1 fails to send request (type: UpdateMetadataRequest=, controllerId=1, controllerEpoch=1, partitionStates={}, liveBrokers=(id=1, endPoints=(host=localhost, port=29092, listenerName=ListenerName(PLAINTEXT), securityProtocol=PLAINTEXT), rack=null)) to broker localhost:29092 (id: 1 rack: null). Reconnecting to broker. (kafka.controller.RequestSendThread) 
kafka_1  | java.io.IOException: Connection to 1 was disconnected before the response was read 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:114) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1$$anonfun$apply$1.apply(NetworkClientBlockingOps.scala:112) 
kafka_1  | at scala.Option.foreach(Option.scala:257) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:112) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$$anonfun$blockingSendAndReceive$extension$1.apply(NetworkClientBlockingOps.scala:108) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$.recursivePoll$1(NetworkClientBlockingOps.scala:136) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$.kafka$utils$NetworkClientBlockingOps$$pollContinuously$extension(NetworkClientBlockingOps.scala:142) 
kafka_1  | at kafka.utils.NetworkClientBlockingOps$.blockingSendAndReceive$extension(NetworkClientBlockingOps.scala:108) 
kafka_1  | at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:196) 
kafka_1  | at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:188) 
kafka_1  | at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63) 
kafka_1  | [2017-05-08 21:01:07,618] INFO [Controller-1-to-broker-1-send-thread], Controller 1 connected to localhost:29092 (id: 1 rack: null) for sending state change requests (kafka.controller.RequestSendThread) 
kafka_1  | [2017-05-08 21:01:07,619] ERROR Processor got uncaught exception. (kafka.network.Processor) 
kafka_1  | java.lang.NoClassDefFoundError: Could not initialize class kafka.network.RequestChannel$ 
kafka_1  | at kafka.network.RequestChannel$Request.<init>(RequestChannel.scala:111) 
kafka_1  | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:513) 
kafka_1  | at kafka.network.Processor$$anonfun$processCompletedReceives$1.apply(SocketServer.scala:505) 
kafka_1  | at scala.collection.Iterator$class.foreach(Iterator.scala:893) 
kafka_1  | at scala.collection.AbstractIterator.foreach(Iterator.scala:1336) 
kafka_1  | at scala.collection.IterableLike$class.foreach(IterableLike.scala:72) 
kafka_1  | at scala.collection.AbstractIterable.foreach(Iterable.scala:54) 
kafka_1  | at kafka.network.Processor.processCompletedReceives(SocketServer.scala:505) 
kafka_1  | at kafka.network.Processor.run(SocketServer.scala:433) 
kafka_1  | at java.lang.Thread.run(Thread.java:745) 

回答

4

泊塢最近更名爲白鯨,並且引起了我的問題。我需要在我的docker-compose配置中添加moby作爲本地主機。

通過添加extra_hosts參數解析莫比爲localhost將解決這個問題:

extra_hosts: 
    - "moby:127.0.0.1" 

定影有關此錯誤拉請求是here

要獲得此修復程序,請鍵入:git pull origin pull/258/head

如果您還想了解這方面的根本原因,請參閱click here

+0

但是,仍然存在問題。我無法從我的主機系統訪問Kafka暴露的端口。哦,我的Mac上的Docker。 –

+0

將moby和任何其他容器/服務主機名的別名添加到localhost的行上的/ etc/hosts文件中。 –

+0

它不適用於羣集kafka(示例/ kafka-cluster)。你有一個例子嗎? –