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'
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.
trace
1.确定耗时节点 、2.通过方法执行实际调用路径
trace demo.MathGame primeFactors
stack
查看方法的调用链
stack demo.MathGame primeFactors -n 5 '1==1'
tt
查看方法的调用记录 并对异常记录进行查看
tt -t demo.MathGame primeFactors
tt -i index 指定查看 index为第一步报错的序列
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