• 微服务架构之spring cloud turbine


    在前面介绍了spring cloud hystrix及其hystrix dashboard,但都是对单个项目的监控,对于一个为项目而言,必定有很多微服务,一个一个去看非常的不方便,如果有一个能集中熔断器监控的地方就完美了,spring cloud turbine 就实现了这样的功能,这篇文章就来介绍spring cloud turbine。

    (一) 版本说明

    a) Spring boot 2.0.6.RELEASE

    b) Spring cloud Finchley.SR2

    c) Java version 1.8

    d) spring-cloud-starter-netflix-hystrix 2.0.2.RELEASE

    e) spring-cloud-starter-netflix-hystrix-dashboard 2.0.2.RELEASE

    f) spring-cloud-starter-netflix-turbine 2.0.2.RELEASE

    (二) 项目配置

    1. 项目设置

    a) POM设置

    <dependency>
    
    <groupId>org.springframework.cloud</groupId>
    
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
    
    </dependency>
    
    <dependency>
    
    <groupId>org.springframework.cloud</groupId>
    
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    
    </dependency>
    
    <dependency>
    
    <groupId>org.springframework.cloud</groupId>
    
    <artifactId>spring-cloud-starter-netflix-turbine</artifactId>
    
    </dependency>

    b) application.yml配置文件

    eureka:
    
    datacenter: ctm
    
    environment: dev
    
    instance:
    
    hostname: 192.168.1.78
    
    prefer-ip-address: true
    
    ip-address: 192.168.1.129
    
    lease-renewal-interval-in-seconds: 10
    
    lease-expiration-duration-in-seconds: 30
    
    instance-id: ${eureka.instance.ip-address}:${server.port}
    
    client:
    
    service-url:
    
    defaultZone: http://${eureka.instance.hostname}:1001/eureka/,http://${eureka.instance.hostname}:1002/eureka/,http://${eureka.instance.hostname}:1003/eureka/
    
    fetch-registry: true
    
    register-with-eureka: true
    
    healthcheck:
    
    enabled: true
    
    turbine:
    
    aggregator:
    
    cluster-config: default
    
    app-config: clientservice,callbackservice
    
    cluster-name-expression: new String("default")

    c) 主要参数说明

    i. eureka.instance.prefer-ip-address 使用IP显示注册信息

    ii. eureka.instance.ip-address 实例IP地址,

    iii. eureka.instance.instance-id 自定义实例id,服务之间调用就是使用该配置,多个实例必须保证唯一性

    iv. eureka.client.service-url.defaultZone 注册中心地址

    v. turbine.app-config 设置要聚集的服务名称,这里是指注册的服务名字

    2. 项目运行

    a) 运行要监控的服务

    i. 为了演示聚集的效果,这里运行了2个服务者实例后,会在服务中心看到如下效果

    clip_image002

    b) 运行

    i. 运行turbine项目,如下图所示

    clip_image004

    c) 在浏览器中输入消费者地址服务地址,即可看到如下效果

    clip_image006

    在看板地址中输入http://localhost:1251/turbine.stream,然后点击Monitor Stream 按钮,即可看到熔断器监控,如果没有数据显示,可以用任何客户端调用几次API,即可看到聚合后的效果。

    clip_image008

      这样spring cloud turbine就介绍完了,如果在开发中遇到问题,也可以留言共同探讨共同进步。

  • 相关阅读:
    整除
    奇怪的生日礼物
    欧拉函数平方和
    奇怪的生日礼物(数论基础)
    整除(简单数论)
    Tarjan求割点
    构造双连通(tarjan)
    次小生成树
    机器扫边
    最短路径(树形DP)
  • 原文地址:https://www.cnblogs.com/lzh-boy/p/10381452.html
Copyright © 2020-2023  润新知