High-availability configuration for Spring Cloud config Server

Source: Internet
Author: User

First look at the configuration of official documents

---spring:  profiles: peer1eureka:  instance:    hostname: peer1  client:    serviceUrl:      defaultZone: http://peer2/eureka/---spring:  profiles: peer2eureka:  instance:    hostname: peer2  client:    serviceUrl:      defaultZone: http://peer1/eureka/

两台注册中心的高可用的时候,就是分别注册到对方上去


同理,三台以上的时候
---spring:  profiles: peer1eureka:  instance:    hostname: peer1  client:    serviceUrl:      defaultZone: http://peer2/eureka/,http://peer3/eureka/---spring:  profiles: peer2eureka:  instance:    hostname: peer2  client:    serviceUrl:      defaultZone: http://peer1/eureka/,http://peer3/eureka/
---spring:  profiles: peer3eureka:  instance:    hostname: peer3  client:    serviceUrl:      defaultZone: http://peer1/eureka/,http://peer2/eureka/

不论多少台主机,都是将自己注册到除了自己之外的其他注册中心上去
不过这里有一个小问题,就是peer是一个主机名,如果想要使用还需要在host文件中配置,如果想要简单一点,只用ip就可以了。
---spring:  profiles: peer1
server:
port: 8761eureka: instance: client: serviceUrl: defaultZone: http://127.0.0.1:8762/eureka/,http://127.0.0.1:8763/eureka/---spring: profiles: peer2
server:
port: 8762eureka: instance: client: serviceUrl: defaultZone: http://127.0.0.1:8761/eureka/,http://127.0.0.1:8763/eureka/
---spring:  profiles: peer3
server:
port: 8763 eureka: instance: client: serviceUrl: defaultZone: http://127.0.0.1:8761/eureka/,http://127.0.0.1:8762/eureka/
这样就可以了,而且官方文档也是这么说的

如果您在一台知道自己的主机名的机器上运行(默认情况下使用java.net.InetAddress查找),则不需要eureka.instance.hostname


High-availability configuration for Spring Cloud config Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.