java1234开源博客系统
博客信息

Hystrix集群监控turbine

0
发布时间:『 2018-10-09 22:32』  博客类别:SpringCloud  阅读(3991) 评论(0)

前面Dashboard演示的仅仅是单机服务监控,实际项目基本都是集群,所以这里集群监控用的是turbine。


turbine是基于Dashboard的。


先搞个集群;

再microservice-student-provider-hystrix-1004项目的基础上再搞一个microservice-student-provider-hystrix-1005


代码和配置都复制一份,然后修改几个地方;

第一 yml配置 

server:

  port: 1005

instance-id: microservice-student-hystrix:1005 #客户端实例名称 


第二 启动类改成StudentProviderHystrixApplication_1005


这样的话 就有了 hystrix集群服务;


我们新建项目microservice-student-consumer-hystrix-turbine-91

pom.xml加下依赖

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-turbine</artifactId>
</dependency>



application.yml


server:

  port: 91

  context-path: /



eureka:

  client:

    service-url:

      defaultZone: http://eureka2001.java1234.com:2001/eureka/,http://eureka2002.java1234.com:2002/eureka/,http://eureka2003.java1234.com:2003/eureka/


turbine:

  app-config: microservice-student   # 指定要监控的应用名称

  clusterNameExpression: "'default'" #表示集群的名字为default


spring:

  application:

    name: turbine



新建启动类:StudentConsumerTurbineApplication_91

加注解:@EnableTurbine

package com.java1234;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.netflix.turbine.EnableTurbine;

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
@EnableTurbine
public class StudentConsumerTurbineApplication_91 {

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


测试:

先启动三个eureka,然后把1004  1005 带hystrix的服务都启动;

microservice-student-consumer-80这个也启动,方便测试;

dashboard,turbine启动;


这样的话 http://localhost/student/getInfo 就能调用服务集群;

http://localhost:91/turbine.stream  可以监控数据,实时ping 返回data

dd.png


进入仪表盘,输入地址


ddd.jpg


点击 进入集群监控仪表:

cccs.jpg



关键字:   Hystrix集群监控turbine  
关注Java1234微信公众号
博主信息
Java1234_小锋
(知识改变命运,技术改变世界)
Powered by Java1234 V3.0 Copyright © 2012-2016 Java知识分享网 版权所有