[英]How to set a Spring Cloud Eureka app's zone
This is probably a dumb question ;-). 这可能是一个愚蠢的问题;-)。
In Spring's ribbon code (ZonePreferenceServerListFilter), I see: 在Spring的功能区代码(ZonePreferenceServerListFilter)中,我看到:
if (ConfigurationManager.getDeploymentContext() != null) {
this.zone = ConfigurationManager.getDeploymentContext().getValue(
ContextKey.zone);
}
The zone name defaults to 'defaultZone'. 区域名称默认为“ defaultZone”。
How/where can I set that value for my application? 如何/在哪里为我的应用程序设置该值?
I tried setting eureka.instance.metadataMap.zone in application.yml but that did not work. 我尝试在application.yml中设置eureka.instance.metadataMap.zone,但这没有用。
Any suggestions? 有什么建议么?
Thanks. 谢谢。
Henry 亨利
I believe it is eureka.client.availabilityZones
which is a list. 我相信这是列表的eureka.client.availabilityZones
。 Then you can set eureka.client.serviceUrl.<yourzone>=<eurekaurlforthatzone
. 然后,您可以设置eureka.client.serviceUrl.<yourzone>=<eurekaurlforthatzone
。
If you have multiple zones, you may find some more details here: https://github.com/spring-cloud/spring-cloud-netflix/issues/991 如果您有多个区域,则可以在此处找到更多详细信息: https : //github.com/spring-cloud/spring-cloud-netflix/issues/991
With the enhancement provided there you can set the zone of the Eureka-Ribbon-Client with eureka.instance.metadataMap.zone
. 使用此处提供的增强功能,您可以使用eureka.instance.metadataMap.zone
设置Eureka-Ribbon-Client的eureka.instance.metadataMap.zone
。 If you use earlier versions of Spring Cloud you can still use the property "@zone"
in your application.yaml. 如果您使用早期版本的Spring Cloud,您仍然可以在"@zone"
使用属性"@zone"
。
The approach to use availabilityZones
to set the zone is limited to setups with only one zone, since the first one will be always used. 使用availabilityZones
设置区域的方法仅限于只有一个区域的设置,因为将始终使用第一个区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.