1. #查询节点的资源使用情况
kubectl -n kjhs-yonyou top nodes
2.#查询每个服务的资源使用情况
kubectl -n kjhs-yonyou top pod
3.#做theaddump和heapdump文件
#找一个内存使用最大的服务,进入容器中做dump文件 kubectl -n kjhs-yonyou exec -it f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd sh (f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd为服务节点名称)
#进入容器之后先检查下是否有jstack和jmap命令,如果是oracle jdk就会有这两个命令;如果不存在就把jdk拷贝到容器中;
jstack -help
jmap -help
#查看对应服务的java进程
ps -ef|grep java
#做threaddump文件操作,建议做3次
jstack 1 > /home/admin/app/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-`date +%Y%m%d%H%M%S`.txt
#做heapdump文件,建议正常情况做一次,发生full gc做一次
jmap -dump:format=b,file=/home/admin/app/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-heapdump-`date +%Y%m%d%H%M%S`.hprof 1
#压缩heapdump文件
gzip f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-heapdump-20230524103142.hprof
4.#把上面做的四个文件拷贝出来(从容器中拷贝到master服务器中)
kubectl cp -n -kjhs-yonyou f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd:/home/admin/app/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-heapdump-20230524103142.hprof.gz /root/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-heapdump-20230524103142.hprof.gz
kubectl cp -n -kjhs-yonyou f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd:/home/admin/app/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-20230524102618.txt /root/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-20230524102618.txt
kubectl cp -n -kjhs-yonyou f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd:/home/admin/app/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-20230524102638.txt /root/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-20230524102638.txt
kubectl cp -n -kjhs-yonyou f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd:/home/admin/app/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-20230524102650.txt /root/f9667046-kjhs-yonyou-agla-cwy2-blue-b455b8d56-gs6hd-threaddump-20230524102650.txt
5.#对这四个文件进行分析
标签:blue,yonyou,threaddump,kjhs,f9667046,heapdump,k8s,b455b8d56,cwy2 From: https://www.cnblogs.com/zengwb/p/17427368.html