一、Spring Cloud系列:Zipkin服务端配置
2017-09-12 16:20
232 查看
一、引入依赖
//起步依赖 compile('org.springframework.cloud:spring-cloud-starter') //zipkin compile('io.zipkin.java:zipkin-server') //zipkin的web界面 compile('io.zipkin.java:zipkin-autoconfigure-ui') //保存到数据库需要如下依赖 compile('io.zipkin.java:zipkin-autoconfigure-storage-mysql') compile('mysql:mysql-connector-java') compile('org.springframework.boot:spring-boot-starter-jdbc')
二、启动类配置
加上@EnableZipkinServer注解。@EnableZipkinServer @SpringBootApplication public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } }
二、配置文件
application.properties#应用名 spring.application.name=zipking-server-v1 #端口 server.port=9411 #zipkin数据保存到数据库中需要进行如下配置 #表示当前程序不使用sleuth spring.sleuth.enabled=false #表示zipkin数据存储方式是mysql zipkin.storage.type=mysql #数据库脚本创建地址,当有多个是可使用[x]表示集合第几个元素 spring.datasource.schema[0]=classpath:/zipkin.sql #spring boot数据源配置 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
需要在数据库中新建zipkin的库
三、创建sql脚本文件
在resources目录下新建zipkin.sql文件,内容如下SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for zipkin_annotations -- ---------------------------- CREATE TABLE `zipkin_annotations` ( `trace_id` bigint(20) NOT NULL COMMENT 'coincides with zipkin_spans.trace_id', `span_id` bigint(20) 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(11) NOT NULL COMMENT 'BinaryAnnotation.type() or -1 if Annotation', `a_timestamp` bigint(20) DEFAULT NULL COMMENT 'Used to implement TTL; Annotation.timestamp or zipkin_spans.timestamp', `endpoint_ipv4` int(11) DEFAULT NULL COMMENT 'Null when Binary/Annotation.endpoint is null', `endpoint_ipv6` binary(16) 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 insert 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 CHARSET=utf8 ROW_FORMAT=COMPRESSED; -- ---------------------------- -- Table structure for zipkin_dependencies -- ---------------------------- CREATE TABLE `zipkin_dependencies` ( `day` date NOT NULL, `parent` varchar(255) NOT NULL, `child` varchar(255) NOT NULL, `call_count` bigint(20) 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(20) NOT NULL, `id` bigint(20) NOT NULL, `name` varchar(255) NOT NULL, `parent_id` bigint(20) DEFAULT NULL, `debug` bit(1) DEFAULT NULL, `start_ts` bigint(20) DEFAULT NULL COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL', `duration` bigint(20) DEFAULT NULL COMMENT 'Span.duration(): micros used for minDuration and maxDuration query', UNIQUE KEY `trace_id` (`trace_id`,`id`) COMMENT 'ignore insert on duplicate', KEY `trace_id_2` (`trace_id`,`id`) COMMENT 'for joining with zipkin_annotations', KEY `trace_id_3` (`trace_id`) COMMENT 'for getTracesByIds', KEY `name` (`name`) COMMENT 'for getTraces and getSpanNames', KEY `start_ts` (`start_ts`) COMMENT 'for getTraces ordering and range' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;
刷新项目依赖,启动项目不报错则说明正常。
相关文章推荐
- 五、Spring Cloud系列:Eureka服务端与客户端常用配置
- 六、Spring Cloud系列:Config服务端与客户端常用配置
- Zipkin-1.19.0学习系列5:listeners.environmentPrepared(environment)&配置文件解析
- [置顶] Spring cloud系列十一 @Feign集成的Hystrix进行个性化配置及集成原理
- VPS系列---安装配置nagios客户端、服务端
- Spring cloud系列七 为@Feign中集成的Ribbon进行个性化配置
- Spring cloud系列九 Hystrix的配置属性优先级和详解
- 三、Spring Cloud系列:通过消息队列传输zipkin日志
- spring cloud系列一 搭建配置服务器(分布式配置管理)configserver
- Spring cloud系列三 Spring Cloud 配置中心集群
- SpringCloud系列教程(5)-- Config服务端配置
- SpringCloud系列四:Eureka 服务发现框架(定义 Eureka 服务端、Eureka 服务信息、Eureka 发现管理、Eureka 安全配置、Eureka-HA(高可用) 机制、Eureka 服务打包部署)
- 【Spring Boot&&Spring Cloud系列】Spring Boot配置文件
- 干货实操:微服务Spring Cloud 系列(一) Spring cloud Config 用SVN做配置仓库
- zabbix系列(一)centos7搭建zabbix3.0.4服务端及配置详解
- zabbix系列(一)centos7搭建zabbix3.0.4服务端及配置详解
- spring cloud系列-02.配置中心Config搭建
- Spring cloud系列二 Spring Cloud 配置中心的基本用法
- SpringCloud系列九:SpringCloudConfig 基础配置(SpringCloudConfig 的基本概念、配置 SpringCloudConfig 服务端、抓取配置文件信息、客户端使用 SpringCloudConfig 进行配置、单仓库目录匹配、应用仓库自动选择、仓库匹配模式)
- 二、Spring Cloud系列:Zipkin客户端配置