解决zookeeper报错:java.net.BindException: 地址已在使用,是因为端口被占用。显示Starting zookeeper ... STARTED,jps没有QuorumPeerMain进程。
问题截图:
看似Starting zookeeper ... STARTED,实则集群并没有启动起来。从jps没有QuorumPeerMain进程就能够看出来。


[main:NIOServerCnxnFactory@89] - 绑定到端口 0.0.0.0/0.0.0.0:2181 2023-11-09 21:05:49,443 [myid:2] - ERROR [main:QuorumPeerMain@89] - 发生意外异常,异常退出 java.net.BindException: 地址已在使用
这里我们通过打开zookeeper.out文件可以看到"2181"端口被占用。
解决方法:
第一步:拿到进程号

python
sudo netstat -nltp | grep 2181
第二步:杀掉该进程
python
sudo kill -9 4988
不同人的号码不一样,请大家执行第一步。
第三步:重启zookeeper


效果展示:
QuorumPeerMain终于出现了。成功!
