first, the introduction of dependency
Start dependent
compile (' org.springframework.cloud:spring-cloud-starter ')
//zipkin
compile (' Io.zipkin.java: Zipkin-server ')
//zipkin Web Interface
compile (' io.zipkin.java:zipkin-autoconfigure-ui ')
//Save to database requires the following dependencies
compile (' io.zipkin.java:zipkin-autoconfigure-storage-mysql ')
compile (' Mysql:mysql-connector-java ')
compile (' Org.springframework.boot:spring-boot-starter-jdbc ')
second, start-up class configuration
Add @enablezipkinserver annotations.
@EnableZipkinServer
@SpringBootApplication Public
class Zipkinapplication {public
static void main ( String[] args) {
springapplication.run (zipkinapplication.class, args);
}
}
Second, the configuration file
Application.properties
#应用名
spring.application.name=zipking-server-v1
#端口
server.port=9411
#zipkin数据保存到数据库中需要进行如下配置
#表示当前程序不使用sleuth
spring.sleuth.enabled=false
#表示zipkin数据存储方式是mysql
zipkin.storage.type=mysql
#数据库脚本创建地址, when there are multiple elements that can be used [x] to represent the spring.datasource.schema[0]=classpath:/zipkin.sql of the collection
#spring Boot data Source configuration
Spring.datasource.url=jdbc:mysql://localhost:3306/zipkin
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.driver
Spring.datasource.initialize=true
Spring.datasource.continue-on-error=true
Need to create a new Zipkin library in the database iii. Creating a SQL script file
Create a new Zipkin.sql file under the Resources directory with the following content
SET foreign_key_checks=0; --------------------------------Table structure for zipkin_annotations------------------------------CREATE table ' Z Ipkin_annotations ' (' trace_id ' bigint () not NULL COMMENT ' coincides with zipkin_spans.trace_id ', ' span_id ' bigint (2 0) NOT null COMMENT ' coincides with Zipkin_spans.id ', ' a_key ' varchar (255) NOT null COMMENT ' Binaryannotation.key or Ann Otation.value if Type = =-1 ', ' a_value ' blob COMMENT ' Binaryannotation.value (), which must be smaller than 64KB ', ' a_t ype ' int (one) not null COMMENT ' Binaryannotation.type () or-1 if Annotation ', ' A_timestamp ' bigint (All) DEFAULT NULL COMME NT ' used to implement TTL; Annotation.timestamp or Zipkin_spans.timestamp ', ' Endpoint_ipv4 ' int (one) DEFAULT NULL COMMENT ' null when Binary/annotati On.endpoint is null ', ' Endpoint_ipv6 ' binary (+) DEFAULT null COMMENT ' null when binary/annotation.endpoint is NULL, or No IPv6 address ', ' endpoint_port ' smallint (6) DEFAULT null COMMENT ' null when Binary/annotaTion.endpoint is null ', ' endpoint_service_name ' varchar (255) DEFAULT null COMMENT ' null when Binary/annotation.endpoint Is null ', UNIQUE KEY ' trace_id ' (' trace_id ', ' span_id ', ' a_key ', ' a_timestamp ') COMMENT ' Ignore inserts on duplicate ', KEY ' Trace_id_2 ' (' trace_id ', ' span_id ') COMMENT ' for joining with Zipkin_spans ', KEY ' trace_id_3 ' (' trace_id ') COMMENT ' for
Gettraces/byids ', KEY ' endpoint_service_name ' (' endpoint_service_name ') COMMENT ' for gettraces and Getservicenames ', Key ' A_type ' (' a_type ') COMMENT ' for gettraces ', key ' A_key ' (' A_key ') COMMENT ' for gettraces ') Engine=innodb DEFAULT C
Harset=utf8 row_format=compressed; --------------------------------Table structure for zipkin_dependencies------------------------------CREATE table ' Zipkin_dependencies ' (' Day ' date is not null, ' parent ' varchar (255) is not NULL, ' child ' varchar (255) is not NULL, ' Call_c Ount ' bigint () default NULL, UNIQUE KEY ' Day ' (' Day ', ' parent ', ' child ') engine=innodb default Charset=utf8 row_format=compressed; --------------------------------Table structure for Zipkin_spans------------------------------CREATE table ' Zipkin_ Spans ' (' trace_id ' bigint () not NULL, ' ID ' bigint (a) Not null, ' name ' varchar (255) is not NULL, ' parent_id ' bigin T () default NULL, ' Debug ' bit (1) default null, ' Start_ts ' bigint (all) default null COMMENT ' Span.timestamp (): Epoch M Icros used for Endts query and to implement TTL ', ' duration ' bigint (all) DEFAULT NULL COMMENT ' span.duration (): Micros US
Ed for minduration and maxduration query ', UNIQUE KEY ' trace_id ' (' trace_id ', ' id ') COMMENT ' ignore inserts on duplicate ', Key ' Trace_id_2 ' (' trace_id ', ' id ') COMMENT ' for joining with Zipkin_annotations ', key ' trace_id_3 ' (' trace_id ') COMME NT ' for Gettracesbyids ', key ' name ' (' name ') COMMENT ' for gettraces and Getspannames ', Key ' start_ts ' (' start_ts ') COM ment ' for gettraces Ordering and range ') Engine=innodb DEFAULT Charset=utf8 row_format=compressed;
Refresh Project Dependencies, the startup project does not error indicates normal.