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及服务注册中心代码 

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服务注册中心 代码 -----------------------------

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    集群地址

#服务注册中心 启动类

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 });
  }
}

 

posted on 2025-03-04 18:59  oktokeep  阅读(830)  评论(0)    收藏  举报