Meet Eureka for the first time

I have only recently begun to have to learn the distributed architecture stage of microservices. I recently started to learn SpringCloud H version (currently the latest version). First I learned from the service registry Eureka. This blog post is mainly a learning record of my own, and there is something wrong. I hope everyone will let you know about the place! ! !

One: First of all, the version of springCloud and springBoot corresponds to the problem:

Two: There are more things you need to master when learning springCloud: × is a technology that has been slowly eliminated.

 Three: eureka service registry, including a client (consumers and providers belong to the client of eureka), a server (providing service registration services)

The current latest version of H version can directly tell whether it is the server or the client, unlike before, it can’t be distinguished.

<!--eureka-server 2020.02 The latest version of eureka service [server]-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<!--eureka-server 2020.02 The latest version of eureka service [client]-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

 

 

Four: The previous relationship between the registration center, service consumers, and service providers

 

 Five: Eureka principle analysis:

When I started learning, I didn't understand point 4, what is the "service alias"?

---Answer: It is an instance of a service provider, that is, the name of a microservice; in a non-stand-alone cluster, no matter how many service providers there are, this instance is the same.

So the next question is, how do you know which provider the consumer is calling (if there are multiple providers)?

---Answer: If there are two providers 8001 and 8002, it is to use polling to call the interface. One will go to the provider 8001, and the other will go to 8002.

The specific remote call is called through the RestTemplate template.

Six: The main code of the consumer of the eureka client: There are several important places, all in the picture.

 

Seven: The yml of the provider of the eureka client. There are two providers in the example, and only one is shown:

 

Eight: eureka server yml, there are two servers in the example, only one is shown:

 

Nine: Architecture diagram: 7001 and 7002 are two servers (to form a cluster), 80 is the consumer of the eureka client, and 8001 and 8002 are the provider of the client (to form a cluster)

 

Guess you like

Origin blog.csdn.net/zhangleiyes123/article/details/106734980