栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

我的arthas使用学习过程

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

我的arthas使用学习过程

我的arthas使用学习过程 在我的aliyun服务器安装jdk
#3.安装 JDK
yum install -y java-1.8.0-openjdk*
后台运行demo程序
nohup java -jar math-game.jar > log.file 2>&1 &

# 上面的2 和 1 的意思如下:
0    标准输入(一般是键盘)
1    标准输出(一般是显示屏,是用户终端控制台)
2    标准错误(错误信息输出)

将运行的jar 错误日志信息输出到log.file文件中,然后(>&1)就是继续输出到标准输出(前面加的&,是为了让系统识别是标准输出),最后一个&,表示在后台运行。
下载arthas
curl -O https://arthas.aliyun.com/arthas-boot.jar
运行arthas
java -jar arthas-boot.jar

运行后控制台会列出现在在跑的进程:
[INFO] arthas-boot version: 3.6.1
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 12588 math-game.jar
备注:
执行该程序(arthas-boot.jar)的用户需要和目标进程(math-game.jar)具有相同的权限
如果attach不上目标进程,可以查看~/logs/arthas/ 目录下的日志

这里我们输入1,按回车,让arthas关联该进程12588
使用1:查看仪表盘

dashboard 查看仪表盘(包含内存信息,线程信息等,系统变量信息等)
按ctrl+c可以中断执行

ID NAME                GROUP     PRIORI STATE %CPU   DELTA TIME   INTER DAEMON 
49 Timer-for-arthas-da system    5      RUNNA 0.32   0.015 0:0.01 false true   
-1 C1 CompilerThread1  -         -1     -     0.28   0.014 0:2.39 false true   
-1 C2 CompilerThread0  -         -1     -     0.23   0.011 0:2.78 false true   
-1 VM Periodic Task Th -         -1     -     0.08   0.004 0:1.94 false true   
47 arthas-NettyHttpTel system    5      RUNNA 0.06   0.003 0:0.11 false true   
1  main                main      5      TIMED 0.02   0.000 0:0.79 false false  
-1 VM Thread           -         -1     -     0.01   0.000 0:0.63 false true   
2  Reference Handler   system    10     WAITI 0.0    0.000 0:0.00 false true   
3  Finalizer           system    8      WAITI 0.0    0.000 0:0.00 false true   

Memory           used  total max  usage GC                                     
heap             44M   84M   419M       gc.copy.count       20                 
eden_space       9M    23M   115M 8.53% gc.copy.time(ms)    206                
survivor_space   0K    2944K 1478 0.00% gc.marksweepcompact 3                  
                             4K         .count                                 
tenured_gen      35M   58M   289M       gc.marksweepcompact 233                
nonheap          47M   50M   -1         .time(ms)                              
code_cache       6M    8M    240M 2.87%  

Runtime                                                                        
os.name                                 Linux                                  
os.version                              3.10.0-957.21.3.el7.x86_64  
使用2:查看线程堆栈

输入thread 1 查看线程id为1的线程堆栈

[arthas@12588]$ thread 1 
"main" Id=1 TIMED_WAITING
    at java.lang.Thread.sleep(Native Method)
    at java.lang.Thread.sleep(Thread.java:342)
    at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:386)
    at demo.MathGame.main(MathGame.java:17)
使用3:反编译线上代码

jad demo.MathGame

// demo.MathGame是全限定类名

使用4:通过watch来查看函数执行的返回值

watch demo.MathGame primeFactors returnObj

退出Arthas

quit或exit退出当前连接

使用4:通过watch来查看函数执行的返回值

watch demo.MathGame primeFactors returnObj

退出Arthas

quit或exit退出当前连接

stop完全退出arthas

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/941578.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号