High-Availability Registration center
In a distributed environment such as the microservices architecture, we need to take full account of the failure situation, so that the individual components must be highly available for deployment in a production environment. In the application.yml of Eureka-server we remember two sections of configuration. Let the service registry itself not register itself
Eureka: client: #由于该应用为注册中心, so set to false, the representative does not register itself with the registry false #由于注册中心的职责就是维护服务实例, It does not need to retrieve the service, so it is also set to False
Next we need to change the configuration file so that Eureke-server will register itself as a service to other service registries. This enables the formation of a set of mutually-registered service registries to synchronize the service list to achieve a high availability effect.
According to (1-1) Springcloud-eureka: Registration and discovery of the service is reformed.
Step one: Create a new two profiles application-peer1.properties and application-peer2.properties under the Maven Resources folder
Application-peer1.properties
Eureka.client.register-with-eureka=trueeureka.client.fetch-registry=truespring.application.name= eureka-ha-serverserver.port=8751eureka.instance.hostname=peer1eureka.client.serviceurl.defaultzone=http:// Peer2:8752/eureka
Application-peer2.properties
Eureka.client.register-with-eureka=trueeureka.client.fetch-registry=truespring.application.name= eureka-ha-serverserver.port=8752eureka.instance.hostname=peer2eureka.client.serviceurl.defaultzone=http:// Peer2:8751/eureka
Step Two: Change the Hosts file to C:\Windows\System32\drivers\etc, add
127.0.0.1 peer1127.0.0.1 Peer2
Step three: Start the service
Run mvn clean install in the project's Pom.xml directory. Then go down to the MAVEN repository and find the generated jar file and run
Java-jar Eureka-server-1.0.0.jar--spring.profiles.active=peer1java-jar Eureka-server-1.0.0.jar-- Spring.profiles.active=peer2
The highly available registry is configured
Https://gitee.com/huayicompany/springcloud-learn/tree/master/lesson2
Reference:
[1] "Springcloud Micro Service", electronic industry Press, Suphing
[2] Blog, http://blog.csdn.net/forezp/article/details/70183572
(2-1) Springcloue-eureka implementing a highly available registration center