当前位置:网站首页>Arthas简介及IDEA插件快速入门
Arthas简介及IDEA插件快速入门
2022-07-13 17:47:00 【Kuo-Teng】
Arthas简介及IDEA插件快速入门
1. Arthas简介
Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。
当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:
- 这个类从哪个
jar包加载的?为什么会报各种类相关的Exception? - 我改的代码为什么没有执行到?难道是我没
commit?分支搞错了? - 遇到问题无法在线上
debug,难道只能通过加日志再重新发布吗? - 线上遇到某个用户的数据处理有问题,但线上同样无法
debug,线下无法重现! - 是否有一个全局视角来查看系统的运行状况?
- 有什么办法可以监控到
JVM的实时运行状态? - 怎么快速定位应用的热点,生成火焰图?
- 怎样直接从
JVM内查找某个类的实例?
Arthas支持JDK 6+,支持Linux/Mac/Windows,采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断。
说了一大堆,其实Arthas最厉害的地方就在于,能够让你在线上环境没有日志的情况下进行调试程序,定位问题。
2. Arthas快速入门
- 首先在
IDEA的插件Marketplace中找到arthas idea这款插件,安装;可以点击这里查看插件详情~ - 打开线上环境的
terminal,执行以下语句curl -O https://arthas.aliyun.com/arthas-boot.jar java -jar arthas-boot.jar - 然后会出现如下界面
[INFO] arthas-boot version: 3.6.2 [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER. * [1]: 592 arthas-boot.jar [2]: 1 /data0/www/htdocs/code/lib/XXXXXXX.jar [3]: 403 arthas-boot.jar [4]: 295 arthas-boot.jar [5]: 503 arthas-boot.jar - 选择应用的
java进程即可; - 比如我的应用的
java进程是第2个,则输入2,再输入回车/enter。Arthas会attach到目标进程上,并输出日志:[INFO] arthas home: /root/.arthas/lib/3.6.2/arthas [INFO] Try to attach process 1 [INFO] Attach process 1 success. [INFO] arthas-client connect 127.0.0.1 3658 ,---. ,------. ,--------.,--. ,--. ,---. ,---. / O \ | .--. ''--. .--'| '--' | / O \ ' .-' | .-. || '--'.' | | | .--. || .-. |`. `-. | | | || |\ \ | | | | | || | | |.-' | `--' `--'`--' '--' `--' `--' `--'`--' `--'`-----' wiki https://arthas.aliyun.com/doc tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html version 3.6.2 main_class pid 1 time 2022-06-30 18:24:02 - 然后如何在没有日志的情况下,像在本地一样调试线上的代码呢?首先定位到想要查看的方法(
Arthas只支持到方法级别)

- 在想要定位的方法上点击右键,选择
Arthas Command,选择Watch; - 回到
terminal的界面粘贴命令
默认[[email protected]]$ watch com.ke.utopia.scs.saas.base.utils.DateUtils transferString2LocalDate '{params,returnObj,throwExp}' -n 5 -x 3-n 5,代表命令执行最大次数为5次;可以手动更改; - 然后
terminal中就会显示该方法的入参和出参,就像在本地调试一样方便~
边栏推荐
- 网络安全应急响应-终端检测与响应技术
- North tour project notes
- [prettier] the code automatically formatted by prettier does not take effect
- PHP docking Alipay web payment -tp5.1 framework
- Intranet penetration notes - MSF
- 微信支付退款 PHP
- unity实验-重力撞墙
- Buuctf nine links
- 密态数字经济:用密码去“深海淘珍珠”
- Compilation principle - lexical analyzer design
猜你喜欢

El button display and disable

Log blacklist can really save you money!

内网渗透笔记——三层发现and四层发现

Convert list data to tree data
![[ASIS 2019]Unicorn shop](/img/e2/c295a83e03eeaa720a631f6d736eb2.png)
[ASIS 2019]Unicorn shop

39.js-- scope

Dense Digital Economy: using passwords to "search for pearls in the deep sea"

网络通信安全部分笔记——静态路由及实验

NFTScan 开发者平台推出多链 NFT 数据 Pro API 服务

网络通信安全部分笔记——OSPF理论及实验
随机推荐
JS copy text to clipboard
PLSQL problem solving ora-12154: tns: unable to resolve the specified connection identifier
[ASIS 2019]Unicorn shop
网络通信安全部分笔记二
[Vue] keep alive the simplest way to clear the cache
[NCTF2019]Fake XML cookbook
Analysis, capture and simulation attack of Sniffer Pro on ARP Protocol
密态数字经济:用密码去“深海淘珍珠”
Network security emergency response terminal detection and response technology
Buuctf mysterious Tornado
MSF Foundation
MySQL-约束
摩斯隐私计算一体机全项通过深圳国金测评中心83项测评
Single file component
Test MySQL master-slave synchronization under win10
MSF利用永恒之蓝渗透win2003
WP of the southwest division of the 15th National College Students Information Security Competition (ciscn) 2022
36.js-- prototype chain 2-- (mainly written test questions)
ES6 -- object
ES6 -- class