Reference: <<spring Cloud Micro-service combat >>
In a distributed environment such as the microservices architecture, each component needs to be highly available for deployment.
Eureka Server High Availability is actually registering itself as a service to other service registries, thus forming a set of mutually registered service registries to synchronize the service inventory to achieve a high availability effect.
Building a two-node service registry cluster
to Build a node service registry cluster:
1. Create the application-peer1.properties as a configuration for the Peer1 Service Center and Point Serviceurl to Peer2:
spring.application.name=eureka-serverserver.port=1001eureka.instance.hostname= Peer1eureka.instance.prefer-ip-address=trueeureka.client.serviceUrl.defaultZone=http: // 192.168.1.2:1002/eureka/
2. Create the application-peer2.properties as a configuration for the Peer2 Service Center and Point Serviceurl to Peer1:
spring.application.name=eureka-Serverserver.port=1002eureka.instance.hostname= Peer2eureka.instance.prefer-ip-address=trueeureka.client.serviceUrl.defaultZone=http: // 192.168.1.2:1001/eureka/
Start Peer1 and Peer2 by Spring.profiles.active properties, respectively
java -jar eureka-server-1.0. 0. Jar--spring.profiles.active=peer1-jar eureka-server-1.0. 0. Jar--spring.profiles.active=peer2
After starting two items, visit Peer1 's registry http://localhost:1001/
Spring Cloud Eureka High-Availability Registration center