一、方式一
1、拉鏡像 docker pull openzipkin/zipkin 2、運行鏡像 # 普通運行 docker run -d --restart always -p 9411:9411 --name zipkin openzipkin/zipkin
# docker-compose運行,新建docker-compose.yml加入以下內容
version: '2'
services:
# The zipkin process services the UI, and also exposes a POST endpoint that
# instrumentation can send trace data to. Scribe is disabled by default.
zipkin:
image: openzipkin/zipkin
container_name: zipkin
environment:
- STORAGE_TYPE=mysql
# Point the zipkin at the storage backend
- MYSQL_DB=zipkin
- MYSQL_USER=root
- MYSQL_PASS=123456
- MYSQL_HOST=192.168.1.8
- MYSQL_TCP_PORT=3306
# Uncomment to enable scribe
# - SCRIBE_ENABLED=true
# Uncomment to enable self-tracing
# - SELF_TRACING_ENABLED=true
# Uncomment to enable debug logging
# - JAVA_OPTS=-Dlogging.level.zipkin=DEBUG -Dlogging.level.zipkin2=DEBUG
ports:
# Port used for the Zipkin UI and HTTP Api
- 9411:9411
# Uncomment if you set SCRIBE_ENABLED=true
# - 9410:9410
#networks:
# - default
# - my_net #創建網路 docker network create my_net 刪除網絡 docker network rm my_net
#networks:
#my_net:
#external: true
# 守護進程啟動
cd 到docker-compose.yml目錄下
docker-compose up -d
停止
docker-compose stop
# mysql腳本下載地址
https://github.com/openzipkin/zipkin/blob/master/zipkin-storage/mysql/src/main/resources/mysql.sql
3、訪問 在瀏覽器訪問:http://ip:9411/zipkin/
# 方式二
springcloud 官方按照傳輸方式分成了三種啟動服務端的方式:Sleuth with Zipkin via HTTP,Sleuth with Zipkin via Spring Cloud Stream,Spring Cloud Sleuth Stream Zipkin Collector。只需要添加相應的依賴,之后配置相應的注解,如 @EnableZipkinStreamServer 即可。具體配置參考 Spring Cloud 官方文檔
# 使用
# 依賴
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-sleuth-zipkin</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency>
# 項目配置
spring:
zipkin:
#服務端地址
base-url: http://ip:9411
#本項目服務名
service:
name: ${spring.application.name}
sleuth:
#監控開關
enabled: true
#采樣率
sampler:
percentage: 1