Alibaba开源Java诊断工具Arthas简单介绍

简介: Alibaba开源Java诊断工具Arthas简单介绍

640.jpg

Alibaba开源Java诊断工具Arthas

640.png


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


640.png

640.png

640.png


2、启动arthas


1)用as.sh启动

./as.sh


640.png

2)用arthas-boot启动  

java -jar arthas-boot.jar

选择应用java进程

例如kafka进程是第1个,输入1回车,Arthas会attach到目标进程上


640.png


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]$

640.png


4、jvm——查看当前 JVM 的信息

640.png

640.png

5、thread——查看当前 JVM 的线程堆栈信息

640.png

例如thread -n 3 查看占CPU资源最多的前3个线程

640.png

6、dashboard 当前系统的实时数据面板

640.png

更多用法就不一一介绍,具体可以参考https://alibaba.github.io/arthas/官方文档


7、一图掌握Arthas—常用命令汇总


若图片不清晰,请后台联系作者索要高清大图

或者如下地址下载高清大图

https://user-images.githubusercontent.com/31468811/71954111-3010be00-321f-11ea-9900-e88195c2a570.png

640.png

640.png

相关文章
|
Java 数据安全/隐私保护
快手小红书抖音留痕工具,自动留痕插件工具,java代码开源
这个框架包含三个核心模块:主操作类处理点赞评论、配置管理类和代理管理类。使用时需要配合
|
人工智能 Kubernetes Java
回归开源,两位 Java 和 Go 程序员分享的开源贡献指引
Higress是一个基于Istio和Envoy的云原生API网关,支持AI功能扩展。它通过Go/Rust/JS编写的Wasm插件提供可扩展架构,并包含Node和Java的console模块。Higress起源于阿里巴巴,解决了Tengine配置重载及gRPC/Dubbo负载均衡问题,现已成为阿里云API网关的基础。本文介绍Higress的基本架构、功能(如AI网关、API管理、Ingress流量网关等)、部署方式以及如何参与开源贡献。此外,还提供了有效的开源贡献指南和社区交流信息。
2679 33
|
人工智能 Java 开发者
阿里出手!Java 开发者狂喜!开源 AI Agent 框架 JManus 来了,初次见面就心动~
JManus是阿里开源的Java版OpenManus,基于Spring AI Alibaba框架,助力Java开发者便捷应用AI技术。支持多Agent框架、网页配置、MCP协议及PLAN-ACT模式,可集成多模型,适配阿里云百炼平台与本地ollama。提供Docker与源码部署方式,具备无限上下文处理能力,适用于复杂AI场景。当前仍在完善模型配置等功能,欢迎参与开源共建。
3636 58
阿里出手!Java 开发者狂喜!开源 AI Agent 框架 JManus 来了,初次见面就心动~
|
Java Linux Apache
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
693 5
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
|
消息中间件 人工智能 Java
抖音微信爆款小游戏大全:免费休闲/竞技/益智/PHP+Java全筏开源开发
本文基于2025年最新行业数据,深入解析抖音/微信爆款小游戏的开发逻辑,重点讲解PHP+Java双引擎架构实战,涵盖技术选型、架构设计、性能优化与开源生态,提供完整开源工具链,助力开发者从理论到落地打造高留存、高并发的小游戏产品。
|
NoSQL Java Redis
推荐一款好用的开源免费Java CMS内容管理站群系统
Java开源内容管理系统(JProcms),基于SpringCloud、SpringBoot、MyBatisPlus、Vue3等技术构建,采用Apache-2.0协议,支持免费商用。系统具备自定义字段存储与可视化设计、API制作网站群页面等功能,强调简单灵活的设计理念,降低二次开发成本。支持多种数据库、消息队列和认证方式,提供SaaS多租户、动态权限菜单、工作流配置等强大功能,同时集成阿里云、腾讯云服务,适用于高效建站与内容管理。
2205 4
|
文字识别 监控 Java
顺丰同城抢单辅助脚本,顺丰骑士抢单辅助免封号,自动抢单神器【java版开源】
这是一套OCR实时检测订单列表并自动右滑的完整代码方案,适用于学习研究。代码包含四个主要模块:OCR处理(文字识别)、价格分析
|
Arthas 监控 Java
开源Java诊断工具Arthas:开篇之watch实战
还在为排查Java程序线上问题头痛吗,看我们用阿里开源的诊断神器 Arthas 来帮您
1962 1
|
Arthas 监控 Java
Arthas 可以用于监控和诊断在 Windows 系统下部署的 Tomcat 服务
Arthas 可以用于监控和诊断在 Windows 系统下部署的 Tomcat 服务
1905 2
|
Arthas 监控 Java
Java 诊断利器 Arthas使用
Java 诊断利器 Arthas使用
5626 0