环境

因为k8s中是最基本的jre,网上说缺少tools.jar,但是补充了以后还是不行,最后还是将整个jdk给移到容器中的。

jre中执行:

/home # /opt/jre/bin/java -jar /home/arthas-bin/arthas-boot.jar 1
[INFO] arthas-boot version: 3.3.7
[INFO] arthas home: /home/arthas-bin
[INFO] Try to attach process 1
Exception in thread "main" java.lang.IllegalArgumentException: Can not find tools.jar under java home: /opt/jre1.8.0_231, please try to start arthas-boot with full path java. Such as /opt/jdk/bin/java -jar arthas-boot.jar
at com.taobao.arthas.boot.ProcessUtils.findJavaHome(ProcessUtils.java:222)
at com.taobao.arthas.boot.ProcessUtils.startArthasCore(ProcessUtils.java:233)
at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:515)

tools.jar迁移到/opt/jre/lib/

/opt/jre1.8.0_231/lib # /opt/jre/bin/java -jar /home/arthas-bin/arthas-boot.jar 1
[INFO] arthas-boot version: 3.3.7
[INFO] arthas home: /home/arthas-bin
[INFO] Try to attach process 1
java.lang.UnsatisfiedLinkError: no attach in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:342)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:250)
at com.taobao.arthas.core.Arthas.attachAgent(Arthas.java:86)
at com.taobao.arthas.core.Arthas.<init>(Arthas.java:28)
at com.taobao.arthas.core.Arthas.main(Arthas.java:124)
[ERROR] Start arthas failed, exception stack trace:
[ERROR] attach fail, targetPid: 1

最后还是将整个jdk迁移到容器中。

//k8s中进行迁移
kubectl cp arthas-bin/ test-huishi-server-7b5dd79689-tfsvz:/home -n irm-server

进入容器:

kubectl exec -ti test-huishi-server-test1-58fb7775fd-2n7bp -n irm-server -- /bin/sh

启动

/ # /home/jdk1.8.0_91/bin/java -jar /home/arthas-bin/arthas-boot.jar
[INFO] arthas-boot version: 3.3.7
[INFO] Can not find java process. Try to pass <pid> in command line.
Please select an available pid.

起动不了,查看帮助

/ # /home/jdk1.8.0_91/bin/java -jar /home/arthas-bin/arthas-boot.jar -help
[INFO] arthas-boot version: 3.3.7
Usage: arthas-boot [-h] [--target-ip <value>] [--telnet-port <value>]
[--http-port <value>] [--session-timeout <value>] [--arthas-home <value>]
[--use-version <value>] [--repo-mirror <value>] [--versions] [--use-http]
[--attach-only] [-c <value>] [-f <value>] [--height <value>] [--width
<value>] [-v] [--tunnel-server <value>] [--agent-id <value>] [--stat-url
<value>] [--select <value>] [pid] Bootstrap Arthas EXAMPLES:
java -jar arthas-boot.jar <pid>
java -jar arthas-boot.jar --target-ip 0.0.0.0
java -jar arthas-boot.jar --telnet-port 9999 --http-port -1
java -jar arthas-boot.jar --tunnel-server 'ws://192.168.10.11:7777/ws'
java -jar arthas-boot.jar --tunnel-server 'ws://192.168.10.11:7777/ws'
--agent-id bvDOe8XbTM2pQWjF4cfw
java -jar arthas-boot.jar --stat-url 'http://192.168.10.11:8080/api/stat'
java -jar arthas-boot.jar -c 'sysprop; thread' <pid>
java -jar arthas-boot.jar -f batch.as <pid>
java -jar arthas-boot.jar --use-version 3.3.7
java -jar arthas-boot.jar --versions
java -jar arthas-boot.jar --select arthas-demo
java -jar arthas-boot.jar --session-timeout 3600
java -jar arthas-boot.jar --attach-only
java -jar arthas-boot.jar --repo-mirror aliyun --use-http
WIKI:
https://alibaba.github.io/arthas

使用pid进行启动

