skywarking链路跟踪

最后更新于:2022-04-02 07:10:47

**背景:** 微服务架构是通过业务来划分服务的,使用 REST 调用。对外暴露的一个接口,可能需要很多个服务协同才能完成这个接口功能,如果链路上任何一个服务出现问题或者网络超时,都会形成导致接口调用失败。为了在发生故障的时候,能够快速定位和解决问题,需要使用SkyWalking --- **环境:** windows JDK8 --- **开发工具:** idea --- **软件安装:** 1.[下载elasticsearch7](https://www.elastic.co/cn/downloads/elasticsearch) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/4b/a9/4ba93afd2cead67c63ec5308e0a82d38_1347x545.png) 2.解压 运行bin/elasticsearch.bat 3.访问 `localhost:9200` 如下结果表示OK ``` ~~~ { "name" : "xxxx", "cluster_name" : "elasticsearch", "cluster_uuid" : "xxxx", "version" : { "number" : "7.7.1", "build_flavor" : "default", "build_type" : "zip", "build_hash" : "xxxxx", "build_date" : "2020-05-28T16:30:01.040088Z", "build_snapshot" : false, "lucene_version" : "8.5.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } ~~~ ``` 4.[下载skywarking](http://skywalking.apache.org/downloads/) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/4a/95/4a958e3ac2a6b8b855d3854e3dedb8d5_1576x668.png) --- 5.解压 运行 bin/startup.bat,这个时候实际上是启动了两个项目,一个收集器,一个web页面 ---- 6.访问`localhost:8080`,端口号webapp/webapp.yml中可以修改,第一次访问页面空白正常 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/48/34/4834c17a446ac85e8556f09b4f98cdb4_1907x765.png) ---- 7.在项目根目录下创建目录 jeecg-skywarking,并且将skywarking下的agent文件夹直接拷贝至该目录下 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/dc/ee/dceeef8af5df94ef72ba1841f5e8e77c_548x443.png) ---- 8.配置vm参数 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/69/1a/691ad4c90d9c3ba77ddaedb4c5fc51be_373x205.png) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/5e/bc/5ebc7675a8448465727607e36a4dab0a_1139x460.png) --- eclipse配置vm参数图: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/44/a3/44a3eb8cb82c934825dd3ec4ecd84778_1232x909.png) ---- 附上参数代码及描述 ``` -javaagent:D:\JAVA\cloud\jeecg-yanshi\jeecg-skywarking\agent\skywalking-agent.jar -Dskywalking.agent.service_name=jeecg-ys-gateway -Dskywalking.collector.backend_service=localhost:11800 ``` | 参数 | 描述 | | --- | --- | | javaagent | 配置 skywalking-agent.jar 的地址,需要修改 | | service_name| 配置 需要监控的服务名,需要修改 | | javaagent | skywalking收集器服务的地址,照抄 | ---- 9.启动项目,访问接口(多访问几次),再去localhost:8080看面板数据 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/48/34/4834c17a446ac85e8556f09b4f98cdb4_1907x765.png) ---- 10.当我们访问一个服务,而他会调用另一个服务的时候,点击拓扑图会出现下图的效果,这就是链路跟踪的效果 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/91/94/9194550ffabe463d90ead8a132ca97ba_1703x550.png) ---- 11.还可以在追踪界面,查看整个请求的具体调用链 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/8a/ac/8aac50e29392c43699b87fe30872add6_1906x733.png) --- *其他功能需自行摸索*
';