Mac 安裝使用Arthas

工具:https://arthas.aliyun.com/

image.png

1.安裝arthas

curl -O https://alibaba.github.io/arthas/arthas-boot.jar

image.png

2.啟動(dòng)jar

java -jar arthas-boot.jar

image.png

3.出現(xiàn)所有可監(jiān)控的進(jìn)程,輸入要監(jiān)控的進(jìn)程,回車

image.png
  • 執(zhí)行監(jiān)控進(jìn)程后,報(bào)錯(cuò):【沒報(bào)錯(cuò),直接看4】


    image.png
[INFO] Start download arthas from remote server: https://arthas.aliyun.com/download/3.6.7?mirror=aliyun
[INFO] File size: 12.92 MB, downloaded size: 9.60 MB, downloading ...
[INFO] Download arthas success.
[INFO] arthas home: /Users/cici/.arthas/lib/3.6.7/arthas
[INFO] Try to attach process 13160
Exception in thread "main" java.lang.IllegalArgumentException: Can not find tools.jar under java home: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home, please try to start arthas-boot with full path java. Such as /opt/jdk/bin/java -jar arthas-boot.jar
    at com.taobao.arthas.boot.ProcessUtils.findJavaHome(ProcessUtils.java:222)
    at com.taobao.arthas.boot.ProcessUtils.startArthasCore(ProcessUtils.java:233)
    at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:586)

解決辦法:

執(zhí)行:vim ~/.bash_profile

添加以下內(nèi)容:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

執(zhí)行:source ~/.bash_profile
  • 重新啟動(dòng)jar,成功


    image.png

4. 啟動(dòng)接口觀察

trace com.xx.assetsinnovation.scene.service.impl.xxxServiceImpl queryById -n 50 --skipJDKMethod false '#cost > 200'

image.png

  • 針對部分接口,想進(jìn)行時(shí)間上的過濾

trace com.xx.assetsinnovation.scene.service.impl.xxxServiceImpl queryById -n 5 --skipJDKMethod false '#cost > 200'

5.查看監(jiān)控的結(jié)果

  • 頭部位置,說明該接口耗時(shí)11s


    image.png
  • 發(fā)現(xiàn)紅色圈起來的部分就是耗時(shí)占比嚴(yán)重的地方,針對性的去優(yōu)化


    image.png

    image.png

6. 接口性能達(dá)標(biāo),但是每次并發(fā)就是上不去

  • 針對權(quán)限校驗(yàn)進(jìn)行檢查過濾
    trace com.bantu.platform.sso.web.client.cors.CorsSsoAgentFilter doFilterInternal -n 5000 --skipJDKMethod false '#cost > 300'

  • 其中還碰到過arthas監(jiān)控的服務(wù)端口不可用的情況


    image.png

java -jar arthas-boot.jar --telnet-port 9998 --http-port 9999

7.監(jiān)控客戶端 http://127.0.0.1:8563/

除了在命令行查看外,還可以通過瀏覽器訪問http://127.0.0.1:8563/查看。如下圖:可以直接操作相關(guān)的命令參數(shù)

image.png
image.png

8.退出

看見那個(gè)$符號,就是打開進(jìn)入了監(jiān)控客戶端??梢允褂胵uit(退出當(dāng)前客戶端)、stop\shutdown(關(guān)閉arthas服務(wù)端,并退出所有客戶端)


image.png

9.常用命令

https://blog.csdn.net/huo065000/article/details/123231411

10.快速獲取arthas命令

arthas的命令較多,如果每次都需要自己
idea安裝插件 arthas idea

image
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容