(2-1) Springcloue-eureka implementing a highly available registration center

Source: Internet
Author: User

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

Related Article

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.