当前位置:   article > 正文

Arthas运用且与Docker结合_arthas 加入到dockerfile

arthas 加入到dockerfile

dockerfile 配置

COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas

执行流程

##基础镜像

1.java -jar /opt/arthas/arthas-boot.jar

## help
help
## 查看dashboard
dashboard 回车

## 查看线程1
thread 1

## 反编译class
jad demo.MathGame

## 可以通过 sc 命令来查找JVM里已加载的类
sc -d *MathGame


## 查看函数返回
watch -h
watch demo.MathGame primeFactors params
watch demo.MathGame primeFactors returnObj
watch demo.MathGame primeFactors '{params, target, returnObj}' -x 2
watch *StringUtils isBlank params '#cost>100'
  • 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

arthas 重点命令

thread

排查应用请求响应慢,锁等待,异常线程定位

thread -help
thread -n -1 The number of thread(s) to show, ordered by cpu utilization, -1 to show all
thread id  查看指定线程堆栈
thread -b  Find the thread who is holding a lock that blocks the most number of threads.
thread -i Specify the sampling interval (in ms) when calculating cpu usage.
  • 1
  • 2
  • 3
  • 4
  • 5
trace

1.确定耗时节点 、2.通过方法执行实际调用路径

trace demo.MathGame primeFactors
  • 1
stack

查看方法的调用链

stack demo.MathGame primeFactors -n 5 '1==1'
  • 1
tt

查看方法的调用记录 并对异常记录进行查看

tt -t demo.MathGame primeFactors
tt -i index    指定查看  index为第一步报错的序列
  • 1
  • 2
jad

1.指定代码改动是否提交 2.查看代码源码

watch

1.查看方法入参和出参

idea 插件

1.使用手册 https://www.yuque.com/arthas-idea-plugin/help

停止arthas

java -jar /opt/arthas/arthas-client.jar 127.0.0.1 3658 -c “stop”

参考地址

https://arthas.aliyun.com/doc/docker.html
https://blog.csdn.net/zhang_jiayuan/article/details/109261904

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号