点击上方蓝字,关注我们
微服务架构的特性是服务体系多,这样意味着需要对很多的微服务需要进行监控以及质量体系的保障。特别是需要清晰的知道服务调用链以及服务请求的响应时间。基于这样的诉求,目前主流的APM的监控工具主要为SkyWalking和pinPoint以及Cat工具链。下面主要以SkyWalking工具为核心,来演示下基于SkyWalking全链路工具的整合和案例实战应用。
在安装SkyWalking前我们首先需要安装elasticsearch(在ELK环境搭建中文章中详细了说明了ES的搭建和应用)。到elasticsearch,到该工具的bin目录下,执行./elasticsearch就会启动ES的服务。监听的端口是9200,在浏览器访问http://localhost:9200/,就会显示如下的信息:
下面来说明SkyWalking的下载以及安装。 在SkyWalking的官方地址下载 apache-skywalking-apm-8.3.0.tar.gz ,下载成功后进行解压,在apache-skywalking/config的目录下,完善application.yml的文件,我们使用elasticsearch来存储数据,具体如下:
代码语言:javascript复制storage:
selector: ${SW_STORAGE:h2}
elasticsearch:
nameSpace: ${SW_NAMESPACE:""}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
user: ${SW_ES_USER:""}
password: ${SW_ES_PASSWORD:""}
trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""}
trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""}
secretsManagementFile: ${SW_ES_SECRETS_MANAGEMENT_FILE:""} # Secrets management file in the properties format includes the username, password, which are managed by 3rd party tool.
dayStep: ${SW_STORAGE_DAY_STEP:1} # Represent the number of days in the one minute/hour/day index.
indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:1} # Shard number of new indexes
indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:1} # Replicas number of new indexes
# Super data set has been defined in the codes, such as trace segments.The following 3 config would be improve es performance when storage super size data in es.
superDatasetDayStep: ${SW_SUPERDATASET_STORAGE_DAY_STEP:-1} # Represent the number of days in the super size dataset record index, the default value is the same as dayStep when the value is less than 0
superDatasetIndexShardsFactor: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_SHARDS_FACTOR:5} # This factor provides more shards for the super data set, shards number = indexShardsNumber * superDatasetIndexShardsFactor. Also, this factor effects Zipkin and Jaeger traces.
编辑完成后,我们到bin目录下,执行命令./startup.sh来启动,启动输出的信息为:
代码语言:javascript复制SkyWalking OAP started successfully!
SkyWalking Web Application started successfully!
监听的端口是8080,我们可以具体看下,具体如下:
代码语言:javascript复制lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 15359 liwangping 23u IPv6 0xee642bd5ccc521cf 0t0 TCP *:http-alt (LISTEN)
在浏览器输入http://localhost:8080/,就会显示如下的信息:
通过如上SkyWalking的环境搭建完整的完成,下个文章主要系统的说明SkyWalking与SpringBoot的整合以及针对API请求的全链路监控和案例实战应用。