sleuth+zipkin+rabbitmq+elasticsearchz整合

sleuth+zipkin+rabbitmq+elasticsearchz整合

版本 spring-boot-starter-parent---------------------1.5.9.RELEASE

1.http+mysql

在zipkin-server项目中引入

    <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
        </dependency> 
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
        </dependency>
        <!-- zipkin 存储到数据库需要引入此类 -->
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-storage-mysql</artifactId>
        </dependency>
        <!--保存到数据库需要如下依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.11</version>
        </dependency>
    

application.properties

server.port=17601
spring.application.name=zddk-server-zipkin
spring.sleuth.enabled=false
zipkin.storage.type=mysql
spring.datasource.schema[0]=classpath:/zipkin.sql
spring.datasource.url=jdbc:mysql://localhost:3306/zddk-zipkin?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialize=true
spring.datasource.continue-on-error=true

在启动方法上添加@EnableZipkinServer

@SpringBootApplication
//@EnableZipkinStreamServer
@EnableZipkinServer
public class ZddkServerZipkinApplication {
​
    public static void main(String[] args) {
        /*args = new String[1];
        args[0] = "--spring.profiles.active=zipkin-http";*/
        SpringApplication.run(ZddkServerZipkinApplication.class, args);
    }
}

在其他服务pom中引入

 
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>  
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zipkin</artifactId>
        </dependency>

2.rabbitmq+mysql

     
   <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

application.properties

server.port=17601
spring.application.name=zddk-server-zipkin
spring.sleuth.enabled=false
zipkin.storage.type=mysql
spring.datasource.schema[0]=classpath:/zipkin.sql
spring.datasource.url=jdbc:mysql://localhost:3306/zddk-zipkin?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialize=true
spring.datasource.continue-on-error=true
spring.rabbitmq.host=192.****.***.***
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

在启动方法上添加@EnableZipkinStreamServer

@SpringBootApplication
@EnableZipkinStreamServer
//@EnableZipkinServer
public class ZddkServerZipkinApplication {
​
    public static void main(String[] args) {
        /*args = new String[1];
        args[0] = "--spring.profiles.active=zipkin-http";*/
        SpringApplication.run(ZddkServerZipkinApplication.class, args);
    }
}

在其他服务pom中引入

   
    <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>

3.rabbitmq+elasticsearch

     
    <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-server</artifactId>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin-autoconfigure-ui</artifactId>
        </dependency>
​
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>
​
        <dependency>
            <groupId>io.zipkin.java</groupId>
            <artifactId>zipkin</artifactId>
            <version>1.28.1</version>
        </dependency>
        <dependency>
            <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-elasticsearch-                              http</artifactId>
            <version>1.28.1</version>
        </dependency>       
         

application.yml

eureka:
  client:
    serviceUrl:
      defaultZone: http://192.168.1.***:8011/eureka/
server:
  port: 9411
spring:
  application:
    name: zipkin-server
  sleuth:
    enabled: false
  rabbitmq:
    host: 192.168.1.***
    port: 5672
    username: guest
    password: guest
 # datasource:
 #   url: jdbc:mysql://localhost:3306/zddk-zipkin?useUnicode=true&characterEncoding=utf8&useSSL=false
 #   username: root
 #   password: 123456
 #   driver-class-name: com.mysql.jdbc.Driver
#zipkin:
 #storage:
  #  type: mysql
zipkin:
  storage:
    type: elasticsearch
    StorageComponent: elasticsearch
    elasticsearch:
      cluster: elasticsearch
      max-requests: 30
      index: zipkin
      index-shards: 3
      index-replicas: 1
      hosts: 192.168.1.143:9200

在启动方法上添加@EnableZipkinStreamServer

@SpringBootApplication
@EnableZipkinStreamServer
//@EnableZipkinServer
public class ZddkServerZipkinApplication {
​
    public static void main(String[] args) {
        /*args = new String[1];
        args[0] = "--spring.profiles.active=zipkin-http";*/
        SpringApplication.run(ZddkServerZipkinApplication.class, args);
    }
}

在其他服务pom中引入

      
  <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值