server.properties配置
broker.id=0
listeners = PLAINTEXT://127.0.0.1:9092
port=9092
advertised.listeners = PLAINTEXT://127.0.0.1:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=C:\Product-Files\apache\kafkas\kafka_2.11-1.0.0\config\tmp\kafka-logs
num.partitions=4
num.recovery.threads.per.data.dir=1
metadata.broker.list=127.0.0.1:9092
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=127.0.0.1:2181
zookeeer.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
zk配置信息
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
#数据目录
dataDir=C:\Product-Files\apache\zookeepers\zookeeper-3.4.10\data
#日志目录
dataLogDir=C:\Product-Files\apache\zookeepers\zookeeper-3.4.10\log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=10
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
kafka报错信息
[2018-01-02 11:25:56,190] FATAL Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server '127.0.0.1:2181' with timeout of 6000 ms
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1233)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:157)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:131)
at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:115)
at kafka.utils.ZkUtils$.withMetrics(ZkUtils.scala:92)
at kafka.server.KafkaServer.initZk(KafkaServer.scala:346)
at kafka.server.KafkaServer.startup(KafkaServer.scala:194)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
at kafka.Kafka$.main(Kafka.scala:92)
at kafka.Kafka.main(Kafka.scala)
[2018-01-02 11:25:56,191] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
[2018-01-02 11:25:56,200] INFO shutting down (kafka.server.KafkaServer)
[2018-01-02 11:25:56,218] INFO shut down completed (kafka.server.KafkaServer)
[2018-01-02 11:25:56,219] FATAL Exiting Kafka. (kafka.server.KafkaServerStartable)
[2018-01-02 11:25:56,225] INFO shutting down (kafka.server.KafkaServer)
zk console信息
2018-01-02 11:35:39,532 [myid:] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@373] - Exception causing close of session 0x160b4e45e5c0004 due to java.io.IOException: 你的主机中的软件中止了一个已建立的连接。
2018-01-02 11:35:39,537 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /127.0.0.1:54579 which had sessionid 0x160b4e45e5c0004
2018-01-02 11:35:46,000 [myid:] - INFO [SessionTracker:ZooKeeperServer@358] - Expiring session 0x160b4e45e5c0001, timeout of 6000ms exceeded
2018-01-02 11:35:48,994 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x160b4e45e5c0001
2018-01-02 11:36:10,000 [myid:] - INFO [SessionTracker:ZooKeeperServer@358] - Expiring session 0x160b4e45e5c0004, timeout of 30000ms exceeded
2018-01-02 11:36:10,000 [myid:] - INFO [SessionTracker:ZooKeeperServer@358] - Expiring session 0x160b4e45e5c0002, timeout of 30000ms exceeded
2018-01-02 11:36:10,000 [myid:] - INFO [SessionTracker:ZooKeeperServer@358] - Expiring session 0x160b4e45e5c0003, timeout of 30000ms exceeded
2018-01-02 11:36:10,001 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x160b4e45e5c0004
2018-01-02 11:36:10,001 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x160b4e45e5c0002
2018-01-02 11:36:10,001 [myid:] - INFO [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x160b4e45e5c0003
楼主问题时怎么解决的
在kafka的配置中(server.properties) 把连接zookeeper的超时时间改久些就可以了 在server.properties 中加入以下配置 zookeeper.connection.timeout.ms=6000000 如果已经存在这个配置 就直接修改值
检查你的zookeeper的myid和kafka的brokerid,我是虚拟机克隆的忘记改了,报了一样的错误
你要再看看你的生产者和消费者配置文件里的端口号,创建代码是2181 9092 我记得是不一样的,我之前也和你一样
已经解决,办法是请执行一遍,zookeeper的关闭命令:
1、如果是kafka自带的,执行\bin\windows\zookeeper-server-stop.bat
2、如果是自行安装zookeeper,。。。。。(自行网上查查标准的关闭zookeeper命令)
你的zookeeper是在本机吗?
在本机的,我用kafka内置的zk就不报错,用自己搭的zk环境就出错
telnet通吗?
开启zk,无论是外部搭建还是内置zk执行该命令(telnet 127.0.0.1:2181)都出现: 正在连接127.0.0.1:2181...无法打开到主机的连接。 在端口 23: 连接失败
telnet 127.0.0.1 2181
要空格的。
可以....
你配置的没错,我怀疑你zk没起来
可能是你说的这个,但是我遇到另外一个问题,就是每次重启zk和kafka时,先启动zk再启动kafka会报:另一个程序正在使用此文件,进程无法访问。
谷歌翻译:
telnet 127.0.0.1 2181
启动kafka报错
好坑怎么办
看看zk启动成功了没,telnet一下,网络问题。
启动成功了
好烦啊搞了几天不行,你qq多少,我发截图给你
Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'.
您好,我也是启动kafka报错,说是超时,困扰了好多天了,请问你是怎么解决的,求回复!!!
https://blog.csdn.net/A1229451567/article/details/83817881
打开看,我写成了文档
你这文档写了个锤子,从头到尾说一遍。超时错误咋解决没说啊
你的答案