/ # ps -ef |grep huishi
1 root 8:25 java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -Xms256M -Duser.timezone=GMT+08 -Dfile.encoding=UTF-8 -javaagent:/data/jacocoagent.jar=includes=*,output=file,append=true,destfile=/data/log/huishi-server/jacoco.exec -jar /home/huishi-server.jar / # /home/jdk1.8.0_91/bin/java -jar /home/arthas-bin/arthas-boot.jar 1
[INFO] arthas-boot version: 3.3.7
[INFO] arthas home: /home/arthas-bin
[INFO] Try to attach process 1
[INFO] Attach process 1 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.7
pid 1
time 2020-08-06 15:48:34

调试

仪表盘

[arthas@1]$ dashboard
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON 207 Timer-for-arthas-dashboard-d85134f6-3f4c-4e5b-ae6f-6 system 5 RUNNABLE 67 0:0 false true
76 DubboResponseTimeoutScanTimer main 5 TIMED_WAITING 21 0:14 false true
40 Hashed wheel timer #1 main 5 TIMED_WAITING 11 0:5 false false
24 Abandoned connection cleanup thread main 5 TIMED_WAITING 0 0:0 false true
161 Attach Listener system 9 RUNNABLE 0 0:0 false true
22 ContainerBackgroundProcessor[StandardEngine[Tomcat]] main 5 TIMED_WAITING 0 0:0 false true
50 Curator-ConnectionStateManager-0 main 5 WAITING 0 0:0 false true
53 Curator-Framework-0 main 5 WAITING 0 0:0 false true
75 DestroyJavaVM main 5 RUNNABLE 0 3:16 false false
25 Druid-ConnectionPool-Create-1936208710 main 5 WAITING 0 0:0 false true
26 Druid-ConnectionPool-Destroy-1936208710 main 5 TIMED_WAITING 0 0:0 false true
43 DubboClientReconnectTimer-thread-1 main 5 TIMED_WAITING 0 0:0 false true
46 DubboClientReconnectTimer-thread-2 main 5 WAITING 0 0:0 false true
33 DubboRegistryFailedRetryTimer-thread-1 main 5 TIMED_WAITING 0 0:0 false true
37 DubboSaveRegistryCache-thread-1 main 5 WAITING 0 0:0 false true
3 Finalizer system 8 WAITING 0 0:0 false true
89 Java2D Disposer system 10 WAITING 0 0:0 false true
41 New I/O boss #3 main 5 RUNNABLE 0 0:1 false true
38 New I/O worker #1 main 5 RUNNABLE 0 0:1 false true
39 New I/O worker #2 main 5 RUNNABLE 0 0:1 false true
59 NioBlockingSelector.BlockPoller-1 main 5 RUNNABLE 0 0:0 false true
Memory used total max usage GC heap 389M 510M 1979M 19.68% gc.copy.count 838 eden_space 104M 140M 546M 19.10% gc.copy.time(ms) 14061
survivor_space 3M 17M 68M 4.48% gc.marksweepcompact.count 6 tenured_gen 282M 351M 1365M 20.67% gc.marksweepcompact.time(ms) 2640
nonheap 267M 278M -1 96.01%
code_cache 84M 84M 240M 35.03%
metaspace 166M 175M -1 94.89%
compressed_class_space 16M 18M 1024M 1.64%
direct 211K 211K - 100.00%
mapped 0K 0K - NaN%
Runtime os.name Linux
os.version 3.10.0-693.el7.x86_64
java.version 1.8.0_231
java.home /opt/jre1.8.0_231
systemload.average 0.40
processors 1
uptime 8607s

查看JVM信息

参考:

Arthas排查Kubernetes中的应用频繁挂掉重启问题

