Zipkin + Sleuth + RabbitMQ + Mysql 环境配置

一、Zipkin Server

  1. 依赖包如下:

	    	io.zipkin.java
		  	zipkin-autoconfigure-ui
		
		
		  	io.zipkin.java
		  	zipkin-server
		
		
		  	io.zipkin.java
		  	zipkin-autoconfigure-collector-rabbitmq
		  	2.3.1
		
  		
		    io.zipkin.java
		    zipkin-storage-mysql
		    1.28.0
		
		
		    org.springframework.boot
		    spring-boot-starter-jdbc
		
  		
		    mysql
		    mysql-connector-java
		    8.0.11
       
  1. 启动类加上注解 @EnableZipkinServer 并且加上下面这个bean
@Bean
    public MySQLStorage mySQLStorage(DataSource datasource) {
        return MySQLStorage.builder().datasource(datasource).executor(Runnable::run).build();
    }
  1. yml配置文件如下:
zipkin:
  collector:
    rabbitmq:
      addresses: 192.168.1.22:5672
      password: mq
      username: mq
      queue: zipkin
  storage:
    type: mysql

二、其他微服务配置

  1. 依赖包如下

			org.springframework.cloud
			spring-cloud-starter-zipkin
		
		
			org.springframework.amqp
			spring-rabbit
		
  1. yml配置文件如下:
spring:
  application:
      name: test-service-feign-client
  rabbitmq:
    host: 192.168.1.22
    port: 5672
    username: mq
    password: mq
  zipkin:
    sender:
      type: rabbit
zipkin
    rabbitmq:
      queue: zipkin
  sleuth:
  #统计收集百分比默认0.1,正式环境可不配置
    sampler:
      percentage: 1.0

参考:

https://blog.csdn.net/varyall/article/details/81318645

你可能感兴趣的:(Sring,Cloud)