前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >com.netflix.client.ClientException Load balancer does not have available server for client及服务注册中心代码

com.netflix.client.ClientException Load balancer does not have available server for client及服务注册中心代码

作者头像
oktokeep
发布2025-03-05 08:08:06
发布2025-03-05 08:08:06
8500
代码可运行
举报
文章被收录于专栏:第三方工具第三方工具
运行总次数:0
代码可运行

com.netflix.client.ClientException Load balancer does not have available server for client及服务注册中心代码 

Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: test-manageShortUrl-service 解决方案:测试环境的eureka服务注册中心 重启解决问题。 短链服务,注册中心提示不可用。将Eureka注册中心重启解决。

##重启命令: pwd ./startup.sh (bin目录)

##查看是否网络通 telnet ip 端口号

根据eureka服务注册中心的端口号查找日志目录 ps -ef | grep "1246" com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

1.检查网络:确保网络没有问题,客户端可以访问服务注册中心和服务实例。 2.查看日志:查看服务注册中心、服务提供者以及客户端的日志,看是否有更详细的错误信息可以帮助定位问题。 3.重启服务:有时候重启服务注册中心、服务提供者或者客户端可以解决问题。 4.检查配置:检查客户端和服务端的配置文件,确认服务名称、端口等设置正确无误。

eureka配置 - Apollo 项目微服务配置 eureka.client.fetchRegistry = true eureka.client.serviceUrl.defaultZone = http://xxx:1246/eureka/ (配置集群中的一个地址即可) eureka.instance.prefer-ip-address = true hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds = 5000 ribbon.ReadTimeout = 5000 ribbon.ConnectTimeout = 5000

----------------------------- eureka服务注册中心 代码 -----------------------------

代码语言:javascript
代码运行次数:0
复制
eurekaServer Apollo
server.port = 1246
spring.application.name = eurekaServer
eureka.server.enableSelfPreservation = false
## 主动失效检测间隔,配置成5秒
eureka.server.evictionIntervalTimerInMs = 5000
## 禁用readOnlyCacheMap
eureka.server.useReadOnlyResponseCache = false
eureka.instance.prefer-ip-address = true
eureka.instance.hostname = ${spring.cloud.client.ipAddress}
eureka.instance.instance-id = ${spring.cloud.client.ipAddress}:${server.port}
## 心跳间隔,5秒
eureka.instance.leaseRenewalIntervalInSeconds = 5
## 没有心跳的淘汰时间,10秒
eureka.instance.leaseExpirationDurationInSeconds = 10
eureka.client.serviceUrl.defaultZone = http://xxx:1246/eureka,http://xxx2:1246/eureka,http://xxx3:1246/eureka    集群地址

#服务注册中心 启动类

代码语言:javascript
代码运行次数:0
复制
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaClient
@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication extends SpringBootServletInitializer
{
  public static void main(String[] args)
  {
    SpringApplication.run(EurekaServerApplication.class, args);
  }
  
  protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
  {
    return builder.sources(new Class[] { EurekaServerApplication.class });
  }
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-03-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档