天天看點

分布式鍊路跟蹤 skywalking

首先要知道的是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

分布式鍊路跟蹤 skywalking

# 修改

# 如果 cluster.name 不設定為 CollectorDBCluster ,則需要修改 SkyWalking 的配置檔案cluster.name: CollectorDBCluster 

# 增加thread_pool.bulk.queue_size: 1000

如果是 linux 環境,Elasticsearch 安裝可能沒有那麼順利,請參考Linux環境下安裝Elasticsearch5.x、6.x問題彙總。

    1. 下載下傳Skywalking

從官網下載下傳tar包(5.0.0-GA版),解壓後目錄結構如下:

分布式鍊路跟蹤 skywalking
    1. 部署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配置即可

    1. KVM上部署Collector,Web
      1. 配置Collector(config/application.yml)

将如下配置檔案中的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就可以了  其他不用動

      1. 啟動 collector 節點
  1. 使用 bin/startup.sh同時啟動collector和UI,若不使用1啟動,需要單獨啟動,參考2,3
  2. 單獨啟動collector,運作 bin/collectorService.sh
  3. 單獨啟動UI,運作 bin/webappService.sh
  4. 通路http://localhost:8080