Welcome everyone

链路追踪开源产品SkyWalking初体验

分布式 汪明鑫 2159浏览 0评论

SkyWalking 介绍

分布式系统的应用程序性能监视工具,专为微服务、云原生架构和基于容器(Docker、K8s、Mesos)架构而设计。

提供分布式追踪、服务网格遥测分析、度量聚合和可视化一体化解决方案。

 

简而言之,SkyWalking是分布式微服务场景下的一款开源的链路追踪产品。

 

 

大体架构

 

 

架构简图

application: 应用程序

agent:程序本地计算、上报链路数据

OAP: 收集、分析数据,存储到Storage,提供查询功能

Storage: 存储链路数据,一般有es、mysql、h2

UI:展示数据

 

SkyWalking安装

我是在mac本地装的

 

brew install wget
wget http://mirror.bit.edu.cn/apache/skywalking/6.6.0/apache-skywalking-apm-es7-6.6.0.tar.gz
tar -zxvf apache-skywalking-apm-es7-6.6.0.tar.gz

 

~/Documents/software/skywalking » cd apache-skywalking-apm-bin-es7                                                          
~/Documents/software/skywalking/apache-skywalking-apm-bin-es7 » ls                                                                                                
LICENSE    NOTICE     README.txt agent      bin        config     licenses   oap-libs   webapp

 

 

修改配置

vi config/application.yml

 

我们用elasticsearch做存储

elasticsearch7 意思是存储用es7.x 版本

 

启动OAP服务

~/Documents/software/skywalking/apache-skywalking-apm-bin-es7 » bin/oapService.sh  
SkyWalking OAP started successfully!

 

看下日志

~/Documents/software/skywalking/apache-skywalking-apm-bin-es7/logs tail -f skywalking-oap-server.log 
2020-07-08 12:39:52,768 - org.apache.skywalking.oap.server.library.module.BootstrapFlow - 58 [main] INFO  [] - start the provider default in receiver-jvm module.
2020-07-08 12:39:52,768 - org.apache.skywalking.oap.server.library.server.grpc.GRPCServer - 138 [main] INFO  [] - Bind handler JVMMetricsServiceHandler into gRPC server 0.0.0.0:11800
2020-07-08 12:39:52,770 - org.apache.skywalking.oap.server.library.server.grpc.GRPCServer - 138 [main] INFO  [] - Bind handler JVMMetricReportServiceHandler into gRPC server 0.0.0.0:11800
2020-07-08 12:39:57,943 - org.apache.skywalking.oap.server.library.server.jetty.JettyServer - 93 [main] INFO  [] - start server, host: 0.0.0.0, port: 12800
2020-07-08 12:39:57,946 - org.eclipse.jetty.server.Server - 372 [main] INFO  [] - jetty-9.4.2.v20170220
2020-07-08 12:39:57,976 - org.eclipse.jetty.server.handler.ContextHandler - 802 [main] INFO  [] - Started o.e.j.s.ServletContextHandler@79777da7{/,null,AVAILABLE}
2020-07-08 12:39:57,985 - org.eclipse.jetty.server.AbstractConnector - 280 [main] INFO  [] - Started ServerConnector@45832b85{HTTP/1.1,[http/1.1]}{0.0.0.0:12800}
2020-07-08 12:39:57,985 - org.eclipse.jetty.server.Server - 444 [main] INFO  [] - Started @64222ms
2020-07-08 12:39:57,986 - org.apache.skywalking.oap.server.core.storage.PersistenceTimer - 54 [main] INFO  [] - persistence timer start
2020-07-08 12:39:57,988 - org.apache.skywalking.oap.server.core.cache.CacheUpdateTimer - 42 [main] INFO  [] - Cache updateServiceInventory timer start

 

es上也建了很多索引

 

启动 UI

~/Documents/software/skywalking/apache-skywalking-apm-bin-es7 » bin/webappService.sh
SkyWalking Web Application started successfully!

 

看下日志

~/Documents/software/skywalking/apache-skywalking-apm-bin-es7/logs tail -f webapp.log
2020-07-08 12:42:59.690  INFO 80078 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'filtersEndpoint': registering with JMX server as MBean [org.springframework.cloud.netflix.zuul:name=filtersEndpoint,type=FiltersEndpoint]
2020-07-08 12:42:59.691  WARN 80078 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with key 'filtersEndpoint' has been registered as an MBean but has no exposed attributes or operations
2020-07-08 12:42:59.691  INFO 80078 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2020-07-08 12:42:59.698  INFO 80078 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=77ec78b9,type=ConfigurationPropertiesRebinder]
2020-07-08 12:42:59.702  INFO 80078 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2020-07-08 12:42:59.713  INFO 80078 --- [main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2020-07-08 12:42:59.735  INFO 80078 --- [main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
2020-07-08 12:42:59.740  INFO 80078 --- [main] ration$HystrixMetricsPollerConfiguration : Starting poller
2020-07-08 12:42:59.780  INFO 80078 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2020-07-08 12:42:59.785  INFO 80078 --- [main] o.a.s.apm.webapp.ApplicationStartUp      : Started ApplicationStartUp in 26.049 seconds (JVM running for 26.573)

 

http://localhost:8080/

 

启动应用程序和agent

现在我们的OAP 服务和 UI都好了,
需要在应用程序部上agent上报应用程序的数据

agent目录位置

~/Documents/software/skywalking/apache-skywalking-apm-bin-es7/agent » pwd 
/Users/xinye/Documents/software/skywalking/apache-skywalking-apm-bin-es7/agent

 

我们整个自己小项目打包一波

再写一个脚本,运行我们的程序和agent

 

#! /bin/bash
  
export SW_AGENT_NAME=xinye
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800
export SW_AGENT_SPAN_LIMIT=2000

export JAVA_AGENT=-javaagent:/Users/xinye/Documents/software/skywalking/apache-skywalking-apm-bin-es7/agent/skywalking-agent.jar

echo "agent setting..."

java -jar $JAVA_AGENT demo1.jar

 

~/Documents/software/skywalking/demo ./startApplicationAgent.sh 
zsh: permission denied: ./startApplicationAgent.sh

permission denied

给脚本授权即可

chmod u+x *.sh

 

再运行脚本

就ok 了

 

我们请求下应用程序api

 

 

我们还可以直接在idea本地起服务上报skywalking,不用打包启动了

 

VM options:
-javaagent:/Users/xinye/Documents/software/skywalking/apache-skywalking-apm-bin-es7/agent/skywalking-agent.jar

Environment variables:
SW_AGENT_NAME=xinye-idea;SW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800

 

基本功能

【仪表盘】

 

 

【链路追踪】

 

 

 

【拓扑图】

 

不得不说,skywalking的界面做的很好看

 

 

 

转载请注明:汪明鑫的个人博客 » 链路追踪开源产品SkyWalking初体验

喜欢 (2)

说点什么

您将是第一位评论人!

提醒
avatar
wpDiscuz