连接zookeeper报错

本文记录了在使用ZooKeeper过程中遇到的连接失败问题及其解决办法。详细介绍了由于端口配置错误导致的连接拒绝异常,并给出了正确的配置建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

09:48:41,517  INFO ZooKeeper:100 - Client environment:user.name=cheng
09:48:41,517  INFO ZooKeeper:100 - Client environment:user.home=C:\Users\cheng
09:48:41,518  INFO ZooKeeper:100 - Client environment:user.dir=E:\eclipseworkspace01\pinyougou-parent\pinyougou-search-service
09:48:41,519  INFO ZooKeeper:438 - Initiating client connection, connectString=192.168.25.130:2881,192.168.25.130:2882,192.168.25.130:2883 sessionTimeout=60000 watcher=org.I0Itec.zkclient.ZkClient@25275eea
09:48:41,541  INFO ClientCnxn:1032 - Opening socket connection to server 192.168.25.130/192.168.25.130:2883. Will not attempt to authenticate using SASL (unknown error)
09:48:42,550  WARN ClientCnxn:1162 - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
    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:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
09:48:42,662  INFO ClientCnxn:1032 - Opening socket connection to server 192.168.25.130/192.168.25.130:2882. Will not attempt to authenticate using SASL (unknown error)
09:48:42,662  INFO ClientCnxn:876 - Socket connection established to 192.168.25.130/192.168.25.130:2882, initiating session
09:48:46,541  INFO ZkEventThread:82 - Terminate ZkClient event thread.
09:49:02,664  WARN ClientCnxn:1108 - Client session timed out, have not heard from server in 20002ms for sessionid 0x0
09:49:02,768  INFO ZooKeeper:684 - Session: 0x0 closed
09:49:02,772  WARN XmlWebApplicationContext:546 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jms.listener.DefaultMessageListenerContainer#0' defined in file [E:\eclipseworkspace01\pinyougou-parent\pinyougou-search-service\target\classes\spring\applicationContext-jms-consumer.xml]: Cannot resolve reference to bean 'itemSearchListener' while setting bean property 'messageListener'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemSearchListener': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pinyougou.search.service.ItemSearchService com.pinyougou.search.service.impl.ItemSearchListener.itemSearchService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'itemSearchServiceImpl' defined in file [E:\eclipseworkspace01\pinyougou-parent\pinyougou-search-service\target\classes\com\pinyougou\search\service\impl\ItemSearchServiceImpl.class]: Initialization of bean failed; nested exception is org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 5000
09:49:02,776  INFO ClientCnxn:519 - EventThread shut down for session: 0x0
09:49:02,780 ERROR ContextLoader:353 - Context initialization failed

错误原因:eclipse中连接zookeeper端口错误,应该配置为zoo.cfg中clientPort,而不是zookeeper集群之间通信的端口。
zookeeper集群中涉及到3个端口 zoo.cfg中: server.1=192.168.25.130:2881:3881,2881是zookeeper通信端口,3881是选举端口,clienPort是客户端连连接zookeeper端口

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值