首先要知道的是skywalking的原理 ,为什么可以实现对程序完全没有侵入性,了解字节码增强,引申出java的动态代理 以及其他使用动态代理的框架
下面来说配置skywalking 分为agent,collector ,webui
后台数据可以传入es ,h2,或mysql
首先安装es
1、JDK8+
2、Elasticsearch 5.x
3、8080,10800,11800,12800端口不被占用
Elasticsearch下载安装参考官方教程,安装完成后需要对 config/elasticsearch.yml做如下修改:
修改配置文件
vim /etc/sysconfig/elasticsearch
JAVA_HOME=/home/java/jdk1.8.0_181
启动Esearch
service elasticsearch start
测试Esearch
curl localhost:9200
# 修改
# 如果 cluster.name 不设置为 CollectorDBCluster ,则需要修改 SkyWalking 的配置文件cluster.name: CollectorDBCluster
# 增加thread_pool.bulk.queue_size: 1000
如果是 linux 环境,Elasticsearch 安装可能没有那么顺利,请参考Linux环境下安装Elasticsearch5.x、6.x问题汇总。
-
- 下载Skywalking
从官网下载tar包(5.0.0-GA版),解压后目录结构如下:
-
- 部署Agent
无需修改agent的配置文件,我们通过启动skywalking-agent.jar时,设置启动参数指定服务名称以及收集器(Collector)的端口,命令如下:
java -javaagent:$AGENT_PATH/skywalking-agent.jar
-Dskywalking.agent.application_code=springcloud-provider
-Dskywalking.collector.servers=localhost:10800
-jar myapp.jar
说明1:-Dskywalking.agent.application_code=springcloud-provider为微服务名称
-Dskywalking.collector.servers=localhost:10800为收集器端口
说明2:服务部署在K8s中,则将agent打入dockerfile配置文件中,具体详见dockerfile文件的编写。
单点es只需要修改config/application.yml中关于h2的配置文件 (默认h2) 开放el配置即可
-
- KVM上部署Collector,Web
- 配置Collector(config/application.yml)
- KVM上部署Collector,Web
将如下配置文件中的localhost进行修改为正确的收集器IP和ES集群IP。
cluster:
# The Zookeeper cluster for collector cluster management.
zookeeper:
hostPort: localhost:2181
sessionTimeout: 100000
naming:
# Host and port used for agent config
jetty:
# 配置agent发现collector集群,host必须要系统真实网络ip地址. agent --(HTTP)--> collector
host: localhost
port: 10800
contextPath: /
remote:
gRPC:
# 配置collector节点在集群中相互通信,host必须要系统真实网络ip地址. collectorN --(gRPC) --> collectorM
host: localhost
port: 11800
agent_gRPC:
gRPC:
# 配置agent上传(链路跟踪和指标)数据到collector,host必须要系统真实网络ip地址. agent--(gRPC)--> collector
host: localhost
port: 11800
agent_jetty:
jetty:
# 配置agent上传(链路跟踪和指标)数据到collector,host必须要系统真实网络ip地址. agent--(HTTP)--> collector
# SkyWalking native Java/.Net/node.js agents don't use this.
# Open this for other implementor.
host: localhost
port: 12800
contextPath: /
analysis_register:
default:
analysis_jvm:
default:
analysis_segment_parser:
default:
bufferFilePath: ../buffer/
bufferOffsetMaxFileSize: 10M
bufferSegmentMaxFileSize: 500M
ui:
jetty:
# 配置UI访问collector,host必须要系统真实网络ip地址.
host: localhost
port: 12800
contextPath: /
# 配置Elasticsearch 集群连接信息
storage:
elasticsearch:
clusterName: CollectorDBCluster
clusterTransportSniffer: true
clusterNodes: localhost:9200
indexShardsNumber: 2
indexReplicasNumber: 0
highPerformanceMode: true
# 设置统计指标数据的失效时间,当指标数据失效时系统将数据自动删除.
traceDataTTL: 90 # 单位为分
minuteMetricDataTTL: 45 # 单位为分
hourMetricDataTTL: 36 # 单位为小时
dayMetricDataTTL: 45 # 单位为天
monthMetricDataTTL: 18 # 单位为月
configuration:
default:
# namespace: xxxxx
# 告警阀值
applicationApdexThreshold: 2000
serviceErrorRateThreshold: 10.00
serviceAverageResponseTimeThreshold: 2000
instanceErrorRateThreshold: 10.00
instanceAverageResponseTimeThreshold: 2000
applicationErrorRateThreshold: 10.00
applicationAverageResponseTimeThreshold: 2000
# 热力图配置,修改配置后需要删除热力指标统计表,由系统重建
thermodynamicResponseTimeStep: 50
thermodynamicCountOfResponseTimeSteps: 40
非集群只用es就可以了 其他不用动
-
-
- 启动 collector 节点
-
- 使用 bin/startup.sh同时启动collector和UI,若不使用1启动,需要单独启动,参考2,3
- 单独启动collector,运行 bin/collectorService.sh
- 单独启动UI,运行 bin/webappService.sh
- 访问http://localhost:8080