Java Eureka 服务器的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37187327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:05:28  来源:igfitidea点击:

Problems with Eureka server

javaspringspring-cloudnetflix-eureka

提问by slippery

I have a local eureka server and one client

我有一个本地尤里卡服务器和一个客户端

Eureka:

尤里卡:

server:
 port: 1111

eureka:
 instance:
   prefer-ip-address: true
 client:
   registerWithEureka: false
   fetchRegistry: false
   serviceUrl:
      defaultZone: http://127.0.0.1:1111/eureka/
 server:
   waitTimeInMsWhenSyncEmpty: 0    

Client:

客户:

eureka:
  instance:
    prefer-ip-address: true
  client:
    serviceUrl:
    defaultZone: http://127.0.0.1:1111/eureka/

I have 2 problems:

我有两个问题:

1) Eureka server throws in log:

1)尤里卡服务器抛出日志:

NullPointerException: at com.netflix.eureka.resources.StatusResource.isReplicaAvailable

NullPointerException:在 com.netflix.eureka.resources.StatusResource.isReplicaAvailable

2) The client connecting with Eureka, but after some time I see in his log next:

2) 客户端与 Eureka 连接,但一段时间后我在他的日志中看到:

RedirectingEurekaHttpClient : Request execution error javax.ws.rs.WebApplicationException: null at com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:110)

RetryableEurekaHttpClient : Request execution failure DiscoveryClient : DiscoveryClient_MW/192.168.0.100:client:8080 - was unable to send heartbeat!

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server

RedirectingEurekaHttpClient:请求执行错误 javax.ws.rs.WebApplicationException:com.netflix.discovery.provider.DiscoveryJerseyProvider.readFrom(DiscoveryJerseyProvider.java:110) 处为空

RetryableEurekaHttpClient : 请求执行失败 DiscoveryClient : DiscoveryClient_MW/192.168.0.100:client:8080 - 无法发送心跳!

com.netflix.discovery.shared.transport.TransportException:无法在任何已知服务器上执行请求

In log Eureka I see:

在日志尤里卡我看到:

InstanceRegistry : DS: Registry: lease doesn't exist, registering resource: CLIENT - 192.168.0.100:client:8080 InstanceResource : Not Found (Renew): CLIENT - 192.168.0.100:client:8080

InstanceRegistry:DS:Registry:租约不存在,注册资源:CLIENT - 192.168.0.100:client:8080 InstanceResource:未找到(续订):CLIENT - 192.168.0.100:client:8080

In Eureka web console the client has a UP status, but also there is a big inscription:

在 Eureka Web 控制台中,客户端具有 UP 状态,但还有一个很大的铭文:

RENEWALS ARE LESSER THAN THE THRESHOLD. THE SELF PRESERVATION MODE IS TURNED OFF.THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEM

续订少于阈值。自我保护模式已关闭。如果网络/其他问题,这可能无法保护实例到期

Although connection is working and I can get link to my client throught Eureka.

尽管连接正常,但我可以通过 Eureka 获得到我的客户端的链接。

Could you explain what it means and how I can get rid from that?

你能解释一下这意味着什么以及我如何摆脱它吗?

回答by u6852245

serviceUrl:
defaultZone: http://127.0.0.1:1111/eureka/

in client setting YML, you should add space before "defaultZone" like this:

在客户端设置 YML 中,您应该在“defaultZone”之前添加空格,如下所示:

serviceUrl:
  defaultZone: http://127.0.0.1:1111/eureka/

else defaultZone is same level with serviceUrl. thanks

否则 defaultZone 与 serviceUrl 处于同一级别。谢谢