Spring Cloud - Eureka服务发现集群

时间:2017-11-03 05:34:32

标签: spring-cloud netflix-eureka spring-cloud-netflix

我尝试使用以下配置文件在对等感知中启动Eureka服务。

#profile 1:

spring:
  application:
    name: service-registry
  profiles: p1
server:
  port: 8761
eureka:
  dashboard:
    enabled: false
    override: true
  enableselfPresentation: true
  shouldUseDns: true
  instance:
    appname: ${spring.application.name}
    instanceId: ${random.value}
  client:
    registerWithEureka: false
    fetchRegistry: false

#profile 2:

spring:
  application:
    name: service-registry
  profiles: p2
server:
  port: 8762
eureka:
  dashboard:
    enabled: false
    override: true
  enableselfPresentation: true
  shouldUseDns: true
  instance:
    appname: ${spring.application.name}
    instanceId: ${random.value}
  client:
    registerWithEureka: false
    fetchRegistry: false

使用这些配置文件启动eureka后,在端口8761的eureka仪表板上,我将DS副本视为localhost:8761,但不是localhost:8762 在localhost:8762 DS副本作为localhost:8761 如何将localhost的副本:8761作为localhost:8762,反之亦然

1 个答案:

答案 0 :(得分:0)

找到以下配置的解决方案:

#profile p1
eureka
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8762/eureka/
#profile p2
eureka
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/