0


连接zookeeper报错Connection refused: no further information

消费端启动类控制台循环打印:

java.net.ConnectException:Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(NativeMethod)~[na:1.8.0_251]
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)~[na:1.8.0_251]
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)~[zookeeper-3.4.9.jar:3.4.9-1757313]
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)~[zookeeper-3.4.9.jar:3.4.9-1757313]

查看application.properties配置的地址是否有误:

dubbo.application.name=provider-ticket

dubbo.registry.address=zookeeper://192.168.30.128:2181

dubbo.scan.base-packages=com.atguigu.ticket.service

查看zookeeper的配置文件zoo.cfg中的端口是否和配置的一样:
搜索文件所在位置

find /-name zoo.cfg

在这里插入图片描述
在这里插入图片描述
如不一致,可进行修改。

继续搜索zookeeper的启动命令所在的文件目录:

[root@aiguigu bin]# find / -name zkServer.sh/var/lib/docker/overlay2/383af248ee27a350fcf2c88f7a7cfe3f0f010db4668821784d745f2b452df266/diff/apache-zookeeper-3.8.0-bin/bin/zkServer.sh

进到搜索的目录下,进行启动zookeeper:

./zkServer.sh start

当我启动的时候发现有个报错:

[root@aiguigu bin]# ./zkServer.sh start/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /var/lib/docker/overlay2/383af248ee27a350fcf2c88f7a7cfe3f0f010db4668821784d745f2b452df266/diff/apache-zookeeper-3.8.0-bin/bin/../conf/zoo.cfg
grep: /var/lib/docker/overlay2/383af248ee27a350fcf2c88f7a7cfe3f0f010db4668821784d745f2b452df266/diff/apache-zookeeper-3.8.0-bin/bin/../conf/zoo.cfg: 没有那个文件或目录
grep: /var/lib/docker/overlay2/383af248ee27a350fcf2c88f7a7cfe3f0f010db4668821784d745f2b452df266/diff/apache-zookeeper-3.8.0-bin/bin/../conf/zoo.cfg: 没有那个文件或目录
mkdir: 无法创建目录"": 没有那个文件或目录
Starting zookeeper ... FAILED TO START

意思是在conf目录下没有找到zoo.cfg配置文件,于是我将zoo.cfg配置文件,复制了一份放到启动命令搜索的目录下,再次启动就成功了。

[root@aiguigu bin]# ./zkServer.sh start/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /var/lib/docker/overlay2/383af248ee27a350fcf2c88f7a7cfe3f0f010db4668821784d745f2b452df266/diff/apache-zookeeper-3.8.0-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查看zookeeper状态:

[root@aiguigu bin]# ./zkServer.sh status/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /var/lib/docker/overlay2/383af248ee27a350fcf2c88f7a7cfe3f0f010db4668821784d745f2b452df266/diff/apache-zookeeper-3.8.0-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone

启动成功,端口2181

重新运行代码:

如果遇到空指针情况,需要在服务提供端的启动类上加@EnableDubbo注解即可


本文转载自: https://blog.csdn.net/weixin_45293769/article/details/127438738
版权归原作者 notTu 所有, 如有侵权,请联系我们删除。

“连接zookeeper报错Connection refused: no further information”的评论:

还没有评论