zipkin是一款微服务分布式链路跟踪服务,一开始打算在微服务中集成的,最新的springBoot2.1.5已经不建议这么做了,而且引入出现很多的依赖问题,建议在docker中安装此服务。
目录
1、在docker仓库下载zipkin最新版
#在docker仓库中查询zipkin [root@apg-server zipkinDocker]# docker search zipkin NAME DESCRIPTION STARS OFFICIAL AUTOMATED openzipkin/zipkin This is the authoritative image for zipkin, … 58 openzipkin/zipkin-dependencies Spark job that aggregates zipkin spans for u… 5 openzipkin/zipkin-web This is a historical image for zipkin, repla… 4 openzipkin/zipkin-query This is a historical image for zipkin, repla… 3 openzipkin/zipkin-java This image has been renamed to openzipkin/zi… 3 openzipkin/zipkin-elasticsearch Mirror of https://quay.io/repository/openzip… 3 openzipkin/zipkin-mysql Mirror of https://quay.io/repository/openzip… 2 openzipkin/zipkin-collector This is a historical image for zipkin, repla… 2 openzipkin/zipkin-elasticsearch5 Mirror of https://quay.io/repository/openzip… 2 openzipkin/zipkin-cassandra Mirror of https://quay.io/repository/openzip… 1 openzipkin/zipkin-aws Mirror of https://quay.io/repository/openzip… 0 openzipkin/zipkin-gcp Mirror of https://quay.io/repository/openzip… 0 openzipkin/zipkin-ui test image that runs the zipkin ui on nginx 0 openzipkin/zipkin-elasticsearch6 Mirror of https://quay.io/repository/openzip… 0 openzipkin/zipkin-base This is a historical image for zipkin, repla… 0 sk8s/zipkin-server 0 ibmcom/zipkin 0 openzipkin/zipkin-kafka Testing image for Kafka, with bundled Zookee… 0 kubekit/zipkin zipkin images 0 [OK] silentkevin/zipkin-proxy zipkin-proxy 0 [OK] smartthingsoss/zipkin-dependencies-cassandra3 Zipkin Dependencies Spark Job 0 openzipkin/zipkin-azure Mirror of https://quay.io/repository/openzip… 0 openzipkin/zipkin-elasticsearch7 Mirror of https://quay.io/repository/openzip… 0 ludayong20/zipkin-server 0 honeycombio/zipkinproxy 0 #下载zipkin镜像,等待一会就回下载完成 docker pull openzipkin/zipkin #查看zipkin镜像是否下载完成 docker images
2、编写docker-compose文件
#服务器任意目录创建zipkinDocker文件夹 #新建以下文件 vi docker-compose.yml #编写内容 #注意mysql数据库版本最好是5.6-5.7的,我用mysql8.0连接不成功 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=你的数据库IP地址 - 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 network_mode: host 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 #启动服务编排,在docker-compose.yml所在文件目录执行 docker-compose up -d Creating zipkin ... done #查看服务日志 docker-compose logs
3、在mysql数据库中创建zipkin需要用到的表结构
创建一个数据库名称为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, `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' ) ENGINE = InnoDB ROW_FORMAT = COMPRESSED CHARACTER SET = utf8 COLLATE utf8_general_ci; ALTER TABLE zipkin_spans ADD UNIQUE KEY (`trace_id_high`, `trace_id`, `id`) COMMENT 'ignore insert on duplicate'; ALTER TABLE zipkin_spans ADD INDEX (`trace_id_high`, `trace_id`, `id`) COMMENT 'for joining with zipkin_annotations'; 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 (`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` VARCHAR(255) NOT NULL COMMENT 'BinaryAnnotation.key or Annotation.value if type == -1', `a_value` BLOB COMMENT 'BinaryAnnotation.value(), which must be smaller than 64KB', `a_type` INT NOT NULL COMMENT 'BinaryAnnotation.type() or -1 if Annotation', `a_timestamp` BIGINT COMMENT 'Used to implement TTL; Annotation.timestamp or zipkin_spans.timestamp', `endpoint_ipv4` INT COMMENT 'Null when Binary/Annotation.endpoint is null', `endpoint_ipv6` BINARY(16) COMMENT 'Null when Binary/Annotation.endpoint is null, or no IPv6 address', `endpoint_port` SMALLINT COMMENT 'Null when Binary/Annotation.endpoint is null', `endpoint_service_name` VARCHAR(255) COMMENT 'Null when Binary/Annotation.endpoint is null' ) ENGINE = InnoDB ROW_FORMAT = COMPRESSED CHARACTER SET = utf8 COLLATE utf8_general_ci; ALTER TABLE zipkin_annotations ADD UNIQUE KEY (`trace_id_high`, `trace_id`, `span_id`, `a_key`, `a_timestamp`) COMMENT 'Ignore insert on duplicate'; ALTER TABLE zipkin_annotations ADD INDEX (`trace_id_high`, `trace_id`, `span_id`) COMMENT 'for joining with zipkin_spans'; ALTER TABLE zipkin_annotations ADD INDEX (`trace_id_high`, `trace_id`) COMMENT 'for getTraces/ByIds'; ALTER TABLE zipkin_annotations ADD INDEX (`endpoint_service_name`) COMMENT 'for getTraces and getServiceNames'; ALTER TABLE zipkin_annotations ADD INDEX (`a_type`) COMMENT 'for getTraces and autocomplete values'; ALTER TABLE zipkin_annotations ADD INDEX (`a_key`) COMMENT 'for getTraces and autocomplete values'; ALTER TABLE zipkin_annotations ADD INDEX (`trace_id`, `span_id`, `a_key`) COMMENT 'for dependencies job'; CREATE TABLE IF NOT EXISTS zipkin_dependencies ( `day` DATE NOT NULL, `parent` VARCHAR(255) NOT NULL, `child` VARCHAR(255) NOT NULL, `call_count` BIGINT, `error_count` BIGINT ) ENGINE = InnoDB ROW_FORMAT = COMPRESSED CHARACTER SET = utf8 COLLATE utf8_general_ci; ALTER TABLE zipkin_dependencies ADD UNIQUE KEY (`day`, `parent`, `child`);
4、启动zipkin后,在浏览器中访问
http://你的ip地址:9411/
至此,zipkin服务就安装完成了,需要注意的是mysql版本8.0是不行的,需要5.6或者5.7。
1 条评论