Zookeeper 使用中出现的错误排查

Zookeeper 使用中出现的错误排查

启动

确保 springCloud 与 zookeeper 都启动成功,并且已注册进zookeeper中,本次使用单机版zookeeper编写。
1、centos7中启动 zookeeper 启动成功,截图如下:

在这里插入图片描述

2、在IDEA中启动 springCloud 成功,截图如下:

在这里插入图片描述
在这里插入图片描述

3、zookeeper 客户端中已有注册进入的 服务,截图如下

在这里插入图片描述

错误日志-01

单独访问 服务提供者没什么问题,但是当消费者使用 RestTemplate 作为客户端访问服务提供者 payment-service 时,使用服务名访问出现如下错误日志,如下图:

2022-04-03 16:00:12.139 ERROR 21600 --- [p-nio-80-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://payment-service/payment/zk": connect timed out; nested exception is java.net.SocketTimeoutException: connect timed out] with root cause

java.net.SocketTimeoutException: connect timed out

在这里插入图片描述

解决方案如下:

  1. 查看 linux 服务器上防火墙是否关闭,或者开放该 2181 端口
  2. 如在虚拟机安装的zookeeper,查看本机是否能ping通 linux 服务器IP和端口,cmd命令:telnet 192.168.15.130 2181
  3. 如windows10本机有防火墙,检查是否关闭防火墙,或者防火墙开放端口
  4. 如使用 RestTemplate 作为客户端访问zookeeper服务,确认是否已在RestTemplate配置类上添加注解:@LoadBalanced
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值