kafka 不能接受消息
1:[root@localhost bin]# /usr/local/kafka1/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
1111
22222
另外一个session有:
[root@localhost bin]#bin/kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic test
有报错:
[2016-10-09 15:36:41,877] ERROR Error when sending message to topic test with key: null, value: 4 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
于是google ,
解决方法:
Vi /usr/local/kafka1/config/server.properties
修改listeners=PLAINTEXT://10.33.97.111:9092
为:
listeners=PLAINTEXT://0.0.0.0:9092
问题即可解决!
但是又带来一 个问题,tomcat 日志文件里面狂报错!
2016-10-09 15:42:01-[WARN] [org.apache.kafka.common.network.Selector] Error in I/O with /0.0.0.0
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.kafka.common.network.Selector.poll(Selector.java:238)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:192)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:191)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:122)
at java.lang.Thread.run(Thread.java:745)
不得已又要找解决方法:
其实方法很简单,只要不用localhost,换成ip地址即可!
[root@localhost bin]# /usr/local/kafka1/bin/kafka-console-producer.sh --broker-list 10.33.97.111:9092 --topic test
另外一个session:
[root@localhost bin]# /usr/local/kafka1/bin/kafka-console-consumer.sh --zookeeper 10.33.97.111:2181 --from-beginning --topic test
即可!
为什么localhost不行,而ip地址可以,因为配置文件里面指定的是ip地址,而没使用localhost
2:kafka 启动失败:
提示:
Caused by: java.net.UnknownHostException: kafka1: kakfa1: unknown error
解决方法:/etc/hosts中加入本地解析
10.10.11.89 kafka01
阅读(9713) | 评论(0) | 转发(0) |