线上故障排查神器Arthas

线上故障排查神器Arthas

一次线上突发故障,接口响应超时,一顿操作猛如虎,记录一下。

K8S环境下,进入容器:

kubectl exec -it <podName> -n <命名空间> sh

查看容器内的目录文件: 

ls

下载arthas

curl -O https://arthas.aliyun.com/arthas-boot.jar

启动arthas

java -jar arthas-boot.jar

启动后显示如下:

* [1]: 11 com.xxxx.xxxx.xxxx.xxxx

1  选中监听的程序

监控要观察的方法,设置不跳过JDK方法:

trace --skipJDKMethod false 名 方法名

监控耗时大于200毫秒的请求:

trace --skipJDKMethod false 类名 方法名 '#cost > 200'

监控完成后,记得关闭 arthas 哦。

查询 arthas 的进程 : ps -ef | grep arthas

杀死进程 :kill -9 <进程PID>

原文地址:https://www.cnblogs.com/itbac/p/14380240.html