老师,我的连接超时了

老师,我的连接超时了

# 具体遇到的问题

这是我的命令 ./bin/zkCli.sh -server 39.97.251.11:2181 显示连接超时,没有显示welcome to Zookeeper

代码中的是连接超时显示的信息

# 报错信息的截图

# 相关课程内容截图

# 尝试过的解决思路和结果

# 粘贴全部相关代码,切记添加代码注释(请勿截图)

在这里输入代码,可通过选择【代码语言】突出显示

​java.net.ConnectException: 连接超时
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:342)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1262)
2020-11-06 09:21:20,252 [myid:39.97.251.11:2181] - INFO [main-SendThread(39.97.251.11:2181):ClientCnxn$SendThread@1154] - Opening socket connection to server 39.97.251.11/39.97.251.11:2181.
2020-11-06 09:21:20,253 [myid:39.97.251.11:2181] - INFO [main-SendThread(39.97.251.11:2181):ClientCnxn$SendThread@1156] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
2020-11-06 09:21:27,252 [myid:39.97.251.11:2181] - WARN [main-SendThread(39.97.251.11:2181):ClientCnxn$SendThread@1272] - Session 0x0 for sever 39.97.251.11/39.97.251.11:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
java.net.ConnectException: 连接超时
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:342)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1262)
2020-11-06 09:21:28,354 [myid:39.97.251.11:2181] - INFO [main-SendThread(39.97.251.11:2181):ClientCnxn$SendThread@1154] - Opening socket connection to server 39.97.251.11/39.97.251.11:2181.
2020-11-06 09:21:28,354 [myid:39.97.251.11:2181] - INFO [main-SendThread(39.97.251.11:2181):ClientCnxn$SendThread@1156] - SASL config status: Will not attempt to authenticate using SASL (unknown error)


正在回答

登陆购买课程后可参与讨论,去登陆

2回答

同学你好,

1、同学检查一下zookeeper启动成功了没有,如下:
./bin/Server.sh  status
http://img1.sycdn.imooc.com//climg/5fa6098b09fbe62b05230126.jpg

2、关闭防火墙
systemctl stop firewalld.service 
http://img1.sycdn.imooc.com//climg/5fa6097f09507e4005230126.jpg

​再连接试试

好帮手慕阿满 2020-11-06 18:21:19

同学你好,同学是连接远程的的zookeeper吗?

 ./bin/zkCli.sh -server 39.97.251.11:2181 显示连接超时,建议同学重新执行命令再试试。

另外建议同学使用ip addr命令查看ip地址是否正确。

建议同学先启动zookeeper,再使用代码链接。

祝:学习愉快~

  • 提问者 慕仰7036876 #1
    老师我连接的是远程云服务器上的zookeeper。我使用hostname -I查询了IP地址, 显示为172.27.160.232 ,所以我把命令改./bin/zkCli.sh -server 172.27.160.232:2181,终端显示拒绝连接。下面是错误代码,还夹杂些许乱码 Connecting to 172.27.160.232:2181 2020-11-06 12:52:06,203 [myid:] - INFO [main:Environment@98] - Client environment:zookeeper.version=3.6.0--b4c89dc7f6083829e18fae6e446907ae0b1f22d7, built on 02/25/2020 14:38 GMT 2020-11-06 12:52:06,208 [myid:] - INFO [main:Environment@98] - Client environment:host.name=iZ2zea4k45xs2e37aqeqwlZ 2020-11-06 12:52:06,209 [myid:] - INFO [main:Environment@98] - Client environment:java.version=1.8.0_202 2020-11-06 12:52:06,212 [myid:] - INFO [main:Environment@98] - Client environment:java.vendor=Oracle Corporation 2020-11-06 12:52:06,213 [myid:] - INFO [main:Environment@98] - Client environment:java.home=/usr/java/jdk1.8.0_202/jre 2020-11-06 12:52:06,213 [myid:] - INFO [main:Environment@98] - Client environment:java.class.path=/root/apache-zookeeper-3.6.0-bin/bin/../zookeeper-server/target/classes:/root/apache-zookeeper-3.6.0-bin/bin/../build/classes:/root/apache-zookeeper-3.6.0-bin/bin/../zookeeper-server/target/lib/*.jar:/root/apache-zookeeper-3.6.0-bin/bin/../build/lib/*.jar:/root/apache-zookeeper-3.6.0-bin/bin/../lib/
    2020-11-06 20:56:46
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师