前言
最开始接触Arthas,是在今年的三月份,那时候算是我的转正考试吧,总监让我回去看下线上诊断工具,并对团队里的人讲解一下,那时候看了小马哥的Arthas视频,当时B站上还没有这么多教学视频,只有小马哥讲的最详细。
Arthas主要是定位线上出现的问题,因为很多问题在测试环境中很难再重现。
当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:
1.这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
2.我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
3.遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
4.线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
5.是否有一个全局视角来查看系统的运行状况?
6.有什么办法可以监控到JVM的实时运行状态?
7.怎么快速定位应用的热点,生成火焰图?
具体如何操作Arthas及其Arthas的高阶用法移步Arthas官方手册
快速开始
解压压缩文件,找到arthas-boot.jar
文件
1 | java -jar arthas-boot.jar |
如下我们可以看到在本机上运行的java程序,选择需要诊断的进程
1 | [root@zyj software]# java -jar arthas-boot.jar |
当我们看到下面这个界面,就说明我们可以执行相关的arthas命令了
1 | [INFO] arthas home: /root/.arthas/lib/3.4.5/arthas |
执行dashboard
命令可以看到,当前进程信息
1 | ID NAME GROUP PRIORI STATE %CPU DELTA_ TIME INTER DAEMON |
具体高阶命令可以查看官方文档
常用命令
这个图是官方钉钉群某个大佬总结出来的,基本所有命令都在上面了,讲的很详细,如有侵权请联系删
重要issue链接
由于Arthas拿不到非静态对象,于是最后这篇文章在web开发诊断中及其重要
1 | #可以用tt命令的-i参数来指定index,并且用-w参数来执行ognl表达式来获取spring context |
Alibaba Arthas实践–获取到SpringContext然后为所欲为
如果有小伙伴,想要一起交流学习的,欢迎添加博主微信。