SPRINGCLOUD02 Eureka Knowledge points, Eureka Server and client creation, Eureka server cluster, Eureka Client registration to cluster Eureka Server

Source: Internet
Author: User

1 Eureka Knowledge points

According to the function division:

Eureka consists of Eureka server and Eureka client

Divide by role:

Eureka consists of Eureka Server, service Provider, service Consumer

Eureka Server: Providing service registration and discovery (i.e.: Service registry)

Service Provider: Services providers (that is, services that provide data resources for other microservices), registering their service information with Eureka Server for service Consumer use

Service Consumer: Services Consumers (that is, services that require the logical processing of data resources provided by other services) to obtain service Provider information from Eureka Server to obtain the data resources provided by the service Provider

Tip 01: In fact, most microservices may be both service providers and consumer

1.1 Eureka Service Side

The Eureka server is used as a service registration server, which is equivalent to zookeeper in the Alibaba Micro Service architecture.

1.2 Eureka Client

The Eureka client is a Java client that simplifies the interaction with the server, acts as a polling load balancer, and provides failover support for the service.

2 Eureka Server Create "singleton mode"

Need to introduce Springcloud dependency Manager and Eureka Server dependencies when creating Eureka related projects

2.1 Creating with Idea

Release Notes:

jdk:1.8

maven:3.5

idea:2017.2 Flagship edition

2.1.1 Creating a Spingboot Project

2.1.2 Select dependent

Select dependencies only need to select the Eureka server dependency on it, I choose the other two dependencies just for the convenience of development

The 01:springboot version of the tip will be up-to-date by default, and since we are creating springcloud related projects, idea will automatically introduce us to Sprngcloud's dependency manager However, the version of the Springcloud dependency Manager and the version of the components provided by Springcloud are strictly required, please refer to the official website for details, and the version correspondence is as follows:

2.1.3 Modify the Pom.xml file according to the website's version request

According to the version of the website provided by the revision of the table can be

<?xml version= "1.0" encoding= "UTF-8"? ><project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http ://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelversion>4.0.0 </modelVersion> <groupId>cn.xinagxu</groupId> <artifactId>eureka</artifactId> <v Ersion>0.0.1-snapshot</version> <packaging>jar</packaging> <name>eureka</name> & Lt;description>demo Project for Spring boot</description> <parent> <groupId>org.springframework.boot</groupId> &        Lt;artifactid>spring-boot-starter-parent</artifactid> <version>2.0.4.RELEASE</version> <relativePath/> <!--lookup parent from repository to </parent> <properties> <pro Ject.build.sourceencoding>utf-8</project.build.sourceencoding> <project.reporting.outputencoding >UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-c loud.version>finchley.sr1</spring-cloud.version> </properties> <dependencies> <depend Ency> <groupId>org.springframework.cloud</groupId> <artifactid>spring-cloud-sta rter-netflix-eureka-server</artifactid> </dependency> <dependency> <groupid& gt;org.springframework.boot</groupid> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scop            e> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupid>org.springframework.boot& Lt;/groupid> <artifactId>spring-boot-starter-test</artifactId> <scope>test</            scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <a Rtifactid>spring-cloud-dependencies</artifactid> <version>${spring-cloud.version}</versio N> <type>pom</type> <scope>Import</scope> </dependency> </dependencies> </dependencyManagement> &LT;BUILD&G        T                <plugins> <plugin> <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>
Pom.xml2.1.4 Adding @enableeurekaserver annotations on the startup class

@EnableEurekaServer is to indicate that this project is used as a Eureka server

2.1.5 Launch Application

An error message will be given when the app is launched, as follows:

Error reason: Eureka server will also be like the Eureka client can register to a registry, from Eureka source can be seen Eureka the default Registry is:/HTTP localhost:8761/eureka/, since we did not create this project, the Eureka Server project that was created will continue to register with this nonexistent registry, so The above error will continue to appear in the console

Workaround: Turn off the Eureka server to another registry or register for a separate function "that is: turn off the Eureka client feature of Eureka server ", Add the following configuration in the configuration file to achieve this function "PS: Official Recommendation"

Tip 01: Although the Eureka Server to another registry or its own registration function, but the console will still error, but this time only two error messages, Maybe we configured the information in Eureka Server These two error messages are not valid until the registration request has been initiated to the default registry

Tip 02: The effect of starting Eureka server after Eureka Server is turned off to another registry or a feature that is registered alone

Workaround 02: Register to another registry (because there is no other registry now, so this post registers it with itself), add the following configuration to the configuration file to achieve this function:

Tip 01: Although the Eureka Server is configured to register itself, the console will still get an error, but this time there will only be two errors, possibly the information we configured in Eureka Server These two error messages are not valid until the registration request has been initiated to the default registry

Tip 02: Configure the effect of Eureka server after starting Eureka server with the ability to register itself

2.2 Using MAVEN to create

Created according to official documents, pending update ... August 25, 2018 14:15:10

3 Eureka server Cluster

3.1 Creation of three Eureka server projects

Follow the 2.1 steps to create and, of course, copy the created project directly, or you can

3.2 Modifying configuration files for individual projects

      

    

SpringCloud02 Eureka Knowledge points, Eureka Server and client creation, Eureka Server-side cluster, Eureka client-to-cluster Eureka Server registration

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.