Springcloud's Eureka Cluster

Source: Internet
Author: User

Before we introduced the Springcloud registry Eureka, but there is a single point of failure problem, a registration center is far from meeting the actual production environment, now we introduce how to build a Eureka cluster.

A: Cluster environment construction

We first build two registration center project, a call Eureka_register_master, a call eureka_register_salve. The port of Master is 7998,salve port is 7999.

The configuration file for Eureka_register_master application.properties is as follows:

server.port=7998eureka.client.register-with-eureka=falseEureka.client.fetch -registry=falsespring.application.name=eureka-servereureka.instance.hostname= mastereureka.client.service-url.defaultzone=http://Salve:7999/eureka

The configuration file for Eureka_register_salve application.properties is as follows:

server.port=7998eureka.client.register-with-eureka=falseEureka.client.fetch -registry=falsespring.application.name=eureka-servereureka.instance.hostname= mastereureka.client.service-url.defaultzone=http://Salve:7999/eureka

The startup file for Eureka_register_master is as follows:

Package Com.ysl;import Org.springframework.boot.springapplication;import Org.springframework.boot.autoconfigure.springbootapplication;import Org.springframework.cloud.netflix.eureka.server.EnableEurekaServer, @EnableEurekaServer @springbootapplication Public class  application {    publicstaticvoid   Main (string[] args) {        springapplication.run (application. class , args);}    }

The startup file for Eureka_register_salve is as follows:

Package Com.ysl;import Org.springframework.boot.springapplication;import Org.springframework.boot.autoconfigure.springbootapplication;import Org.springframework.cloud.netflix.eureka.server.EnableEurekaServer, @EnableEurekaServer @springbootapplication Public class  application {    publicstaticvoid   Main (string[] args) {        springapplication.run (application. class , args);}    }

Start:

If the jar is started, the parameter--spring.profiles.active=matser or--spring.profiles.active=salve is required.

Open http://127.0.0.1:7998/and http://127.0.0.1:7999/respectively such as:

   by looking at Port 7998 is matser its registered-replicas pointing to http://backup:7999/eureka/, Port 7999 is backup, and its registered-replicas points to http://master:7999/eureka/.

Two: Service-side registration

After setting up multiple registries, our service configuration does not require much change just to modify the application.properties serviceurl of the SERVICE01 project as follows:

Eureka.client.serviceurl.defaultzone=http://master:7998/eureka/,http://salve  : 7999/eureka/,

Of course, you can also bind an address, eureka.client.serviceurl.defaultzone=http://master:7998/eureka/both of these bindings.

Three: Cluster understanding

Although we use two nodes as an example above, we may need to build more than two Eureka server nodes in the production environment because of the load and so on. So how to configure Serviceurl to synchronize services in a cluster requires a deeper understanding of the synchronization mechanism between nodes to make decisions. We use a graph to understand the cluster.

  

Springcloud Eureka Cluster

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.