微服務架構之spring cloud turbine

在前面介紹了spring cloud hystrix及其hystrix dashboard,但都是對單個項目的監控,對於一個爲項目而言,一定有不少微服務,一個一個去看很是的不方便,若是有一個能集中熔斷器監控的地方就完美了,spring cloud turbine 就實現了這樣的功能,這篇文章就來介紹spring cloud turbine。spring

(一) 版本說明express

a) Spring boot 2.0.6.RELEASE瀏覽器

b) Spring cloud Finchley.SR2app

c) Java version 1.8微服務

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

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

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

(二) 項目配置code

1. 項目設置server

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就介紹完了,若是在開發中遇到問題,也能夠留言共同探討共同進步。

相關文章
相關標籤/搜索