Springboot 整合 skywalking

1. skywalking

官網:https://skywalking.apache.org/

特點:

1.SkyWalking: 一個開源的可觀測平臺, 用于從服務和云原生基礎設施收集, 分析, 聚合及可視化數據。
2.SkyWalking 更是一個現代化的應用程序性能監控(Application Performance Monitoring)系統, 尤其專為云原生、基于容器的分布式系統設計.

2.架構

skywalking.png

2.1 架構組件簡介

1. 上部分Agent: 負責從應用中,收集鏈路信息,發給Skywalking  oap 服務器.
2. 下部分Skywalking oap: 負責接收到Agent 發送的Tracing 的數據信息,然后進行分析(Analysis platform) ,存儲到外部存儲器最終提供query  查詢功能.
3.左邊Storage: Tracing數據存儲,目前支持ES、MySQL、Sharding Sphere、TiDB、H2多種存儲器,目前采用較多的是ES,主要考慮是SkyWalking開發團隊自己的生產環境采用ES為主.
4.右邊UI:負責提供控制臺,查看鏈路等等;

2.2 目錄簡介

在這里插入圖片描述

3. 啟動skywalking 默認的配置服務

[root@basenode bin]# ./startup.sh 
SkyWalking OAP started successfully!
SkyWalking Web Application started successfully!
[root@basenode bin]# pwd
/opt/module/skywalking-apm-bin-es7/bin
[root@basenode bin]# 

4. 頁面訪問地址

http://192.168.1.180:8080/

在這里插入圖片描述

4.1 有時候8080 的端口被占用后, 我們可以修改端口

直接修改8080 端口

[root@basenode webapp]# pwd
/opt/module/skywalking-apm-bin-es7/webapp
[root@basenode skywalking-apm-bin-es7]# cd webapp/
[root@basenode webapp]# ll
總用量 35360
-rw-r--r-- 1 1001 1002 36201156 7月  30 21:36 skywalking-webapp.jar
-rw-r--r-- 1 1001 1002     1346 7月  30 20:32 webapp.yml
[root@basenode webapp]# vi  webapp.yml 

# 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.

server:
  port: 8080

spring:
  cloud:
    gateway:
      routes:
        - id: oap-route
          uri: lb://oap-service
          predicates:
            - Path=/graphql/**

5. 找一個spring boot 項目 運行

命令:

java -javaagent:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar -jar /opt/module/demo/user-center-0.0.1-SNAPSHOT.jar

5.1 然后訪問自己的spring boot 項目

在這里插入圖片描述

6. 然后看Syywalking

在這里插入圖片描述

在這里插入圖片描述

7. 或者寫一個腳本

[root@basenode demo]# vi startup.sh 

#!/bin/sh
# SkyWalking Agent配置
export SW_AGENT_NAME=springboot-skywalking-wudl #Agent名字,一般使用`spring.application.name`
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=192.168.1.180:11800 #配置 Collector 地址。
export SW_AGENT_SPAN_LIMIT=2000 #配置鏈路的最大Span數量,默認為 300。
export JAVA_AGENT=-javaagent:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar
java $JAVA_AGENT -jar /opt/module/demo/user-center-0.0.1-SNAPSHOT.jar #jar啟動

7.1 運行 : sh startup.sh

[root@basenode demo]# sh startup.sh 
DEBUG 2021-09-12 18:01:30:050 main AgentPackagePath : The beacon class location is jar:file:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class. 
INFO 2021-09-12 18:01:30:051 main SnifferConfigInitializer : Config file found in /opt/module/skywalking-apm-bin-es7/agent/config/agent.config. 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)

2021-09-12 18:01:39.170  INFO 5590 --- [           main] c.wudl.usercenter.UserCenterApplication  : Starting UserCenterApplication v0.0.1-SNAPSHOT on basenode with PID 5590 (/opt/module/demo/user-center-0.0.1-SNAPSHOT.jar started by root in /opt/module/demo)
2021-09-12 18:01:39.177  INFO 5590 --- [           main] c.wudl.usercenter.UserCenterApplication  : The following profiles are active: dev
2021-09-12 18:01:43.948  INFO 5590 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9909 (http)
2021-09-12 18:01:44.050  INFO 5590 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-09-12 18:01:44.050  INFO 5590 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.29]
2021-09-12 18:01:44.196  INFO 5590 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-09-12 18:01:44.197  INFO 5590 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4819 ms
2021-09-12 18:01:47.260  INFO 5590 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-09-12 18:01:47.956  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear tk.mybatis.mapper.util.MsUtil CLASS_CACHE cache.
2021-09-12 18:01:47.956  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear tk.mybatis.mapper.genid.GenIdUtil CACHE cache.
2021-09-12 18:01:47.957  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear tk.mybatis.mapper.version.VersionUtil CACHE cache.
2021-09-12 18:01:47.957  INFO 5590 --- [           main] t.m.m.autoconfigure.MapperCacheDisabler  : Clear EntityHelper entityTableMap cache.
2021-09-12 18:01:48.365  INFO 5590 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9909 (http) with context path ''
2021-09-12 18:01:48.370  INFO 5590 --- [           main] c.wudl.usercenter.UserCenterApplication  : Started UserCenterApplication in 11.576 seconds (JVM running for 18.419)

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,461評論 6 532
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,538評論 3 417
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,423評論 0 375
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,991評論 1 312
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,761評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,207評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,268評論 3 441
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,419評論 0 288
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,959評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,782評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,983評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,528評論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,222評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,653評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,901評論 1 286
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,678評論 3 392
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,978評論 2 374

推薦閱讀更多精彩內容