问题描述
Kafka 2.8.1 ZooKeeper启动失败。
zookeeper-server-start.bat ../../config/zookeeper.properties
[2023-09-04 18:21:49,497] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2023-09-04 18:21:49,498] ERROR Unexpected exception, exiting abnormally (org.apache.zookeeper.server.ZooKeeperServerMain)
java.net.BindException: Address already in use: bind
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:555)
at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:89)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:81)
at org.apache.zookeeper.server.NIOServerCnxnFactory.configure(NIOServerCnxnFactory.java:687)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:144)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:107)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:65)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:128)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)
原因分析
2181端口被占用。
打开cmd。
netstat -ano |findstr 2181
无结果返回,找不到占用2181端口的程序。
解决方案
修改config/zookeeper.properties
找到:
clientPort=2181
改为:
clientPort=21810
重新启动ZooKeeper,启动成功。
[2023-09-04 18:32:51,963] INFO binding to port 0.0.0.0/0.0.0.0:21810 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2023-09-04 18:32:51,979] INFO zookeeper.snapshotSizeFactor = 0.33 (org.apache.zookeeper.server.ZKDatabase)
[2023-09-04 18:32:51,981] INFO Reading snapshot \tmp\zookeeper\version-2\snapshot.0 (org.apache.zookeeper.server.persistence.FileSnap)
[2023-09-04 18:32:51,988] INFO Snapshotting: 0x0 to \tmp\zookeeper\version-2\snapshot.0 (org.apache.zookeeper.server.persistence.FileTxnSnapLog)
[2023-09-04 18:32:51,999] INFO PrepRequestProcessor (sid:0) started, reconfigEnabled=false (org.apache.zookeeper.server.PrepRequestProcessor)
[2023-09-04 18:32:52,004] INFO Using checkIntervalMs=60000 maxPerMinute=10000 (org.apache.zookeeper.server.ContainerManager)
记得修改config/server.properties,不然Kafka Server无法连接。
找到:
zookeeper.connect=localhost:2181
改为:文章来源:https://www.toymoban.com/news/detail-701753.html
zookeeper.connect=localhost:21810
补充说明
在解决端口被占用的问题时,首先需要确认端口是否被占用,然后可以通过修改配置文件中的端口号来解决该问题。在修改端口号后,需要确保相关服务的配置也已经更新,以便系统能够正常连接。文章来源地址https://www.toymoban.com/news/detail-701753.html
到了这里,关于【Kafka】ZooKeeper启动失败报错java.net.BindException: Address already in use: bind的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!