企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 一、概述 Arthas号称是Java 线上问题定位处理的终极利器,它针对线上应用的诊断,提供了很多便利的措施,我们可以使用该工具来诊断排查问题; 使用 Arthas 之前,当遇到 Java 线上问题时,如 CPU 飙升、负载突高、内存溢出等问题,你需要查命令,查网络,然后 jps、jstack、jmap、jhat、jstat、hprof 等一通操作。最终焦头烂额,还不一定能查出问题所在。而现在,大多数的常见问题你都可以使用 Arthas 轻松定位; ## 二、快速入门 Arthas只是一个 java 程序,所以可以直接用 `java -jar` 运行。运行时或者运行之后要选择要监测的 Java 进程; ### **安装** ``` curl -O https://arthas.aliyun.com/arthas-boot.jar ``` ### **运行** ``` java -jar arthas-boot.jar ``` ![](https://img.kancloud.cn/18/70/18703c8b205f47262d3700c412c34879_1295x259.png) 选择要诊断的Java进程,比如输入2,Arthas会attach到目标进程上,并输出日志; ![](https://img.kancloud.cn/c6/f2/c6f2bc77b603b842b1434e4addf3d785_1443x829.png) ### **查看dashboard** 输入dashboard,按`回车`,会定时刷新展示当前进程的信息,按`ctrl+c`可以中断执行; ![](https://img.kancloud.cn/48/c2/48c240274cdc3986e2396d8383428d43_1485x764.png) ### **退出** 如果只是退出当前的连接,可以用`quit`或者`exit`命令。Attach到目标进程上的arthas还会继续运行,端口会保持开放,下次连接时可以直接连接上; 如果想完全退出arthas,可以执行`stop`命令; ## 三、正式使用 接下来,就能够正常使用各种命令,来解决各种问题了; 命令清单: * [dashboard](https://arthas.aliyun.com/doc/dashboard.html) * [thread](https://arthas.aliyun.com/doc/thread.html) * [jvm](https://arthas.aliyun.com/doc/jvm.html) * [memory](https://arthas.aliyun.com/doc/memory.html) * [sysprop](https://arthas.aliyun.com/doc/sysprop.html) * [sysenv](https://arthas.aliyun.com/doc/sysenv.html) * [vmoption](https://arthas.aliyun.com/doc/vmoption.html) * [perfcounter](https://arthas.aliyun.com/doc/perfcounter.html) * [logger](https://arthas.aliyun.com/doc/logger.html) * [mbean](https://arthas.aliyun.com/doc/mbean.html) * [getstatic](https://arthas.aliyun.com/doc/getstatic.html) * [ognl](https://arthas.aliyun.com/doc/ognl.html) * [sc](https://arthas.aliyun.com/doc/sc.html) * [sm](https://arthas.aliyun.com/doc/sm.html) * [dump](https://arthas.aliyun.com/doc/dump.html) * [heapdump](https://arthas.aliyun.com/doc/heapdump.html) * [vmtool](https://arthas.aliyun.com/doc/vmtool.html) * [jad](https://arthas.aliyun.com/doc/jad.html) * [classloader](https://arthas.aliyun.com/doc/classloader.html) * [mc](https://arthas.aliyun.com/doc/mc.html) * [retransform](https://arthas.aliyun.com/doc/retransform.html) * [redefine](https://arthas.aliyun.com/doc/redefine.html) * [monitor](https://arthas.aliyun.com/doc/monitor.html) * [watch](https://arthas.aliyun.com/doc/watch.html) * [trace](https://arthas.aliyun.com/doc/trace.html) * [stack](https://arthas.aliyun.com/doc/stack.html) * [tt](https://arthas.aliyun.com/doc/tt.html) * [profiler](https://arthas.aliyun.com/doc/profiler.html) * [cat](https://arthas.aliyun.com/doc/cat.html) * [echo](https://arthas.aliyun.com/doc/echo.html) * [grep](https://arthas.aliyun.com/doc/grep.html) * [base64](https://arthas.aliyun.com/doc/base64.html) * [tee](https://arthas.aliyun.com/doc/tee.html) * [pwd](https://arthas.aliyun.com/doc/pwd.html) * [auth](https://arthas.aliyun.com/doc/auth.html) * [options](https://arthas.aliyun.com/doc/options.html) 辅助命令: * [help](https://arthas.aliyun.com/doc/help.html) * [cls](https://arthas.aliyun.com/doc/cls.html) * [session](https://arthas.aliyun.com/doc/session.html) * [reset](https://arthas.aliyun.com/doc/reset.html) * [version](https://arthas.aliyun.com/doc/version.html) * [history](https://arthas.aliyun.com/doc/history.html) * [quit](https://arthas.aliyun.com/doc/quit.html) * [stop](https://arthas.aliyun.com/doc/stop.html) * [keymap](https://arthas.aliyun.com/doc/keymap.html)