Spring Cloud notes Eureka high availability through clustering

Source: Internet
Author: User

Eureka implements service registration and discovery, plays a key role in spring cloud microservices, must be guaranteed to be highly available, and the conventional solution is nothing more than a cluster implementation. Here in the local machine to build a pseudo-cluster environment, through two nodes to register each other, and through the master and standby data synchronization to achieve high availability, the actual production environment may have multiple nodes, the same principle. The simple steps are as follows:

"Step1": The Eureka configuration file is as follows

Spring:application:name:eureka-Cluster---Spring:profiles:masterserver:port:8761eureka:instance:hostname:master Client:registerwitheureka:falseFetchregistry:falseserviceUrl:defaultZone:http://Backup:8762/eureka---Spring:profiles:backupserver:port:8762eureka:instance:hostname:backup Client:registerwitheureka:falseFetchregistry:falseserviceUrl:defaultZone:http://Master:8761/eureka

Note: Here the simulation is implemented over the port, and the machine host information needs to be configured:

192.168.31.11 Master
192.168.31.11 Backup

"Step2": Package the deployment and start

Package by mvn Install, then start separately,

Java-jar Eureka.jar--spring.profiles.active=master
Java-jar Eureka.jar--spring.profiles.active=backup

Specify spring.profiles.active at startup to implement a master and standby simulation.

"STEP3": Access test

Visit http://192.168.31.11:8761/details as follows:

Visit http://192.168.31.11:8762/details as follows:

"STEP4": Modify client, start client test

Client modified Eureka's registered address: eureka.client.serviceurl.defaultzone:http://master:8761/eureka/,http://backup:8762/eureka/, Start the client and then access Eureka View separately, which is already registered to each node.

If you stop one of the Eureka nodes and then start viewing again, you will see that the service information is synchronized from the available nodes to the current node.

Spring Cloud notes Eureka high availability through clustering

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.