Spring Cloud搭建微服务架构----使用Zipkin做服务链路追踪
2017-04-25 00:00
1001 查看
摘要: 微服务的特点是通过简单的服务代码单元构建一个具有庞大生命力的分布式系统,往往一个API请求可能会通过内部调用多个服务完成,任何一个接口出现问题都可能会影响整个链路的稳定,所以一个服务链路追踪系统的搭建非常有必要。
实例主要有三个工程组成:
Server-zipkin:通过ZipkinServer功能,实现收集调用数据,展示;
Service1:对外暴漏的服务接口;
Service2:对外暴漏的服务接口;
两个服务可以相互调用,服务相互调用之后可以通过Service-Zipkin收集数据进行链路追踪。
properties:
应用互相调用:
通过:http://10.168.12.25:9400/dependency 查看服务引用;
实例主要有三个工程组成:
Server-zipkin:通过ZipkinServer功能,实现收集调用数据,展示;
Service1:对外暴漏的服务接口;
Service2:对外暴漏的服务接口;
两个服务可以相互调用,服务相互调用之后可以通过Service-Zipkin收集数据进行链路追踪。
Zipkin-Server
POM:<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-server</artifactId> </dependency> <dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-ui</artifactId> </dependency> </dependencies>
Service01,Service02
POM:<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> </dependencies>
properties:
spring.application.name=service-01 server.port=7001 spring.zipkin.base-url=http://localhost:9400 #zipkin地址
应用互相调用:
@RequestMapping(value = "/api", method = RequestMethod.GET) public String api() { return restTemplate.getForEntity( "http://localhost:7002/hi", String.class).getBody(); }
通过:http://10.168.12.25:9400/dependency 查看服务引用;
代码实例
https://github.com/zhangcj/easymall/tree/master/springbootdemo/springbootdemo-zipkin相关文章推荐
- Spring Boot + Spring Cloud 构建微服务系统(八):分布式链路追踪(Sleuth、Zipkin)
- 使用spring cloud+dotnet core搭建微服务架构:服务治理
- Spring Cloud Sleuth服务链路追踪(zipkin)(转)
- 手把手教你使用spring cloud+dotnet core搭建微服务架构:服务治理(-)
- SpringCloud: 服务链路追踪(Spring Cloud Sleuth)
- SpringCloud微服务架构搭建(四):断路器
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(二十二):链路追踪(Sleuth、Zipkin)
- Spring Cloud Spring Boot mybatis分布式微服务云架构(九)使用Swagger2构建强大的RESTful API文档(1)
- Spring Cloud搭建微服务架构----前言
- Spring Cloud Spring Boot mybatis分布式微服务云架构(四十三)使用log4j实现http请求日志入mongodb(2)
- 【微服务架构】springcloud微服务架构搭建
- Spring Cloud Spring Boot mybatis分布式微服务云架构(九)使用Swagger2构建强大的RESTful API文档(1)
- SpringCloud微服务架构搭建(一):注册与发现
- Spring Cloud Spring Boot mybatis分布式微服务云架构(三十五)使用Redis做集中式缓存(1)
- springcloud(十二):使用Spring Cloud Sleuth和Zipkin进行分布式链路跟踪
- spring cloud+.net core搭建微服务架构:配置中心(四)
- 使用Spring Cloud Netflix技术栈实施微服务架构
- Spring Cloud Spring Boot mybatis分布式微服务云架构(十三)使用Spring Security安全控制
- (十)整合spring cloud云服务架构 - commonservice-config配置服务搭建
- 如何用Spring Cloud搭建一个企业分布式微服务云架构平台