Eureka服务器和eureka客户端分离tomcat服务器

时间:2017-03-09 15:21:41

标签: spring tomcat netflix-eureka

我正在寻找一种能够将Eureka服务器部署到与Eureka客户端不同的tomcat服务器的方法。

这是客户端application.yml:

eureka:
  client:
    registryFetchIntervalSeconds: 5
  instance:
    preferIpAddress: true
    leaseRenewalIntervalInSeconds: 10

server:
  port: 8080

spring:
  application.name: my-client
  jmx:
      default-domain: my-client

和服务器application.yml看起来像:

server:
  port: 8761
eureka:
  client:
    registerWithEureka: false
    fetchRegistry: false

如果我将它们部署到同一个tomcat-server,它的工作正常。但是,如果我只使用服务器启动tomcat,然后使用客户端启动服务器,则会出现以下错误:

2017-03-09 16:17:58.496  INFO 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2017-03-09 16:17:58.496  INFO 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2017-03-09 16:17:58.496  INFO 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2017-03-09 16:18:04.740  WARN 7693 --- [on(2)-127.0.0.1] c.n.d.s.t.d.RetryableEurekaHttpClient    : Request execution failure with status code 404; retrying on another server if available
2017-03-09 16:18:04.745 ERROR 7693 --- [on(2)-127.0.0.1] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_MYCLIENT-CLIENT/192.168.196.141:my-client:8080 - was unable to refresh its cache! status = Cannot execute request on any known server

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
    at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.4.12.jar:1.4.12]
    at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.getApplications(EurekaHttpClientDecorator.java:134) ~[eureka-client-1.4.12.jar:1.4.12]

bootstrap.yml和application.yml有什么区别?

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

您的客户 application.yml 没有关于您的eureka服务器运行位置的信息。客户应该向eureka服务器注册,因为您需要配置客户端 application.yml < / strong>如下

eureka:
 client:
  serviceUrl:
       defaultZone:http:localhost:8081/eureka/

 instance:     
  instanceId:application_name:${random.value}