安装
wget https://alibaba.github.io/arthas/arthas-boot.jar
# 启动完后, 如果有多个 java 进程, 会出现选择列表. 请根据实际情况, 选相应的 PID 的号.
java -jar arthas-boot.jar --repo-mirror aliyun --use-http
常用命令
dashboard : 显示整体数据面板
thread : 线程相关. 直接回车的话, 显示整体线程情况
thread -n 5 -i 5000 : 在收集 5 秒, 然后输出 top 5 的 CPU 消耗的线程
thread 1 : 显示指定线程号为 1 的 stack
thread -b 查看阻塞线程
jvm : 输出当前 jvm 信息
syspro/sysenv : 输出当前系统属性/环境变量
排查耗时方法
trace -n 3 com.uniweibo.service.RealtimeBidService makeBidResponse '#cost > 30'
如果想过虑掉 JDK 相关的. 可加参数 -j. 即
trace -n 3 -j com.uniweibo.service.RealtimeBidService makeBidResponse '#cost > 30'
退出
reset : 重置增强类
quit : 退出 arthas 客户端
shutdown/stop : 退出 arthas 服务器端