kafka安装

安装教程

Kafka 安装及快速入门

问题

在生产消息时,发生如下问题:

1
WARN Error while fetching metadata with correlation id 1 : {test=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

controller.log日志如下:

1
2
3
4
5
6
[2018-11-08 10:26:48,704] WARN [Controller-0-to-broker-0-send-thread], Controller 0's connection to broker 222.221.5.253:9092 (id: 0 rack: null) was unsuccessful (kafka.controller.RequestSendThread)
java.net.SocketTimeoutException: Failed to connect within 30000 ms
at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:233)
at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:185)
at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:184)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)

解决

修改配置文件config/server.properties后重新启动zookeeper和kafka即可。

修改配置如下:

1
2
#原配置:listeners=PLAINTEXT://:9092  
listeners=PLAINTEXT://localhost:9092

常用命令

查看当前消费位置

1
./bin/kafka-consumer-groups.sh --bootstrap-server 172.16.123.12:9092,172.16.123.13:9092,172.16.123.14:9092 --describe --group userservice
>