Springboot: 2.1.7.RELEASESpringCloud: Greenwich.SR2java
[TOC]git
Pinpoint是一个由韩国人编写的为大型分布式系统服务的链路跟踪平台,并提供大量链路跟踪数据分析汇总解决方案。自2012年7月开始开发,与2015年1月作为一个开源项目推出。github
先看一下官方提供的架构图,如图:web
Pinpoint主要包含了4个组件:spring
架构图从上往下看,首先是经过Agent组件收集须要的数据,经过UPD/TCP的方式将数据发送给Collector,由Collector将数据分析整理事后存入HBase,经过Web UI组件将分析好的数据从HBase中读出,展现在现代化的UI界面上。shell
Pinpoint中,核心数据结构由Span, Trace, 和 TraceId组成。apache
TraceId: 由 TransactionId, SpanId, 和 ParentSpanId 组成的key的集合. TransactionId 指明消息ID,而SpanId 和 ParentSpanId 表示RPC的父-子关系。bootstrap
Pinpoint Version | Agent | Collector | Web |
---|---|---|---|
1.0.x | 6-8 | 6-8 | 6-8 |
1.1.x | 6-8 | 7-8 | 7-8 |
1.5.x | 6-8 | 7-8 | 7-8 |
1.6.x | 6-8 | 7-8 | 7-8 |
1.7.x | 6-8 | 8 | 8 |
1.8.0 | 6-10 | 8 | 8 |
1.8.1+ | 6-11 | 8 | 8 |
Pinpoint Version | HBase 0.94.x | HBase 0.98.x | HBase 1.0.x | HBase 1.2.x | HBase 2.0.x |
---|---|---|---|---|---|
1.0.x | yes | no | no | no | no |
1.1.x | no | not tested | yes | not tested | no |
1.5.x | no | not tested | yes | not tested | no |
1.6.x | no | not tested | not tested | yes | no |
1.7.x | no | not tested | not tested | yes | no |
1.8.x | no | not tested | not tested | yes | no |
Pinpoint Version | HBase 0.94.x | HBase 0.98.x | HBase 1.0.x | HBase 1.2.x | HBase 2.0.x |
Agent Version | Collector 1.0.x | Collector 1.1.x | Collector 1.5.x | Collector 1.6.x | Collector 1.7.x | Collector 1.8.x |
---|---|---|---|---|---|---|
1.0.x | yes | yes | yes | yes | yes | yes |
1.1.x | not tested | yes | yes | yes | yes | yes |
1.5.x | no | no | yes | yes | yes | yes |
1.6.x | no | no | not tested | yes | yes | yes |
1.7.x | no | no | no | no | yes | yes |
1.8.x | no | no | no | no | no | yes |
Agent Version | Collector 1.0.x | Collector 1.1.x | Collector 1.5.x | Collector 1.6.x | Collector 1.7.x | Collector 1.8.x |
Pinpoint Version | flink 1.3.X | flink 1.4.X | flink 1.5.X | flink 1.6.X | flink 1.7.X | Pinpoint Version |
---|---|---|---|---|---|---|
1.7.x | yes | yes | no | no | no | 1.7.x |
1.8.x | yes | yes | no | no | no | 1.8.x |
1.9.x | yes | yes | yes | yes | yes | 1.9.x |
Pinpoint Version | flink 1.3.X | flink 1.4.X | flink 1.5.X | flink 1.6.X | flink 1.7.X | Pinpoint Version |
1.7.x | yes | yes | no | no | no | 1.7.x |
1.8.x | yes | yes | no | no | no | 1.8.x |
1.9.x | yes | yes | yes | yes | yes | 1.9.x |
在介绍实战以前,咱们先介绍一下Pinpoint部署构建。segmentfault
笔者构建的一些前置条件:浏览器
java:1.8
CentOS:7.6
存储方式须要使用HBase1.2.x的版本,笔者这里选择的是HBase1.2.6,下载地址为Apache官网,推荐使用有端点续传功能的下载器下载(实在是有点慢),HBase全版本下载地址:http://archive.apache.org/dis... ,各位读者选择本身喜欢的版本下载。
下载完成后,将HBase1.2.6放入CentOS的opt目录中,执行以下命令:
tar -xvzf hbase-1.2.6-bin.tar.gz mv hbase-1.2.6/ /data/service/hbase/
修改hbase中config目录中的JAVA_HOME,将这里的JAVA_HOME修改成本身本地的路径,笔者这里修改以下:
export JAVA_HOME=/opt/jdk1.8.0_221
修改完成后就能够进入hbase的bin目录,启动hbase了,执行以下语句:
./start-hbase.sh
启动成功后,能够执行jps,若是看到有HMaster,可有证实启动成功,以下:
19263 HMaster
也能够打开浏览器访问:http://ip:16010/master-status ,结果如图:
接下来咱们先把Pinpoint的HBase的构建脚本导入,进入HBase的bin目录下执行以下语句:
./hbase shell /opt/hbase-create.hbase
数据导入成功咱们在HBase的UI界面上能够看到,如图:
后面的目录是笔者用来存放HBase初始化脚本的路径,各位读者可根据状况自行替换,至此,HBase环境准备完成,接下来开始部署Collector和Web UI。
出于简单方便考虑,不推荐初学者自行编译代码进行部署,能够直接使用官方提供的发行版本进行部署。
浏览器访问连接:https://github.com/naver/pinp... ,直接下载当前最新Release版本便可,笔者如今看到的最新版本是1.8.4,如图,须要下载的内容有pinpoint-agent-1.8.4.tar.gz
、pinpoint-collector-1.8.4.war
和pinpoint-web-1.8.4.war
。
首先须要准备两个tomcat,笔者这里下载的tomcat8,解压两份后并重命名为apache-tomcat-pinpoint-collector
和apache-tomcat-pinpoint-web
。
将apache-tomcat-pinpoint-collector
中的config中的server.xml进行修改。
将8005改为18005,8080改为18080,8443改成18443,8009改成18009。
一样也将apache-tomcat-pinpoint-web
中的config中的server.xml进行修改。
将8005改为28005,8080改为28080,8443改成28443,8009改成28009。
将apache-tomcat-pinpoint-collector
中的webapp/ROOT
清空,将pinpoint-collector-1.8.4.war
放入并解压。解压完成后就能够进入bin目录使用./startup.sh
启动tomcat了,而且使用命令tail -f ../logs/catalina.out
观察启动日志是否启动成功。
一样,将apache-tomcat-pinpoint-web
中的webapp/ROOT
清空,将pinpoint-web-1.8.4.war
放入并解压。解压完成后就能够进入bin目录使用./startup.sh
启动tomcat了,而且使用命令tail -f ../logs/catalina.out
观察启动日志是否启动成功。
当Collector和Web UI都启动成功后,就可使用打开浏览器访问:http://ip:28080/#/main ,初次访问如图:
实战案例,本实战案例和上一篇实战案例保持一致,一样是4个服务,包括Zuul-Service、Eureka-Service、Consumer-Service和Provider-Service。具体实现代码本章再也不列出,各位读者能够参考上一篇或者Github仓库(https://github.com/meteor1993...),下面咱们介绍Spring Cloud是如何与Pinpoint整合使用的。
接入方式和上一篇的Skywalking是一致的,都是使用探针技术接入应用程序,java -jar的方式来加载Agent探针。
首先在工程的跟目录中执行mvn install
,然后在CentOS的opt中新建4个目录,分别存放4个打好包的工程。笔者这里建立的4个目录分别为/opt/project/consumer_service
,/opt/project/eureka_service
,/opt/project/provider_service
和/opt/project/zuul_service
,将4个jar包分别放入对应的目录中,并解压刚才咱们下载好的pinpoint-agent-1.8.4.tar.gz
探针,咱们将解压后的探针放在/opt的目录中,接下来,咱们使用以下命令,顺次启动4个jar包:
java -javaagent:/opt/pinpoint-bootstrap-1.8.4.jar -Dpinpoint.agentId=consumer-service -Dpinpoint.applicationName=consumer-server -jar /opt/project/consumer_service/consumer-0.0.1-SNAPSHOT.jar java -javaagent:/opt/pinpoint-bootstrap-1.8.4.jar -Dpinpoint.agentId=eureka-service -Dpinpoint.applicationName=eureka-server -jar /opt/project/eureka_service/eureka-0.0.1-SNAPSHOT.jar java -javaagent:/opt/pinpoint-bootstrap-1.8.4.jar -Dpinpoint.agentId=provider-service -Dpinpoint.applicationName=provider-server -jar /opt/project/provider_service/provider-0.0.1-SNAPSHOT.jar java -javaagent:/opt/pinpoint-bootstrap-1.8.4.jar -Dpinpoint.agentId=zuul-service -Dpinpoint.applicationName=zuul-server -jar /opt/project/zuul_service/zuul-0.0.1-SNAPSHOT.jar
上述命令执行完成以后,再打开Web UI查看显示状况。
首先打开浏览器访问:http://192.168.44.129:8080/client/hello?name=spring ,页面正常显示Hello, name is spring,查看Pinpoint的Web UI,如图:
图清楚的显示了咱们当前系统的拓扑结构,横线上面的数字表明了调用次数,右边部分,最上面显示的是成功和失败的状况,中间部分显示的是响应时间,下面显示的是加载所使用的时间。
检查器(Inspector):这里已Zuul-Service为例,Timeline显示的是请求的时间段,Information显示的是节点的一些当前信息,包含Application Name、Agent Id、Agent版本、JVM信息、开始时间等。
Heap信息的使用状况,如图:
系统CPU、活动线程、响应时间等信息如图:
更多Pinpoint的信息,读者能够经过官方Demo(http://125.209.240.10:10123/#/main )或者自行构建试验来查看结果,这里再也不一一赘述。至此,Spring Cloud和Pinpoint的使用介绍也就完成了。更多有关Pinpoint的信息各位读者能够前往Github的官网进行查阅,地址为:https://github.com/naver/pinp... 。
这里总结一下整个案例的启动顺序:
同Skywalking同样,以上启动顺序供各位读者参考,请各位读者最好按照以上顺序启动,由于不一样的组件以前实际上是有相互依赖关系的,若是随意更改启动顺序可能会形成某些未知问题。至此,Spring Cloud和APM的相关操做就告一段落了。APM能够很好的帮咱们理解系统行为,也是分析系统性能的工具,更是发生问题故障的时候利器,能够帮咱们快速的定位查找问题。