Kubernetes 使用arthas进行调试的更多相关文章

  1. Kubernetes环境下的各种调试方法

    作者:Jack47 转载请保留作者和原文出处 欢迎关注我的微信公众账号程序员杰克,两边的文章会同步,也可以添加我的RSS订阅源. 本文介绍在Kubernetes环境下的调试方法,希望对读者有用.如果关 ...

  2. 《k8s-1.13版本源码分析》-源码调试

    源码分析系列文章已经开源到github,地址如下: github:https://github.com/farmer-hutao/k8s-source-code-analysis gitbook:ht ...

  3. Arthas的基础学习

    下载与安装 wget https://alibaba.github.io/arthas/arthas-boot.jar java -jar arthas-boot.jar 启动 查看启动的帮助信息: ...

  4. Kubernetes基础:查看状态、管理服务

    目标 了解Kubernetes Pod 了解Kubernetes Node 学习如何调试部署问题 了解如何通过Service暴露应用 Kubernetes Pods 在Kubernetes中创建一个D ...

  5. 排障利器之远程调试与监控 --jmx & remote debug

    监控和调试功能是应用必备的属性之一,其手段也是多种多样. 一般地,我们可以通过:线上日志, zabbix, grafana, cat 等待系统做一问题留底,有问题及时报警,从而达到监控效果. 而对于应 ...

  6. 以对话的形式管理你的Kubernetes集群

    BotKube BotKube 是一个用于监控和调试 Kubernetes 集群的消息传递工具. BotKube 可以与多个消息传递平台(如 Slack.Mattermost 或 Microsoft ...

  7. 使用 Nocalhost 开发 Kubernetes 中的 APISIX Ingress Controller

    本文作者:黄鑫鑫 - Nocalhost 项目核心开发者 腾讯云 CODING DevOps 研发工程师.硕士毕业于中山大学数据科学与计算机学院,曾负责过平安云主机及国家超算中心容器云平台等相关业务, ...

  8. 线上应用调试利器 --Arthas

    在之前的文章中,我介绍了使用 Btrace 工具进行线上代码的debug (https://www.cnblogs.com/yougewe/p/10180483.html),其大致原理就是通过字节码注 ...

  9. Kubernetes用户指南(四)--应用检查和调试

    一.调试 当你的应用开始运行,那么DEBUG是不可避免的问题. 早些时候,我们在描述的是如何通过kubectl get pods来获得Pod的简单状态信息. 但是现在,这里有更多的方式来获得关于你的应 ...

随机推荐

  1. 05 drf源码剖析之认证

    05 drf源码剖析之认证 目录 05 drf源码剖析之认证 1. 认证简述 2. 认证的使用 3. 源码剖析 4. 总结 1. 认证简述 当我们通过Web浏览器与API进行交互时,我们可以登录,然后 ...

  2. How to install nginx in Ubuntu

    The steps for installing the nginx on Ubuntu below. 1.install the packages first. apt-get install gc ...

  3. 解决redis秒杀超卖的问题

    我们再使用redis做秒杀程序的时候,解决超卖问题,是重中之重.以下是一个思路. 用上述思路去做的话,我们再用户点击秒杀的时候,只需要检测,kucun_count中是否能pop出数据,如果能pop出来 ...

  4. Flutter 快捷开发 Mac Android Studio 篇

    老孟导读:此快捷方式适用于Mac下的 Android Studio .Windows 下的快捷方式请参考这篇文章:https://juejin.im/post/5efe71365188252e7d7f ...

  5. Python+selenium+unittest+HTMLTestReportCN单元测试框架分享

    分享一个比较基础的,系统性的知识点.Python+selenium+unittest+HTMLTestReportCN单元测试框架分享 Unittest简介 unittest是Python语言的单元测 ...

  6. Ubuntu14.04 安装VMware tools

    Ubuntu14.04 安装VMware tools 方法一: 1. 在VMware 11(个人的测试环境为vm 11版本)下安装Ubuntu镜像:ubuntu-14.04.1-desktop-amd ...

  7. OSCP Learning Notes - File Transfers(1)

    File transfer type: 1. HTTP Transfer files through the website. 2.wget wget http://10.0.0.109/exploi ...

  8. Spring Boot 2.x基础教程:使用EhCache缓存集群

    上一篇我们介绍了在Spring Boot中整合EhCache的方法.既然用了ehcache,我们自然要说说它的一些高级功能,不然我们用默认的ConcurrentHashMap就好了.本篇不具体介绍Eh ...

  9. 牛客练习赛66A题解

    思路 令 \(sq=\sqrt x\) ,则答案必然在 $ sq^2$ 和 $ (sq+1)^2 $ 之间,两者比较一下谁离 \(x\) 最近,就是答案了. 代码 #include <bits/ ...

  10. Java Properties集合基础解析

    Java Properties集合基础解析 本期学习的properties集合是项目中经常用到的操作 什么是Properties集合? java.util.Properties集合继承于Hashtab ...