Hi,
Following the _kafka documentation_
<http://kafka.apache.org/documentation.html#quickstart>, I succeeded in
Step 1: Download the code, Step 2: Start the server and Step 3: Create a
topic in three different terminals.
While I tried Step 4: Send some messages, the problem happened, the
producer for the topic "test" could be started, however, I got an
exception in the producer console (the fourth terminal) after I sent
"This is a message" in the producer console. The exception looks like
:"kafka.common.FailedToSendMessageException: Failed to send messages
after 3 tries."
I put the detail information to the attachment "producer_terminal.log".
The attachement "server.log.2013-10-11-05" keeps a piece of information
about java.net.ConnectException that seems to be the key of the problem.
But I have no idea how this can happen.
I also tried to have a consumer connecting to the topic ready before
sending the message in producer terminal, the problem was the same.
My environment:
CentOS 6.4 (x64), kafka-0.8.0-beta1-src, jdk 1.6.0_31
Can anyone help? Thanks in advance.
Best regards,
WangXu(Alvin)
[2013-10-11 06:13:22,562] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 26 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,564] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,603] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,604] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:22,606] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 27 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,606] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,619] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,621] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:22,621] ERROR Failed to collate messages by topic, partition
due to: Failed to fetch topic metadata for topic: test
(kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:22,622] INFO Back off for 100 ms before retrying send.
Remaining retries = 3 (kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:22,723] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 28 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,724] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,744] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,745] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:22,746] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 29 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,747] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,761] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,762] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:22,762] ERROR Failed to collate messages by topic, partition
due to: Failed to fetch topic metadata for topic: test
(kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:22,763] INFO Back off for 100 ms before retrying send.
Remaining retries = 2 (kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:22,864] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 30 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,865] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,878] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,880] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:22,881] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 31 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,881] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,894] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:22,895] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:22,895] ERROR Failed to collate messages by topic, partition
due to: Failed to fetch topic metadata for topic: test
(kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:22,896] INFO Back off for 100 ms before retrying send.
Remaining retries = 1 (kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:22,997] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 32 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:22,998] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:23,011] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:23,012] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:23,014] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 33 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:23,014] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:23,027] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:23,028] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:23,029] ERROR Failed to collate messages by topic, partition
due to: Failed to fetch topic metadata for topic: test
(kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:23,029] INFO Back off for 100 ms before retrying send.
Remaining retries = 0 (kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:23,131] INFO Fetching metadata from broker
id:0,host:localhost,port:9092 with correlation id 34 for 1 topic(s) Set(test)
(kafka.client.ClientUtils$)
[2013-10-11 06:13:23,131] INFO Connected to localhost:9092 for producing
(kafka.producer.SyncProducer)
[2013-10-11 06:13:23,144] INFO Disconnecting from localhost:9092
(kafka.producer.SyncProducer)
[2013-10-11 06:13:23,145] WARN Error while fetching metadata [{TopicMetadata
for topic test ->
No partition metadata for topic test due to
kafka.common.LeaderNotAvailableException}] for topic [test]: class
kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2013-10-11 06:13:23,146] ERROR Failed to send requests for topics test with
correlation ids in [26,34] (kafka.producer.async.DefaultEventHandler)
[2013-10-11 06:13:23,146] ERROR Error in handling batch of 1 events
(kafka.producer.async.ProducerSendThread)
kafka.common.FailedToSendMessageException: Failed to send messages after 3
tries.
at
kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:90)
at
kafka.producer.async.ProducerSendThread.tryToHandle(ProducerSendThread.scala:104)
at
kafka.producer.async.ProducerSendThread$$anonfun$processEvents$3.apply(ProducerSendThread.scala:87)
at
kafka.producer.async.ProducerSendThread$$anonfun$processEvents$3.apply(ProducerSendThread.scala:67)
at scala.collection.immutable.Stream.foreach(Stream.scala:254)
at
kafka.producer.async.ProducerSendThread.processEvents(ProducerSendThread.scala:66)
at
kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:44)
[2013-10-11 06:32:08,571] ERROR Error while electing or becoming leader on
broker 0 (kafka.server.ZookeeperLeaderElector)
java.net.ConnectException: Connection timed out
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:500)
at kafka.network.BlockingChannel.connect(BlockingChannel.scala:57)
at
kafka.controller.ControllerChannelManager.kafka$controller$ControllerChannelManager$$addNewBroker(ControllerChannelManager.scala:84)
at
kafka.controller.ControllerChannelManager$$anonfun$1.apply(ControllerChannelManager.scala:35)
at
kafka.controller.ControllerChannelManager$$anonfun$1.apply(ControllerChannelManager.scala:35)
at scala.collection.immutable.Set$Set1.foreach(Set.scala:81)
at
kafka.controller.ControllerChannelManager.<init>(ControllerChannelManager.scala:35)
at
kafka.controller.KafkaController.startChannelManager(KafkaController.scala:503)
at
kafka.controller.KafkaController.initializeControllerContext(KafkaController.scala:467)
at
kafka.controller.KafkaController.onControllerFailover(KafkaController.scala:215)
at
kafka.controller.KafkaController$$anonfun$1.apply$mcV$sp(KafkaController.scala:89)
at
kafka.server.ZookeeperLeaderElector.elect(ZookeeperLeaderElector.scala:53)
at
kafka.server.ZookeeperLeaderElector$LeaderChangeListener.handleDataDeleted(ZookeeperLeaderElector.scala:106)
at org.I0Itec.zkclient.ZkClient$6.run(ZkClient.java:549)
at org.I0Itec.zkclient.ZkEventThread.run(ZkEventThread.java:71)
[2013-10-11 06:32:08,636] INFO 0 successfully elected as leader
(kafka.server.ZookeeperLeaderElector)