Kafka开发时的异常

 

 

1、遇到Producer connection to hostname:9092 unsuccessful

 

14/12/29 11:57:39 INFO utils.VerifiableProperties: Verifying properties
14/12/29 11:57:39 INFO utils.VerifiableProperties: Property metadata.broker.list is overridden to master001:9092,master001:9092
14/12/29 11:57:39 INFO utils.VerifiableProperties: Property serializer.class is overridden to kafka.serializer.StringEncoder
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/maven_repo/repository/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/maven_repo/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
14/12/29 11:57:39 INFO client.ClientUtils$: Fetching metadata from broker id:1,host:master001,port:9092 with correlation id 0 for 1 topic(s) Set(topicName)
14/12/29 11:57:41 ERROR producer.SyncProducer: Producer connection to master001:9092 unsuccessful
java.nio.channels.UnresolvedAddressException
	at sun.nio.ch.Net.checkAddress(Net.java:127)
	at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:640)
	at kafka.network.BlockingChannel.connect(BlockingChannel.scala:57)
	at kafka.producer.SyncProducer.connect(SyncProducer.scala:141)
	at kafka.producer.SyncProducer.getOrMakeConnection(SyncProducer.scala:156)
	at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:68)
	at kafka.producer.SyncProducer.send(SyncProducer.scala:112)
	at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:53)
	at kafka.producer.BrokerPartitionInfo.updateInfo(BrokerPartitionInfo.scala:82)
	at kafka.producer.async.DefaultEventHandler$$anonfun$handle$1.apply$mcV$sp(DefaultEventHandler.scala:67)
	at kafka.utils.Utils$.swallow(Utils.scala:167)
	at kafka.utils.Logging$class.swallowError(Logging.scala:106)
	at kafka.utils.Utils$.swallowError(Utils.scala:46)
	at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:67)
	at kafka.producer.Producer.send(Producer.scala:76)
	at kafka.javaapi.producer.Producer.send(Producer.scala:33)
	at kafka.examples.Producer.run(Producer.java:46)

 解决办法:

    寻找linux下的/etc/hosts和window下的C:\Windows\System32\drivers\etc\hosts所有IP地址与主机名是否配置正确。

    最后发现一个低级错误,window下的hostname配置IP地址错误了。

 

192.168.0.36    hadoop.main
192.168.0.146   hadoop.slave1
192.168.0.142   slave001
192.168.146   master001

 注意:192.168.146   master001

 

 

 

你可能感兴趣的:(kafka)