【问题标题】:Eureka based configuration server breaking actuator endpoints基于 Eureka 的配置服务器破坏执行器端点
【发布时间】:2015-09-11 07:58:35
【问题描述】:

我将我的服务设置为使用基于 spring cloud eureka 的配置服务器。

版本信息:spring cloud 1.0.1.RELEASE

当我将它设置为固定端点时,我可以看到它获得了正确的配置文件,并且我可以访问执行器端点,如健康、信息等,因此 .../manage/info 返回正确的信息。

但是,当我将其设置为使用发现时,相同的执行器端点在尝试访问它们时会超时。

在每种情况下,都会检索和下载配置文件(包括日志文件)。

我如何设置配置服务器和书签服务(使用配置服务器的服务)有问题吗?

我的配置服务器设置如下:

server:
  port: 8888
  contextPath: /configurationservice

eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    leaseRenewalIntervalInSeconds: 10
    statusPageUrlPath: /configurationservice/info
    homePageUrlPath: /configurationservice/
    healthCheckUrlPath: /configurationservice/health
    preferIpAddress: true

spring:
  cloud:
    config:
      server:
        native:
          searchLocations: file:/Users/larrymitchell/libertas/configserver/configfiles

服务 bootstrap.yml 设置为:

spring:
  profiles:
    default: development
    active: development
  application:
    name: bookmarkservice
  cloud:
    config:
      enabled: true # note this needs to be turned on if you wnat the config server to work
#      uri: http://localhost:8888/configurationservice
      label: 1.0.0
      discovery:
        enabled: true
        serviceId: configurationservice

application.yml 设置为:

# general spring settings
spring:
  application:
    name: bookmarkservice
  profiles:
    default: development
    active: development    
# name of the service
service:
  name: bookmarkservice

# embedded web server settings
# some of these are specific to tomcat
server:
  port: 9001
  # the context path is the part after http:/localhost:8080
  contextPath: /bookmarkservice
  tomcat:
    basedir: target/tomcat
    uri-encoding: UTF-8

management:
  context-path: /manage
  security:
    enabled: false

eureka:
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    statusPageUrlPath: /bookmarkservice/manage/info
    homePageUrlPath: /bookmarkservice/manage
    healthCheckUrlPath: /bookmarkservice/manage/health
    preferIpAddress: true

书签服务的启动日志如下:

2015-06-24 17:52:49.806 DEBUG 11234 --- [           main] o.s.web.client.RestTemplate              : Created GET request for "http://10.132.1.56:8888/configurationservice/bookmarkservice/development/1.0.0"
2015-06-24 17:52:49.890 DEBUG 11234 --- [           main] o.s.web.client.RestTemplate              : Setting request Accept header to [application/json, application/*+json]
2015-06-24 17:52:50.439 DEBUG 11234 --- [           main] o.s.web.client.RestTemplate              : GET request for "http://10.132.1.56:8888/configurationservice/bookmarkservice/development/1.0.0" resulted in 200 (OK)
2015-06-24 17:52:50.441 DEBUG 11234 --- [           main] o.s.web.client.RestTemplate              : Reading [class org.springframework.cloud.config.environment.Environment] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@2b07e607]
2015-06-24 17:52:50.466  INFO 11234 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='file:/Users/larrymitchell/libertas/configserver/configfiles/1.0.0/bookmarkservice-development.yml']]]
2015-06-24 17:52:50.503  INFO 11234 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5fa23965: startup date [Wed Jun 24 17:52:50 EDT 2015]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5cced717
2015-06-24 17:52:51.723  WARN 11234 --- [           main] .i.s.PathMatchingResourcePatternResolver : Skipping [/var/folders/kq/ykvl3t4n3l71p7s9ymywb4ym0000gn/T/spring-boot-libs/06f98804e83cf4a94380b46591b976b1d17c36b8-eureka-client-1.1.147.jar] because it does not denote a directory
2015-06-24 17:52:53.662  INFO 11234 --- [           main] o.s.b.f.config.PropertiesFactoryBean     : Loading properties file from URL [jar:file:/Users/larrymitchell/libertas/vipaas/applicationservices/bookmarkservice/target/bookmarkservice.jar!/lib/spring-integration-core-4.1.2.RELEASE.jar!/META-INF/spring.integration.default.properties]

【问题讨论】:

  • 您有重现问题的项目吗?我无法复制。
  • 我正在整理一个。我认为这是某种图书馆冲突或类似的事情。但是,如果我能在我的服务的缩减版中做到这一点,我会把它放在一起并节食
  • @spencergibb,我创建了一个有问题的示例项目。我已经剥夺了所有额外东西的服务。该项目位于 github 的这个位置:github.com/larry13767/configproblem
  • 使用您的项目,我能够在书签服务http://localhost:9001/bookmarkservice/manage/env 中点击执行器端点。
  • 我让一位同事尝试过,他遇到了和我一样的情况。可以想象是环境和网络的问题。我会在他的另一台电脑上试试。您能否建议我打开任何日志以获取更多详细信息?

标签: spring-cloud


【解决方案1】:

好的,在与另一位同事讨论后,我发现了实际问题所在。 部分困惑是我正在使用 spring cloud (https://github.com/VanRoy/spring-cloud-dashboard),顺便说一句,这是一个很棒的前端。因此,当服务启动时,我们会看到它用于发现并检索正确的配置文件并加载它。在我去spring cloud控制台看到一个UP的设置后,表示它是通过发现发现并注册的。还有第二个状态指示器,即 Spring Cloud Dashboard 获取注册端点并获得健康的时间。在我的问题中,端点显示为 UNKNOWN。

如果我随后使用控制台中显示的端点并尝试信息执行器端点,则请求超时。这就是我的问题的本质

好的,那是什么问题?

基本上,因为我在 application.yml 中定义了 ,并且当服务在引导程序中注册时,它还不知道端口,然后它选择了默认值 8080(我的假设,因为它就是这样做的)。服务器端口在 application.yml 中设置为 9001,但发现看到注册为 8080,因此 Spring Cloud 控制台无法访问 localhost:8080/bookmarkservice/manage/health,因为该端点没有服务(实际上是 9001) .其他服务也找不到该服务。

通过将 server.port 移动到 bootstrap.yml,然后注册了正确的 rate 服务端点并且可以正确访问该服务。

【讨论】:

    猜你喜欢
    • 2016-09-26
    • 2020-05-22
    • 2017-05-21
    • 2016-02-15
    • 2015-08-26
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 1970-01-01
    相关资源
    最近更新 更多