1. 背景
my god , 是真的香,学习arthas 一年了,也陆陆续续运用arthas解决了一些uat、fat环境的问题,在此总结一下,我在哪些场景用到了arthas
2. 使用demo
2.1 我怀疑我的代码没部署到线上,咋弄
上jad 命令进行反编译
2.2 cpu 飚高咋排查
查看面板 dashboard -n 1, 可以看到threadId, thread threadId可以查看线程的堆栈
2.3 利用Arthas排查Spring Boot应用NoSuchMethodError
java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(Ljava/util/List;)
jad 反编译的时候就能看出来是引用的哪个jar
2.4 arthas 如何查询服务中的map中的缓存
getstatic com.xxx.Log monitorMap -x 1
getstatic com.xxx.Log monitorMap 'entrySet().iterator.{? #this.key=="dyw"}' -x 1
getstatic com.xxx.Log monitorMap 'entrySet().iterator.{? #this.key=="dyw"}' -x 1
getstatic com.xxx.Log monitorMap 'entrySet().iterator.size()' -x 1
todo: arthas如何获取一个对象占用jvm多少内存
2.5 演示arthas 连续的map该怎么使用,map里面嵌套了map
heap dump static的东西不显示, 那是因为static的东西放到元空间了
todo:如何获取元空间的内容,总结一下如何获取map中的map的表达式
2.6 演示arthas输出到异步文件该怎么显示
有一次我们的服务我getstatic以后,发现map太大了,也不好翻页,这个时候就要把结果重定向到文件
trace Test t >> test.out
这时 trace 命令会在后台执行,并且把结果输出到应用工作目录下面的test.out文件
如果没有指定重定向文件,则会把结果输出到~/logs/arthas-cache/目录下