【问题标题】:Spring Cloud - Eureka service discovery clusteringSpring Cloud - Eureka 服务发现集群
【发布时间】:2018-04-15 18:59:32
【问题描述】:

我尝试使用以下配置文件以点对点感知方式启动 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,反之亦然

【问题讨论】:

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


    【解决方案1】:

    找到了这个添加以下配置的解决方案:

    #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/
    

    【讨论】:

    • 在默认区域中提供不同的端口可能已经解决了您的问题,并且有利于学习。但是对于实际的生产系统,如果您手动提供端口,您并没有充分利用您正在使用的技术堆栈。
    • @mephis-slayer 在实际生产中,这些端口可以从命令行参数传递,如果我错了,请纠正我,或者我们有什么其他方法?
    • 如果你使用容器(docker),平台会处理它并且端口是动态分配的。
    猜你喜欢
    • 2018-04-24
    • 2016-05-26
    • 2017-02-20
    • 2015-04-11
    • 2018-04-29
    • 2016-02-15
    • 2018-10-18
    • 1970-01-01
    • 2016-02-22
    相关资源
    最近更新 更多