SpringCloud Edgware版本zipkin+mysql+kafka配置

本文档介绍了如何在SpringCloud Edgware版本中配置zipkin服务,包括从zipkin的Github地址获取源码,详细步骤涉及在zipkin-service中添加依赖包、启动注解及配置文件设置。同时,还指导了如何在test-service中进行相应的依赖添加和配置更新,以便与zipkin服务集成,实现微服务的日志跟踪。
摘要由CSDN通过智能技术生成

zipkin Github地址

kafka请自行安装

1 zipkin-service  zipkin服务

1.1 zipkin-service 加入以下依赖包

<dependency>
    <groupId>io.zipkin.java</groupId>
    <artifactId>zipkin-server</artifactId>
</dependency>
<dependency>
    <groupId>io.zipkin.java</groupId>
    <artifactId>zipkin-autoconfigure-ui</artifactId>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>io.zipkin.java</groupId>
    <artifactId>zipkin-autoconfigure-collector-kafka</artifactId>
    <version>2.6.1</version>
</dependency>
<dependency>
    <groupId>io.zipkin.java</groupId>
    <artifactId>zipkin-autoconfigure-storage-mysql</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>
<dependency>
    <groupId>com.zaxxer</groupId>
    <artifactId>HikariCP</artifactId>
</dependency>

1.2 ZipkinServiceApplication 加上注解 

@EnableZipkinServer

1.3 application.yml 加入以下配置

spring:
  sleuth:
    enabled: false
    sampler:
      percentage: 1.0
  datasource:
    name: zipkin
    type: com.zaxxer.hikari.HikariDataSource
    driver-class-name:  com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/zipkin?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
    username: root
    password: 123456
    initialize: true
    continue-on-error: true

zipkin:
  storage:
    type: mysql
  collector:
    kafka:
      zookeeper: localhost:2181
zipkin mysql数据库脚本

2 test-service 测试服务

2.1 加入以下依赖包

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.kafka</groupId>
    <artifactId>spring-kafka</artifactId>
    <version>2.1.6.RELEASE</version>
</dependency>

2.2 application.yml 加入以下配置

 
spring:
  zipkin:
    enabled: true
  sleuth:
    sampler:
      percentage: 1.0
  kafka:
    bootstrap-servers: localhost:9092
end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值