从 spring 文档中,我看到我们可以一起拥有对等 eureka 服务器,所以对于 Eureka1,在 application.yml 中,我可以拥有:
spring:
profiles: peer1
eureka:
instance:
hostname: peer1
client:
serviceUrl:
defaultZone: http://peer2/eureka/
在 Eureka Server 2 中,我可以拥有:
spring:
profiles: peer2
eureka:
instance:
hostname: peer2
client:
serviceUrl:
defaultZone: http://peer1/eureka/
现在这两个eureka server 互相认识了,很好。但是,现在在配置客户端时,当他们再次注册 Eureka 时,该怎么做?
在我的客户端应用程序中,我有:
eureka:
instance:
hostname: ${host.instance.name:localhost}
nonSecurePort: ${host.instance.port:8080}
leaseRenewalIntervalInSeconds: 5 #default is 30, recommended to keep default
metadataMap:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
serviceUrl:
defaultZone: http://(eurekaServerHost):8761/eureka/
server:
port: ${host.instance.port:8080}
所以现在我的问题是我应该在客户端 application.yml 中使用 peer1 还是 peer2 作为 EurekaServerHost?
谢谢