Spring-cloud eureka 中的相同区域调用
Same zone calls in Spring-cloud eureka
我正在尝试 运行 两个不同区域中的一些应用程序: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
活动应该互相交谈,除非没有发现他们回退到区域 office
中的应用程序
我发现我需要两个 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
通过这样做,我可以在办公区使用任何服务,但一旦我在我自己的环境(区)上启动该服务,我就会开始使用它。
我正在尝试 运行 两个不同区域中的一些应用程序: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
活动应该互相交谈,除非没有发现他们回退到区域 office
我发现我需要两个 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
通过这样做,我可以在办公区使用任何服务,但一旦我在我自己的环境(区)上启动该服务,我就会开始使用它。