环境配置

安装docker&docker-compose,见博客docker&docker-compose

部署zipkin

持久化到mysql

[root@base zipkin-mysql]# cat docker-compose.yaml
#
# Note that this file is meant for learning Zipkin, not production deployments.

version: '2'

services:
  storage:
    image: openzipkin/zipkin-mysql
    container_name: mysql
    # Uncomment to expose the storage port for testing
    ports:
      - 3307:3306

  # 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
      - MYSQL_HOST=mysql
      # 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.zipkin2=DEBUG
    ports:
      # Port used for the Zipkin UI and HTTP Api
      - 9411:9411
      # Uncomment if you set SCRIBE_ENABLED=true
      # - 9410:9410
    depends_on:
      - storage

  # Adds a cron to process spans since midnight every hour, and all spans each day
  # This data is served by http://192.168.99.100:8080/dependency
  #
  # For more details, see https://github.com/openzipkin/docker-zipkin-dependencies
  dependencies:
    image: openzipkin/zipkin-dependencies
    container_name: dependencies
    entrypoint: crond -f
    environment:
      - STORAGE_TYPE=mysql
      - MYSQL_HOST=mysql
      # Add the baked-in username and password for the zipkin-mysql image
      - MYSQL_USER=zipkin
      - MYSQL_PASS=zipkin
      # Uncomment to see dependency processing logs
      # - ZIPKIN_LOG_LEVEL=DEBUG
      # Uncomment to adjust memory used by the dependencies job
      # - JAVA_OPTS=-verbose:gc -Xms1G -Xmx1G
    depends_on:
      - storage
[root@base zipkin-mysql]# docker-compose up -d
[root@base ~]# docker ps -a|grep zipkin
9c7c2bbd5ad2        openzipkin/zipkin                "/busybox/sh run.sh"     About an hour ago   Up About an hour    9410/tcp, 0.0.0.0:9411->9411/tcp    zipkin
b80170952816        openzipkin/zipkin-dependencies   "crond -f"               About an hour ago   Up About an hour                                        dependencies
a40918387699        openzipkin/zipkin-mysql          "/bin/sh -c /mysql/r…"   About an hour ago   Up About an hour    0.0.0.0:3307->3306/tcp              mysql            

zipkin的sql初始化脚本:zipkin.sql

CREATE TABLE IF NOT EXISTS zipkin_spans (
   `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
   `trace_id` BIGINT NOT NULL,
   `id` BIGINT NOT NULL,
   `name` VARCHAR(255) NOT NULL,
   `remote_service_name` VARCHAR(255),
   `parent_id` BIGINT,
   `debug` BIT(1),
   `start_ts` BIGINT COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL',
   `duration` BIGINT COMMENT 'Span.duration(): micros used for minDuration and maxDuration query',
   PRIMARY KEY (`trace_id_high`, `trace_id`, `id`)
  ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;
   
  ALTER TABLE zipkin_spans ADD INDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTracesByIds';
  ALTER TABLE zipkin_spans ADD INDEX(`name`) COMMENT 'for getTraces and getSpanNames';
  ALTER TABLE zipkin_spans ADD INDEX(`remote_service_name`) COMMENT 'for getTraces and getRemoteServiceNames';
  ALTER TABLE zipkin_spans ADD INDEX(`start_ts`) COMMENT 'for getTraces ordering and range';
   
  CREATE TABLE IF NOT EXISTS zipkin_annotations (
   `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
   `trace_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.trace_id',
   `span_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.id',
   `a_key` V

持久化到es

[root@base zipkin-mysql]# cat docker-compose.yaml
version: '2'
 
services:
  storage:
    image: openzipkin/zipkin-elasticsearch7
    container_name: elasticsearch
    ports:
      - 9200:9200
    volumes:
      - /home/zipkin/data:/elasticsearch/data
  zipkin:
    image: openzipkin/zipkin:latest
    container_name: zipkin
    environment:
      - STORAGE_TYPE=elasticsearch
      - ES_HOSTS=elasticsearch
    ports:
      - 9411:9411
    depends_on:
      - storage
  dependencies:
    image: openzipkin/zipkin-dependencies
    container_name: dependencies
    entrypoint: crond -f
    environment:
      - STORAGE_TYPE=elasticsearch
      - ES_HOSTS=elasticsearch
      - ZIPKIN_LOG_LEVEL=DEBUG
      - JAVA_OPTS=-verbose:gc -Xms1G -Xmx1G
    depends_on:
      - storage

访问地址

http://IP:9411

文章作者: 鲜花的主人
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 爱吃可爱多
Docker Docker
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