创建数据库
<br>
create DATABASE zipkin;<br>
建表
CREATE TABLE IF NOT EXISTS zipkin_spans (<br> `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',<br> `trace_id` BIGINT NOT NULL,<br> `id` BIGINT NOT NULL,<br> `name` VARCHAR(255) NOT NULL,<br> `remote_service_name` VARCHAR(255),<br> `parent_id` BIGINT,<br> `debug` BIT(1),<br> `start_ts` BIGINT COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL',<br> `duration` BIGINT COMMENT 'Span.duration(): micros used for minDuration and maxDuration query',<br> PRIMARY KEY (`trace_id_high`, `trace_id`, `id`)<br>) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;<br> <br>ALTER TABLE zipkin_spans ADD INDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTracesByIds';<br>ALTER TABLE zipkin_spans ADD INDEX(`name`) COMMENT 'for getTraces and getSpanNames';<br>ALTER TABLE zipkin_spans ADD INDEX(`remote_service_name`) COMMENT 'for getTraces and getRemoteServiceNames';<br>ALTER TABLE zipkin_spans ADD INDEX(`start_ts`) COMMENT 'for getTraces ordering and range';<br> <br>CREATE TABLE IF NOT EXISTS zipkin_annotations (<br> `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',<br> `trace_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.trace_id',<br> `span_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.id',<br> `a_key` VARCHAR(255) NOT NULL COMMENT 'BinaryAnnotation.key or Annotation.value if type == -1',<br> `a_value` BLOB COMMENT 'BinaryAnnotation.value(), which must be smaller than 64KB',<br> `a_type` INT NOT NULL COMMENT 'BinaryAnnotation.type() or -1 if Annotation',<br> `a_timestamp` BIGINT COMMENT 'Used to implement TTL; Annotation.timestamp or zipkin_spans.timestamp',<br> `endpoint_ipv4` INT COMMENT 'Null when Binary/Annotation.endpoint is null',<br> `endpoint_ipv6` BINARY(16) COMMENT 'Null when Binary/Annotation.endpoint is null, or no IPv6 address',<br> `endpoint_port` SMALLINT COMMENT 'Null when Binary/Annotation.endpoint is null',<br> `endpoint_service_name` VARCHAR(255) COMMENT 'Null when Binary/Annotation.endpoint is null'<br>) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;<br> <br>ALTER TABLE zipkin_annotations ADD UNIQUE KEY(`trace_id_high`, `trace_id`, `span_id`, `a_key`, `a_timestamp`) COMMENT 'Ignore insert on duplicate';<br>ALTER TABLE zipkin_annotations ADD INDEX(`trace_id_high`, `trace_id`, `span_id`) COMMENT 'for joining with zipkin_spans';<br>ALTER TABLE zipkin_annotations ADD INDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTraces/ByIds';<br>ALTER TABLE zipkin_annotations ADD INDEX(`endpoint_service_name`) COMMENT 'for getTraces and getServiceNames';<br>ALTER TABLE zipkin_annotations ADD INDEX(`a_type`) COMMENT 'for getTraces and autocomplete values';<br>ALTER TABLE zipkin_annotations ADD INDEX(`a_key`) COMMENT 'for getTraces and autocomplete values';<br>ALTER TABLE zipkin_annotations ADD INDEX(`trace_id`, `span_id`, `a_key`) COMMENT 'for dependencies job';<br> <br>CREATE TABLE IF NOT EXISTS zipkin_dependencies (<br> `day` DATE NOT NULL,<br> `parent` VARCHAR(255) NOT NULL,<br> `child` VARCHAR(255) NOT NULL,<br> `call_count` BIGINT,<br> `error_count` BIGINT,<br> PRIMARY KEY (`day`, `parent`, `child`)<br>) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;<br>
调整zipkin的docker-compose.yml新增mysql相关配置
docker-compose.yml文件
version: '3'<br>services:<br> zipkin:<br> image: openzipkin/zipkin<br> environment:<br> - TZ=Asia/Shanghai<br> - JAVA_OPTS=-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms100m -Xmx1024m -Xmn256m <br> - STORAGE_TYPE=mysql<br> - MYSQL_DB=zipkin<br> - MYSQL_USER=root<br> - MYSQL_PASS=root<br> - MYSQL_HOST=192.168.56.10<br> - MSYQL_TCP_PORT=3306<br> container_name: zipkin<br> ports: <br> - 9411:9411
重新启动zipkin
docker-compose down &&docker-compose up -d&&dopcker-compose logs -f