kafka 中zookeeper报错 cant open channel to 2 at election address
Posted X糊涂仙儿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kafka 中zookeeper报错 cant open channel to 2 at election address相关的知识,希望对你有一定的参考价值。
kafka启动Zookeeper报错如下:
[2021-12-01 20:12:35,971] WARN Cannot open channel to 2 at election address /0.0.0.0:3888 (org.apache.zookeeper.server.quorum.QuorumCnxManager)
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:204)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:607)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:558)
at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:534)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:454)
at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$
解决方法:
在每台机器自身ip监听:
server.1=10.20.20.10:2888:3888
server.2=10.20.20.11:2888:3888
server.3=0.0.0.0:2888:3888
修改后,仍会有类似报错:
[2021-12-01 20:35:04,726] WARN Cannot open channel to 1 at election address /10.20.20.10:3888 (org.apache.zookeeper.server.quorum.QuorumCnxManager)
java.net.ConnectException: Connection refused (Connection refused)
解决如下,要细心不可马虎。引自stackoverflow:
I met the save question and solved it.
make sure the myid is the save with your configuration in the zoo.cfg.
please check your zoo.cfg file in your conf directory, which contains such content.
server.1=zookeeper1:2888:3888
server.2=zookeeper2:2888:3888
server.3=zookeeper3:2888:3888
and check the myid in your server dataDir directory. For example:
lets say the dataDir defined on the zoo.cfg is /home/admin/data
then on zookeeper1, you must have a file named myid and have value 1 on this file ;on zookeeper2, you must have a file named myid and have value 2 on this file; on zookeeper3, you must have a file named myid and have value 3 on this file.
if not configured like this, the server will listen on a wrong ip:port.
最终完美解决
以上是关于kafka 中zookeeper报错 cant open channel to 2 at election address的主要内容,如果未能解决你的问题,请参考以下文章
启动zookeeper和kafka时kafka报错或闪退一直无法启动
Kafka自带zookeeper报错INFO Got user-level KeeperException when processing xxx Error Path:/brokers Error:
kafka 创建消费者报错 consumer zookeeper is not a recognized option
kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn
kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn