zoukankan      html  css  js  c++  java
  • Eureka-服务注册与发现组件

    一、Eureka是Netflix开发的服务组件

      本身是一个基于REST的服务,Spring Cloud将它集成在其子项目spring-cloud-netflix中,以实现Spring cloud的服务发现功能

      

    Eureka 他的源码在github上面:
    https://github.com/Netflix/eureka/
    他的文档:
    https://github.com/Netflix/eureka/wiki
    他的架构介绍:High level architecture:
    https://github.com/Netflix/eureka/wiki/Eureka-at-a-glance

    二、Eureka主要概念

      1、Eureka使用了AWS里的区域(Region)和可用区(Availability Zone,AZ)

      

           2、Eureka架构图

      

      Register:服务注册

      Renew:服务的续期

      Cancel:服务下线(客户端主动发起)

      Eviction:服务剔除(90秒)

      Application Serivce:服务生产者

      Application Client:服务消费者

           us-east-1c:美东区域

    三、Eureka在微服务中的应用

      1、Application.properties:

    server.port=8761
    #取消向eureka server(注册中心)注册
    eureka.client.register-with-eureka=false
    #取消向eureka server(注册中心)获取注册信息
    eureka.client.fetch-registry=false
    #eureka 提供服务发现的地址
    eureka.client.service-url.defaultZone=http://localhost:8761/eureka

      2、启动类增加注解@EnableEurekaServer

    #加入spring cloud父POM及spring-cloud-starter-eureka-server
    <dependency>
    	<groupId>org.springframework.cloud</groupId>
    	<artifactId>spring-cloud-starter-eureka-server</artifactId>
    </dependency>

      3、为Eureka增加安全访问

        a、EurekaServer中:pom.xml

    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-security</artifactId>
    </dependency>

        b、EurekaServer中:application.properties

    #eureka 提供服务发现的地址
    eureka.client.service-url.defaultZone=http://zhy:777@localhost:8761/eureka
    #eureka.client.service-url.defaultZone=http://localhost:8761/eureka
    # 安全模块
    security.basic.enabled=true
    security.user.name=zhy
    security.user.password=777
    

      

  • 相关阅读:
    Python 参数设置
    python日志模块logging
    推荐一种快速提高英语口语的方法
    Windows 远程桌面文件传输的方法
    敏捷术语
    Timeout watchdog using a standby thread
    ZFS -世界上最高级的文件系统之一
    Linux下创建和删除用户
    linux 学习之路
    Difference between a Hard Link and Soft (Symbolic) Link
  • 原文地址:https://www.cnblogs.com/gamehiboy/p/9072158.html
Copyright © 2011-2022 走看看