eureka服务过期 篇2
背景:
最近反馈的订单修改提示 远程操作失败。
分析下来是:中台订单服务有台在服务注册中心上面不稳定,运维分析下来可能是机器内存不足原因导致。内存资源是紧张
目前将根据服务名称来调用的方式修改成指定IP来调用。
后来从该出现问题的服务器上面挪出去了一个服务,释放出来内存资源,再分析日志,就没有发现该问题了。
查询服务注册中心的日志:
DS: Registry: expired lease for ORDER-API/hz-auto-tomcat-pro:order-api:8008
Cancelled instance ORDER-API/hz-auto-tomcat-pro:order-api:8008 (replication=false)
查询地址(服务注册中心的地址查看):
http://xxxx:1246/eureka/apps
根据端口号查询:可以查询变更的时间点等信息
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1737511886165</registrationTimestamp> 2025-01-22 10:11:26.1650
<lastRenewalTimestamp>1737517738827</lastRenewalTimestamp> 2025-01-22 11:48:58.8270
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1736747636809</serviceUpTimestamp> 2025-01-13 13:53:56.8090
</leaseInfo>
<lastUpdatedTimestamp>1737511886165</lastUpdatedTimestamp> 2025-01-22 10:11:26.1650
<lastDirtyTimestamp>1737511886082</lastDirtyTimestamp> 2025-01-22 10:11:26.0820
mysql查询时间戳:
SELECT FROM_UNIXTIME(1737515476780/1000);
feign.RetryableException: Connection refused (Connection refused) executing--eureka服务下线问题
有可能是服务挂了 然后后来又被运维脚本自动重启了
让运维检查下有没有自动重启过某一台上的服务
方案1:当调用失败的时候,把path直接替换为url;确保被调用端服务是正常的;
使用feign来调用。避开服务发现机制来调用。
替换前
@FeignClient(name="FEEINTE",path="/feeinte")
替换后
@FeignClient(name="FEEINTE",url="http://xxxx:1903/feeinte/") 不支持配置多个地址,只能配置一个ip, 自测发现。
FeignClient不支持配置多个URL,因为它是基于接口的,设计上只能指定一个服务URL。【关键】
@FeignClient(url = "${feignMyOrderApiUrl}" ,name="FEEINTE") //可以使用Apollo的配置 来指定IP地址
//启动类配置加载自定义feign路径
//如果使用Feign的客户端,请放开下列注释
@EnableFeignClients(basePackages = {"com.test.order.open", "com.test.order.commons","com.test.orderFee.feign"})
@EnableEurekaClient
@SpringBootApplication
public class TemplateApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(TemplateApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(TemplateApplication.class);
}
}
解决eureka注册中心网络拒绝访问指定IP地址,上线后的日志:恢复正常。
方案2:另外一个方向:自定义restTemplate访问,加上负载均衡。不使用feign来调用。
feign接口拒绝 feign.RetryableException: Connection refused (Connection refused) executing POST 篇1
https://cloud.tencent.com/developer/article/2502011
eureka服务过期 篇2
https://cloud.tencent.com/developer/article/2502012
指定IP换成负载均衡地址,微服务内存查看分配 篇3