Alibaba开源Java诊断工具Arthas简单介绍
Alibaba开源Java诊断工具Arthas
Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。在线排查问题,无需重启;动态跟踪Java代码;实时监控JVM状态。
当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:
1)这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
2)我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
3)遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
4)线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
5)是否有一个全局视角来查看系统的运行状况?
6)有什么办法可以监控到JVM的实时运行状态?
7)怎么快速定位应用的热点,生成火焰图?
Arthas支持JDK 6+,支持Linux/Mac/Winodws,采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断。
Github: https://github.com/alibaba/arthas
文档: https://alibaba.github.io/arthas/
下面介绍arthas的安装以及简单使用
1、下载arthas
在线方式快速安装
curl -O https://alibaba.github.io/arthas/arthas-boot.jar
java -jar arthas-boot.jar
离线的方式
https://github.com/alibaba/arthas/releases/tag/arthas-all-3.3.6
下载arthas-bin.zip
rz上传到服务器某个目录,例如/home
mkdir arthas
unzip arthas-bin.zip -d arthas
cd arthas
sh install-local.sh
2、启动arthas
1)用as.sh启动
./as.sh
2)用arthas-boot启动
java -jar arthas-boot.jar
选择应用java进程
例如kafka进程是第1个,输入1回车,Arthas会attach到目标进程上
3、help命令查看命令帮助
[arthas@10528]$ help
NAME DESCRIPTION
help Display Arthas Help
keymap Display all the available keymap for the specified connection.
sc Search all the classes loaded by JVM
sm Search the method of classes loaded by JVM
classloader Show classloader info
jad Decompile class
getstatic Show the static field of a class
monitor Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.
stack Display the stack trace for the specified class and method
thread Display thread info, thread stack
trace Trace the execution time of specified method invocation.
watch Display the input/output parameter, return object, and thrown exception of specified method invocation
tt Time Tunnel
jvm Display the target JVM information
perfcounter Display the perf counter infornation.
ognl Execute ognl expression.
mc Memory compiler, compiles java files into bytecode and class files in memory.
redefine Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)
dashboard Overview of target jvm's thread, memory, gc, vm, tomcat info.
dump Dump class byte array from JVM
heapdump Heap dump
options View and change various Arthas options
cls Clear the screen
reset Reset all the enhanced classes
version Display Arthas version
session Display current session information
sysprop Display, and change the system properties.
sysenv Display the system env.
vmoption Display, and update the vm diagnostic options.
logger Print logger info, and update the logger level
history Display command history
cat Concatenate and print files
echo write arguments to the standard output
pwd Return working directory name
mbean Display the mbean information
grep grep command for pipes.
tee tee command for pipes.
profiler Async Profiler. https://github.com/jvm-profiling-tools/async-profiler
stop Stop/Shutdown Arthas server and exit the console.
[arthas@10528]$
4、jvm——查看当前 JVM 的信息
5、thread——查看当前 JVM 的线程堆栈信息
例如thread -n 3 查看占CPU资源最多的前3个线程
6、dashboard 当前系统的实时数据面板
更多用法就不一一介绍,具体可以参考https://alibaba.github.io/arthas/官方文档
7、一图掌握Arthas—常用命令汇总
若图片不清晰,请后台联系作者索要高清大图
或者如下地址下载高清大图
https://user-images.githubusercontent.com/31468811/71954111-3010be00-321f-11ea-9900-e88195c2a570.png
- 深入了解Java对象序列化
- 在Java EE7框架中使用MongoDB
- 用事实说话,成熟的ORM性能不是瓶颈,灵活性不是问题:EF5.0、PDF.NET5.0、Dapper原理分析与测试手记
- iPhone的Wi-Fi芯片漏洞利用POC公布,赶紧更新系统吧
- No.003 Longest Substring Without Repeating Characters
- 【Spark研究】极简 Spark 入门笔记——安装和第一个回归程序
- 通常Java开发人员如何进行数据排序?
- 消息服务框架使用案例之--大文件上传(断点续传)功能
- Java中三种Set类型用法、性能大比拼
- Android基础总结(5)——数据存储,持久化技术
- 如何突破Windows环境限制打开“命令提示符”
- 【Spark研究】Spark之工作原理
- Java中泛型使用的必要性
- “一切都是消息”--MSF(消息服务框架)之【发布-订阅】模式
- java教程
- Java快速入门
- Java 开发环境配置
- Java基本语法
- Java 对象和类
- Java 基本数据类型
- Java 变量类型
- Java 修饰符
- Java 运算符
- Java 循环结构
- Java 分支结构
- Java Number类
- Java Character类
- Java String类
- Java StringBuffer和StringBuilder类
- Java 数组
- Java 日期时间
- Java 正则表达式
- Java 方法
- Java 流(Stream)、文件(File)和IO
- Java 异常处理
- Java 继承
- Java 重写(Override)与重载(Overload)
- Java 多态
- Java 抽象类
- Java 封装
- Java 接口
- Java 包(package)
- Java 数据结构
- Java 集合框架
- Java 泛型
- Java 序列化
- Java 网络编程
- Java 发送邮件
- Java 多线程编程
- Java Applet基础
- Java 文档注释
- PHP基础之面向对象篇
- PHP变量覆盖漏洞小结
- 算法复习 : 插入排序原理,记忆,时间复杂度 (7行java实现)
- PHP代码审计01之in_array()函数缺陷
- 分治思想 : 并归排序与其时间复杂度
- java Spring系列之 配置文件的操作 +Bean的生命周期+不同数据类型的注入简析+注入的原理详解+配置文件中不同标签体的使用方式
- 算法系列1 初识算法 算法复杂性模型 算法复杂度的计算
- 树莓派基础实验32:DS1302实时时钟模块实验
- Failed to parse date ["1534467411000"]:Invalid time zone indicator '0'
- 快速排序 : 调优:3亿数据40秒,2亿数据30秒,1亿数据15秒
- Spring系列之新注解配置+Spring集成junit+注解注入
- Spring系列之aAOP AOP是什么?+xml方式实现aop+注解方式实现aop
- 线上工程启动日志不滚动了——通过查看堆栈信息排查的过程(ES批量插入)
- Java中使用方法的注意事项
- 微信小程序转发朋友圈详解