我正在对一组 Spring Cloud + Netflix OSS 应用程序进行原型设计,但在使用 Eureka 时遇到了麻烦。在我们的设置中,我们有一个 Spring Cloud Config Server + Eureka Server,然后是 2 个利用该服务器组件进行引导和服务发现的模块。
我遇到的问题是,如果我启动 2 个 Eureka Server 实例并尝试将它们配对(基于文档中的Two Peer Aware Eureka Servers),它们不会相互同步。请参阅下面的配置和/或GitHub 上的代码。
本质上,Peer1 启动并且看起来很好。Peer2 将启动并且看起来很好,两个对等点在服务中相互显示。但是,如果“UserService”模块启动并向 Peer1 注册自身,Peer2 将永远看不到它。如果我们随后启动指向 Peer2 的“Web”模块,它永远无法解析 UserService。他们基本上是孤立地行动。
我尝试了几种serviceUrl
在服务器和 Eureka 服务器实例上设置的组合,但无济于事。我只是配置错误吗?
对等体 1 / 默认配置:
server:
port: 8888
eureka:
dashboard:
path: /dashboard
instance:
hostname: peer1
leaseRenewalIntervalInSeconds: 3
client:
serviceUrl:
defaultZone: ${eureka.server.serviceUrl:http://localhost:${server.port}/eureka/}
server:
serviceUrl:
defaultZone: http://localhost:${server.port}/eureka/
peer2: http://peer2/eureka/
waitTimeInMsWhenSyncEmpty: 0
spring:
application:
name: demo-config-service
profiles:
active: native
# required for Spring Cloud Bus
rabbitmq:
host: ${DOCKER_IP:192.168.59.103}
port: 5672
username: guest
password: guest
virtualHost: /
cloud:
config:
server:
prefix: /configs
native:
searchLocations: /Users/dave/workspace/oss/distributed-spring/modules/config-server/src/main/resources/testConfigs
# git :
# uri: https://github.com/joshlong/microservices-lab-configuration
对等 2 配置:
server:
port: 8889
eureka:
dashboard:
path: /dashboard
instance:
hostname: peer2
leaseRenewalIntervalInSeconds: 3
client:
serviceUrl:
defaultZone: ${eureka.server.serviceUrl:http://localhost:${server.port}/eureka/}
server:
serviceUrl:
defaultZone: http://localhost:8888/eureka/
peer1: http://peer1/eureka/
waitTimeInMsWhenSyncEmpty: 0
spring:
application:
name: demo-config-service
profiles:
active: native
# required for Spring Cloud Bus
rabbitmq:
host: ${DOCKER_IP:192.168.59.103}
port: 5672
username: guest
password: guest
virtualHost: /
cloud:
config:
server:
prefix: /configs
native:
searchLocations: /Users/dave/workspace/oss/distributed-spring/modules/config-server/src/main/resources/testConfigs
# git :
# uri: https://github.com/joshlong/microservices-lab-configuration