SkyWalking 概述
SkyWalking 是观察性分析平台和应用性能管理系统。提供分布式追踪、服务网格遥测分析、度量聚合和可视化一体化解决方案。支持Java, .Net Core, PHP, NodeJS, Golang, LUA语言探针,支持Envoy + Istio构建的Service Mesh。
这里抛出两个概念,SkyWalking 服务和语言探针。SkyWalking 本身是用 Java 写的,作为应用性能管理系统,探针是收集应用性能指标数据的,比如在 .net core 项目中引入 SkyAPM.Agent.AspNetCore,做一些配置,就可以将该项目的数据报告给 SkyWalking 服务,在 SkyWalking UI 界面看到可视化的数据。
SkyWalking 展示的数据是需要存储的,默认是 H2,同时也支持使用ElasticSearch、MySQL、TiDB、InfluxDB,这里使用 elasticsearch。
环境说明
本机开发环境:Win10 + VS2019,服务器是 CentOS,ip:172.17.81.23
Docker 方式(踩坑)
安装 Elasticsearch
docker run --name elasticsearch --restart always -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.8.1
安装 Skywalking
docker run --name skywalking --restart always -d -p 11800:11800 -p 12800:12800 --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 apache/skywalking-oap-server:8.1.0-es7
安装 SkyWalking-UI
docker run --name skywalking-ui --restart always -d -p 8080:8080 --link skywalking:skywalking -e SW_OAP_ADDRESS=skywalking:12800 apache/skywalking-ui:8.1.0
本机访问 skywalking 服务,然而页面一片空白,审查元素发现这么一句话:We're sorry but SkyWalking doesn't work properly without JavaScript enabled.Please enable it to continue.
查看 Docker 服务,发现 SkyWalking 一直在 restart 状态。查看 dockerr 日志,skywalking 连接到 elasticsearch 超时。
Docker Compose 方式(踩坑)
说明:用到的 compose 文件版本是 3.8,需要 Docker 版本在 19.03.0 或更新的版本。
mkdir skywalking cd skywalking
vi docker-compose.yml
# 内容见 https://github.com/apache/skywalking-docker/blob/master/8/8.1.0/compose-es7/docker-compose.yml docker-compose up -d
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: '3.8'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.5.0
container_name: elasticsearch
restart: always
ports:
- 9200:9200
healthcheck:
test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
oap:
image: apache/skywalking-oap-server:8.1.0-es7
container_name: oap
depends_on:
- elasticsearch
links:
- elasticsearch
restart: always
ports:
- 11800:11800
- 12800:12800
healthcheck:
test: ["CMD-SHELL", "/skywalking/bin/swctl"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
environment:
SW_STORAGE: elasticsearch7
SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
ui:
image: apache/skywalking-ui:8.1.0
container_name: ui
depends_on:
- oap
links:
- oap
restart: always
ports:
- 8080:8080
environment:
SW_OAP_ADDRESS: oap:12800