下载Jar:
wget https://alibaba.github.io/arthas/arthas-boot.jar
启动Arthas:
[root@localhost local]# java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.3.6
[INFO] Can not find java process. Try to pass <pid> in command line.
Please select an available pid.
先启动一个Jar进程:
java -jar jvm.jar
[root@localhost local]# java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.3.6
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 10580 JVM.jar
1
[INFO] arthas home: /root/.arthas/lib/3.3.6/arthas
[INFO] Try to attach process 10580
[INFO] Attach process 10580 success.
[INFO] arthas-client connect 127.0.0.1 3658
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki https://alibaba.github.io/arthas
tutorials https://alibaba.github.io/arthas/arthas-tutorials
version 3.3.6
pid 10580
time 2020-07-12 15:08:45
[arthas@10580]$ dashboard
Arthas 命令
dashboard: 查看整个进程的运行情况,线程、内存、GC、运行环境信息
thread: 可以查看线程详细情况
thread加上线程ID : 可以查看线程堆栈
thread -b: 可以查看线程死锁
jad 类的全名 可以反编译,这样可以方便我们查看线上代码是否是正确的版本
ognl 可以查看线上系统变量的值,可以修改变量的值
ognl @package@变量
ognl ‘@package@hashSet.add(“123”)’