我正在尝试在两个不同的区域运行一些应用程序:office和shahbour
根据我的阅读,如果我将preferSameZoneEureka
设置为true
,那么同一区域内的应用程序应始终一起通话,但就我而言,它正在进行循环搜索。下面是我的application.yml,这是所有应用程序共有的
eureka:
client:
preferSameZoneEureka: true
region: lebanon
serviceUrl:
office: http://localhost:8761/eureka/
shahbour: http://192.168.15.202:8761/eureka/
availabilityZones:
lebanon: office
instance:
leaseRenewalIntervalInSeconds: 10
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
zone: office
hystrix:
command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
---
spring:
profiles: shahbour
eureka:
instance:
metadataMap:
zone: shahbour
client:
availabilityZones:
lebanon: shahbour
我的理解是所有具有个人资料shahbour
的应用程序
active应该互相交谈,除非找不到它们回到区域office
答案 0 :(得分:1)
我发现我需要两个eureka才能完成上述工作,每个区域一个
下面是我的eureka配置
server:
port: ${PORT:8761}
---
spring:
profiles: office
eureka:
instance:
hostname: office
client:
serviceUrl:
office: http://office:8761/eureka/
shahbour: http://shahbour:8761/eureka/
---
spring:
profiles: shahbour
eureka:
instance:
hostname: shahbour
client:
serviceUrl:
office: http://office:8761/eureka/
shahbour: http://shahbour:8761/eureka/
和服务
eureka:
client:
preferSameZoneEureka: true
region: lebanon
serviceUrl:
office: http://office:8761/eureka/
shahbour: http://shahbour:8761/eureka/
availabilityZones:
lebanon: office,shahbour
instance:
leaseRenewalIntervalInSeconds: 10
metadataMap:
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
zone: office
hystrix:
command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
---
spring:
profiles: shahbour
eureka:
instance:
metadataMap:
zone: shahbour
client:
availabilityZones:
lebanon: shahbour,office
通过这样做,我可以使用办公区域的任何服务,但是一旦我在自己的环境(区域)上启动该服务,我就开始使用它。