arthas简单使用

Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。
当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:

  1. 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
  2. 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
  3. 遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
  4. 线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
  5. 是否有一个全局视角来查看系统的运行状况?
  6. 有什么办法可以监控到JVM的实时运行状态?
  7. 怎么快速定位应用的热点,生成火焰图?
  8. 怎样直接从JVM内查找某个类的实例?

怎么使用?

  1. 如果是docker容器,先进入容器
    docker exec -it [容器id] bash

  2. 下载
    curl -O https://alibaba.github.io/arthas/arthas-boot.jar

  3. 启用
    java -jar arthas-boot.jar
    在这里插入图片描述

  4. 选择进程,输入1
    在这里插入图片描述

  5. 输入help查看命令帮助

    [arthas@1]$ help
     NAME         DESCRIPTION                                                                                                                                                     
     help         Display Arthas Help                                                                                                                                             
     auth         Authenticates the current session                                                                                                                               
     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 information.                                                                                                                           
     ognl         Execute ognl expression.                                                                                                                                        
     mc           Memory compiler, compiles java files into bytecode and class files in memory.                                                                                   
     redefine     Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)                                                                                      
     retransform  Retransform classes. @see Instrumentation#retransformClasses(Class...)                                                                                          
     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                                                                                                                                     
     base64       Encode and decode using Base64 representation                                                                                                                   
     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                                                                                           
     vmtool       jvm tool                                                                                                                                                        
     stop         Stop/Shutdown Arthas server and exit the console.
    
  6. 使用dashboard命令
    在这里插入图片描述
    线程名非常重要,如果发生内存溢出,CPU打满就可以直接通过线程名定位问题

  7. thread查看线程信息
    在这里插入图片描述

  8. heapdump生成堆dump
    在这里插入图片描述

  9. jvm显示jvm信息
    在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值