SpringCloud created Eureka

What is Eureka

Eureka is a sub-module of Netflix, is one of the core modules -. Eureka is a REST-based services, for location services, the intermediate layer in order to achieve the cloud service discovery and failover. Service registration and discovery services for micro-architecture is very important, with service discovery and registration, just use the identifier of a service, you can access to the service without the need to modify the configuration file of a service call. Functions like the registry dubbo, such Zookeeper.

Eureka basic structure

SpringCloud encapsulates Netflix Eureka module developed to implement the service registration and discovery.

Eureka using the CS design architecture. Eureka Server as a service registration function of the server, which is a service registry.

And other micro-services system, use the client to connect to Eureka Eureka Server and maintaining the heartbeat connection. Such systems maintenance personnel can monitor each micro system service is functioning properly by Eureka Server. SpringCloud some of the other modules (such as Zuul) can be found in other micro-services system through Eureka Server, and implementation of relevant logic.

Eureka and architecture of contrast Dubbo

   

 

Eureka consists of two components: Eureka  Server and Eureka  Client

Eureka Server service registration services;

After each node starts, it will be registered in EurekaServer, so EurekaServer in the service registry will store information about all the available information service node, service node can visually see in the interface;

EurekaClient java is a client, to simplify the user interaction, the client Eureka Server also includes a built-in polling (round-robin) load load balancing algorithm. After the application starts, it will send a heartbeat to the Eureka Server (default period is 30 seconds). If Eureka Server in the heartbeat cycle no more heartbeat interfaces to a node, EurekaServer will remove this service node (default 90 seconds) from the service registry;

Eureka examples

  pom.xml file

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
<!--eureka依赖--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies>

  applicatio.yml file

Server: 
  Port: 1001 
Eureka: 
  Client: 
    ## does not register itself with the service center 
    the Register the -with-Eureka: false 
    ## showed himself registry 
    FETCH -registry: false 
    # Configure Client Access Address 
    Service - url: 
      defaultzone: HTTP : // localhost: 1001 / Eureka 
  instance: 
    #eureka server instance name 
    hostname: eureka1001.com

  Startup class

@SpringBootApplication
@EnableEurekaServer     //服务注册中心
public class SpringcloudEurekaServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringcloudEurekaServerApplication.class, args);
    }

}

  Results page

·····

Guess you like

Origin www.cnblogs.com/wnwn/p/12055837.html