In a distributed environment such as microservices, we need to take full account of the failure situation, so a high-availability deployment of individual components must be considered in a production environment, as is the case with service registries.
The high availability of the Eureka Server is actually about registering itself as a service to other registries, so that a set of registered registries can be implemented to achieve a high-availability effect by synchronizing the list of services with each other.
Create a new project Eureka-cluster and Eureka-cluster2
Project creation refer to the building of the Service registration center above
Http://www.cnblogs.com/HanShisi/p/8319856.html
Not here to repeat.
The difference lies in the configuration of the Application.properties file.
The configuration of the Eureka-cluster is as follows:
Spring.application.name=eureka-server
server.port=1111
Eureka.instance.hostname=peer1
Eureka.client.serviceurl.defaultzone=http://peer2:1112/eureka
The configuration of the Eureka-cluster2 is as follows:
Spring.application.name=eureka-server
server.port=1112
Eureka.instance.hostname=peer2
Eureka.client.serviceurl.defaultzone=http://peer1:1111/eureka
Note:
Add the following configuration to the C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 Peer1
127.0.0.1 Peer2
At the same time, we will modify the service provider that is in the above http://www.cnblogs.com/HanShisi/p/8320022.html hello-service configuration slightly
# Service Name, registration center to mark the service
Spring.application.name=hello-service
# Specify the registration center
Eureka.client.serviceurl.defaultzone=http://peer1:1111/eureka/,http://peer2:1112/eureka
The above-mentioned main eureka.client.serviceUrl.defaultZone values have been modified to register this service in Peer1 and Peer2 respectively
Start Eureka-cluster, Eureka-cluster2, and Hello-service separately
respectively through
http://peer1:1111/
http://peer2:1112/
Visit the Registration center
This is where a simple service registry cluster is built.
Spring Cloud Eureka 4 (Highly available service registry)