SkyWalking

 ·  ☕ 3  · 👀...

介绍

技术 特性 适用场景 说明
SkyWalking - 分布式跟踪
- 服务网格遥测分析
- 度量聚合
- 可视化
- 报警支持
- 多语言代理
分布式系统应用性能监控 - 官网
- Github
- 下载
- Quick Start

安装

安装jdk

参考 {% post_link jdk安装 %}

安装Elasticsearch

参考 {% post_link Elasticsearch基础 %}

配置Elasticsearch

1
2
3
4
5
6
7
8
$ vi /etc/config/elasticsearch.yml
##### 内容开始 #####
# 如果 Skywalking的cluster.name 不设置为 CollectorDBCluster ,则需要修改 SkyWalking 的配置文件
cluster.name: CollectorDBCluster   
network.host: 0.0.0.0
# 增加
thread_pool.bulk.queue_size: 1000
##### 内容结束 #####

安装SkyWalking

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 下载
$ cd /usr/local/
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/skywalking/6.3.0/apache-skywalking-apm-6.3.0.tar.gz

# 解压
$ tar zxvf apache-skywalking-apm-6.3.0.tar.gz

# 创建链接
$ ln -s apache-skywalking-apm-bin skywalking

# 配置SkyWalking
$ vi skywalking/config/application.yml
## 默认数据存储开启是的 h2,这里我们需要用elasticsearch替换掉h2,注释掉后内容如下:
##### 注释内容开始 #####
storage:
#  h2:
#    driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
#    url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db}
#    user: ${SW_STORAGE_H2_USER:sa}
#    metadataQueryMaxSize: ${SW_STORAGE_H2_QUERY_MAX_SIZE:5000}
##### 注释内容结束 #####

##### 增加内容开始 #####
storage:
  elasticsearch:
    cluster_name: CollectorDBCluster    # 修改集群名称为你的ES的集群名称
    cluster_transport_sniffer: true
    cluster_nodes: 192.168.0.202:9300   # 修改集群节点为你的ES的集群节点地址
    index_shards_number: 2
    index_replicas_number: 0
    ttl: 7
##### 内容结束 ##### 
## 启动
$ cd skywalking/bin/
$ ./startup.sh

# 修改Agent配置
$ vi skywalking/agent/config/agent.config
##### 内容开始 #####
agent.application_code=Your_ApplicationName 
collector.servers=127.0.0.1:11800
logging.level=info         
##### 内容结束 ##### 

停止 skywalking 脚本

1
2
3
#!/bin/bssh
ps aux | grep org.apache.skywalking.oap.server.starter.OAPServerStartUp | grep -v grep | awk '{print $2}' | xargs kill  > /dev/null
ps aux | grep skywalking-webapp.jar | grep -v grep | awk '{print $2}' | xargs kill  > /dev/null

访问页面

说明
URL http://localhost:8080
用户名 admin
密码 admin

设置应用

通过 Jar 包方式接入

1
2
3
$ java -javaagent:/path/to/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=nacos-provider -Dskywalking.collector.backend_service=localhost:11800 -jar yourApp.jar

$ java -javaagent:/path/to/skywalking-agent/skywalking-agent.jar -jar yourApp.jar

通过 IDEA 进行调试接入

1
2
3
-javaagent:/path/to/skywalking-agent/skywalking-agent.jar
-Dskywalking.agent.service_name=<ServiceName>
-Dskywalking.collector.backend_service=172.18.30.74:11800

通过容器接入

常见问题

Elasticsearch6 和Elasticsearch7 的配置变化

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# ES6
storage:
  elasticsearch:
    # nameSpace: ${SW_NAMESPACE:""}
    # user: ${SW_ES_USER:""} # User needs to be set when Http Basic authentication is enabled
    # password: ${SW_ES_PASSWORD:""} # Password to be set when Http Basic authentication is enabled
    #trustStorePath: ${SW_SW_STORAGE_ES_SSL_JKS_PATH:""}
    #trustStorePass: ${SW_SW_STORAGE_ES_SSL_JKS_PASS:""}
    clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200}
    protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
    indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2}
    indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0}
    # Those data TTL settings will override the same settings in core module.
    recordDataTTL: ${SW_STORAGE_ES_RECORD_DATA_TTL:7} # Unit is day
    otherMetricsDataTTL: ${SW_STORAGE_ES_OTHER_METRIC_DATA_TTL:45} # Unit is day
    monthMetricsDataTTL: ${SW_STORAGE_ES_MONTH_METRIC_DATA_TTL:18} # Unit is month
    # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html
    bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:2000} # Execute the bulk every 2000 requests
    bulkSize: ${SW_STORAGE_ES_BULK_SIZE:20} # flush the bulk every 20mb
    flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests
    concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests
    resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000}
    metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000}
    segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200}
    advanced: ${SW_STORAGE_ES_ADVANCED:""}

##### ES7 #####
storage:
  elasticsearch7:
    # ... the configurations shared with ES6 that are listed above ...

    # Index max result window, for segment deep pagination, usually we don't recommend to scroll too many pages,
    # instead, give more query criteria (e.g. service id or time range), to narrow the query results.
    # see https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html for more information
    indexMaxResultWindow: ${SW_STORAGE_ES_INDEX_MAX_RESULT_WINDOW:5000}

常见错误

Skywalking UI Service Name 不显示

  1. 检查ES 中 service_inventory 索引是否有数据。
  2. 更改有下角的起止时间或时区,将时间范围扩大。

参考


Wanglibing
Wanglibing
Engineer,Lifelong learner