In the microservices architecture, we consider the failure situation, so in a production environment we need to deploy the various components of the service in a highly available deployment.
The high availability of Eureka Server is actually to register itself as a service to other service registries, thus forming a set of mutually registered service centers,
To achieve a high-availability effect by synchronizing the service list with each other.
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=1111eureka.instance.hostname= Peer1eureka.client.serviceUrl.defaultZone=http://peer2:1112/eureka/
2. Create the Application-pee2.properties, as a Peer2 service center configuration, than Serviceurl point to Peer1
spring.application.name=eureka-serverserver.port=1112eureka.instance.hostname= Peer2eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/
3. Add the configuration to the local host file so that the serviceurl configured in the host form can be properly accessed locally
127.0.0.1 peer1 127.0.0.1 peer2
4. Use the Spring.profiles.active property to start Peer1 separately, Peer2
Java-jar Eureka-server-0.0.1.jar--spring.profiles.active=-jar Eureka-server-0.0.1.jar-- Spring.profiles.active=peer2
5. Start complete
6. Visit http://peer1:1111/as follows:
7. Visit http://peer2:1112/as follows:
8. If we stop a service, we will find that the service will become this state Unavailable-replicas state
Spring Cloud Eureka Service governance (highly available service center)