七、Spring Colud Turbine详解(二):Turbine监控多个集群

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/makyan/article/details/88715166

7.3. Turbine集群监控:配置多个集群组


1、集群分组


将futurecloud-hystrix-cluster1项目复制3份,分别为:
futurecloud-hystrix-cluster4、futurecloud-hystrix-cluster5、futurecloud-hystrix-cluster6
将futurecloud-hystrix-cluster1、futurecloud-hystrix-cluster2、futurecloud-hystrix-cluster3作为一个集群组,集群名称为:BASECLUSTER
将futurecloud-hystrix-cluster4、futurecloud-hystrix-cluster5、futurecloud-hystrix-cluster6作为一个集群组,集群名称为:HACLUSTER
在以上6个项目的application.yml文件中配置各自所属集群,添加属性:eureka.instance.metadata-map.cluster: 集群名 。
futurecloud-hystrix-cluster1、futurecloud-hystrix-cluster2、futurecloud-hystrix-cluster3 配置如下:


#将此服务注册到eureka 服务上
eureka:
  client:
    serviceUrl:
      defaultZone: http://user:123@localhost:10000/eureka
  instance:
    prefer-ip-address: true  #将注册到eureka服务的实例使用ip地址
    metadata-map:
      cluster: BASECLUSTER  #此服务属于BASECLUSTER
    status-page-url-path: /actuator/info
    health-check-url-path: /actuator/health
management:
  endpoints:
    web:
      exposure:
        include: "*"
      cors:
        allowed-origins: "*"
        allowed-methods: "*"

futurecloud-hystrix-cluster4、futurecloud-hystrix-cluster5、futurecloud-hystrix-cluster6 配置如下:


#将此服务注册到eureka 服务上
eureka:
  client:
    serviceUrl:
      defaultZone: http://user:123@localhost:10000/eureka
  instance:
    prefer-ip-address: true  #将注册到eureka服务的实例使用ip地址
    metadata-map:
      cluster: HACLUSTER  #此服务属于HACLUSTER
    status-page-url-path: /actuator/info
    health-check-url-path: /actuator/health
management:
  endpoints:
    web:
      exposure:
        include: "*"
      cors:
        allowed-origins: "*"
        allowed-methods: "*"

2、配置futurecloud-turbine


#2、集群分组
turbine:
  aggregator:
    clusterConfig: BASECLUSTER,HACLUSTER
  appConfig: futurecloud-hystrix-cluster1,futurecloud-hystrix-cluster2,futurecloud-hystrix-cluster3,futurecloud-hystrix-cluster4,futurecloud-hystrix-cluster5,futurecloud-hystrix-cluster6
  # 指定集群名称,访问BASECLUSTER集群时:http://host:port/turbine.stream?cluster=BASECLUSTER
  clusterNameExpression: metadata['cluster']
  combine-host-port: true

3、依次启动服务:

futurecloud-service
#以下启动无顺序要求
futurecloud-user
futurecloud-hystrix-cluster1
futurecloud-hystrix-cluster2
futurecloud-hystrix-cluster3
futurecloud-hystrix-cluster4
futurecloud-hystrix-cluster5
futurecloud-hystrix-cluster6
futurecloud-turbine

访问http://localhost:9988/hystrix 进入HystrixDashBoard界面,输入http://localhost:9988/turbine.stream?cluster=BASECLUSTER 查看BASECLUSTER集群监控,类似的,查看HACLUSTER,将BASECLUSTER参数换成HACLUSTER

猜你喜欢

转载自blog.csdn.net/makyan/article/details/88715166