暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Arthas在线分析诊断工具使用总结

ItTalk 2019-10-10
694

简介

在线分析诊断工具一直是辅助定位解决线上问题的强有力的帮手。最开始使用BTrace,直到发现了greys(https://github.com/oldmanpushcart/greys-anatomy)(是淘宝同学开发的),但今天我介绍的是阿里的Arthas(阿尔萨斯),它是基于greys,功能上有所增强。特别值得一提的是,Arthas可在docker或k8s中使用。

安装

有两种安装使用方式
  • 直接能通过java运行arthar-boot.jar包(官方推荐,可能适用于全平台吧)

  1. wget https://alibaba.github.io/arthas/arthas-boot.jar

  2. java -jar arthas-boot.jar

复制
  • 通过as.sh shell脚本运行(个人推荐,因为习惯greys的使用方式了)

  1. 1,下载

  2. curl -L https://alibaba.github.io/arthas/install.sh | sh

  3. 2,将as.sh拷贝到$PATH

  4. cp as.sh /usr/local/bin

  5. 3,测试

  6. as.sh -h

  7. Arthas script version: 3.1.1

  8. [INFO] JAVA_HOME: /usr/local/jdk1.8.0_144

  9. Usage:

  10. /usr/local/bin/as.sh [-h] [--target-ip <value>] [--telnet-port <value>]

  11. [--http-port <value>] [--session-timeout <value>] [--arthas-home <value>]

  12. [--use-version <value>] [--repo-mirror <value>] [--versions] [--use-http]

  13. [--attach-only] [-c <value>] [-f <value>] [-v] [pid]

复制

常用命令行参数解释

  1. -h --help 查看帮助

  2. --target-ip 打开远程连接功能时,指定的ip地址,默认为127.0.0.10.0.0.0表示监听当前节点上所有的ip

  3. --telnet-port 打开远程连接功能时,指定监听的端口,默认为3658

  4. --http-port 启用http连接的端口,默认为8563,设置为-1可关闭http连接,非常实用,设置后,可通过一个web界面连接进来执行诊断命令

  5. --session-timeout 设置连续不操作的超时时间,默认是30分钟

  6. --attach-only 只启动服务端,不进行连接

  7. -c,--command 指定执行的诊断命令,多个命令使用;分隔

复制

常见使用案例

  • 直接输入as.sh或java -jar arthas-boot.jar,会先列举出系统中的java进程,可通过序号选择attach到指定的进程:

  1. as.sh

  2. Arthas script version: 3.1.1

  3. [INFO] JAVA_HOME: /usr/local/jdk1.8.0_144

  4. Found existing java process, please choose one and hit RETURN.

  5. * [1]: 26529 com.yunmicloud.GiApplicationLauncher

  6. [2]: 18529 com.yunmicloud.Application

  7. [3]: 1059 com.yunmicloud.ApplicationLauncher

  8. [4]: 8102 com.yunmicloud.LicaiAppLauncher

  9. [5]: 29958 com.yunmicloud.ApplicationLauncher

  10. [6]: 5577 com.qingbee.InsuranceRecordLauncher

  11. [7]: 16333 com.qingbee.InsuranceProductLauncher

  12. [8]: 9965 com.yunmicloud.gw.App

  13. [9]: 20334 com.yunmicloud.LoanLauncher

  14. [10]: 16558 com.yunmicloud.loan.schedule.Application

  15. [11]: 2736 com.yunmicloud.WxAppLauncher

  16. [12]: 5394 com.qingbee.ScheduleLauncher

  17. [13]: 20723 com.yunmicloud.CancelInsureLauncher

  18. [14]: 17528 com.qingbee.OtherLauncher

  19. [15]: 28318 com.yunmicloud.ExternalServiceLauncher

  20. Arthas home: /home/yunmi/.arthas/lib/3.1.1/arthas

  21. Calculating attach execution time...

  22. Attaching to 26529 using version /home/yunmi/.arthas/lib/3.1.1/arthas...

  23. real 0m0.789s

  24. user 0m0.526s

  25. sys 0m0.067s

  26. Attach success.

  27. telnet connecting to arthas server... current timestamp is 1566035524

  28. Trying 127.0.0.1...

  29. Connected to 127.0.0.1.

  30. Escape character is '^]'.

  31. ,---. ,------. ,--------.,--. ,--. ,---. ,---.

  32. / O \ | .--. ''--. .--'| '--' | O \ ' .-'

  33. | .-. || '--'.' | | | .--. || .-. |`. `-.

  34. | | | || |\ \ | | | | | || | | |.-' |

  35. `--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'

  36. wiki https://alibaba.github.io/arthas

  37. tutorials https://alibaba.github.io/arthas/arthas-tutorials

  38. version 3.1.1

  39. pid 26529

  40. time 2019-08-17 17:52:04

  41. $

复制
  • attach到某一个进程以后,通过help查看所有支持的命令,通过help command,查看其它命令的详细用法

  1. $ help

  2. NAME DESCRIPTION

  3. help Display Arthas Help

  4. keymap Display all the available keymap for the specified connection.

  5. sc Search all the classes loaded by JVM

  6. sm Search the method of classes loaded by JVM

  7. classloader Show classloader info

  8. jad Decompile class

  9. getstatic Show the static field of a class

  10. monitor Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.

  11. stack Display the stack trace for the specified class and method

  12. thread Display thread info, thread stack

  13. trace Trace the execution time of specified method invocation.

  14. watch Display the input/output parameter, return object, and thrown exception of specified method invocation

  15. tt Time Tunnel

  16. jvm Display the target JVM information

  17. ognl Execute ognl expression.

  18. mc Memory compiler, compiles java files into bytecode and class files in memory.

  19. redefine Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)

  20. dashboard Overview of target jvm's thread, memory, gc, vm, tomcat info.

  21. dump Dump class byte array from JVM

  22. options View and change various Arthas options

  23. cls Clear the screen

  24. reset Reset all the enhanced classes

  25. version Display Arthas version

  26. shutdown Shutdown Arthas server and exit the console

  27. session Display current session information

  28. sysprop Display, and change the system properties.

  29. sysenv Display the system env.

  30. history Display command history

  31. cat Concatenate and print files

  32. pwd Return working directory name

  33. mbean Display the mbean information

  34. $ help thread

  35. USAGE:

  36. thread [-h] [-b] [-i <value>] [-n <value>] [id]

  37. SUMMARY:

  38. Display thread info, thread stack

  39. EXAMPLES:

  40. thread

  41. thread 51

  42. thread -n -1

  43. thread -n 5

  44. thread -b

  45. thread -i 2000

  46. WIKI:

  47. https://alibaba.github.io/arthas/thread

  48. OPTIONS:

  49. -h, --help this help

  50. -b, --include-blocking-thread Find the thread who is holding a lock that blocks the most number of threads.

  51. -i, --sample-interval <value> Specify the sampling interval (in ms) when calculating cpu usage.

  52. -n, --top-n-threads <value> The number of thread(s) to show, ordered by cpu utilization, -1 to show all.

  53. <id> Show thread stack

复制
  • dashboard命令可以实时查看目标进程的thread, memory, gc, vm信息,支持-i 指定刷新时间,默认5s,-n 指定执行的次数

  1. $ dashboard -i 1000 -n 5

  2. ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON

  3. 8429 Timer-for-arthas-dashboard-1c12564d- system 10 RUNNABLE 51 0:0 false true

  4. 100 dubbo-future-timeout-thread-1 main 5 TIMED_WAITI 15 6:37 false true

  5. 52 localQuartzScheduler_Worker-10 main 5 TIMED_WAITI 3 0:16 false false

  6. Memory used total max usage GC

  7. heap 84M 128M 128M 66.02% gc.g1_young_generation.count 250

  8. g1_eden_space 14M 23M -1 60.87% gc.g1_young_generation.time(ms) 2968

  9. g1_survivor_space 4M 4M -1 100.00% gc.g1_old_generation.count 0

  10. g1_old_gen 66M 101M 128M 51.95% gc.g1_old_generation.time(ms) 0

  11. nonheap 96M 98M -1 97.87%

  12. Runtime

  13. os.name Linux

  14. os.version 2.6.32-696.23.1.el6.x86_64

  15. java.version 1.8.0_144

  16. java.home /usr/local/jdk1.8.0_144/jre

  17. systemload.average 0.04

复制
  • jvm命令,可查看attach到的目标JVM的信息。如虚拟机参数,classpath等。

  1. [arthas@2047]$ jvm

  2. RUNTIME

  3. ---------------------------------------------------------------------------------------------------------------------------------------------------

  4. MACHINE-NAME 2047@api112

  5. JVM-START-TIME 2019-09-28 06:08:31

  6. MANAGEMENT-SPEC-VERSION 1.2

  7. SPEC-NAME Java Virtual Machine Specification

  8. SPEC-VENDOR Oracle Corporation

  9. SPEC-VERSION 1.8

  10. VM-NAME Java HotSpot(TM) 64-Bit Server VM

  11. VM-VENDOR Oracle Corporation

  12. VM-VERSION 25.144-b01

  13. INPUT-ARGUMENTS -DtaskName=launcher/otherLauncher

  14. -Xmx512m

  15. -Xms512m

  16. -XX:NewRatio=4

  17. -XX:+UseG1GC

  18. -Xss512k

  19. -Ddubbo.registry.file=other.properties

  20. -Dsun.net.inetaddr.ttl=5

  21. -Djava.awt.headless=true

  22. -Djava.net.preferIPv4Stack=true

  23. -XX:HeapDumpPath=/data/logs/other/heapDump.hprof

  24. -XX:-UseGCOverheadLimit

  25. -XX:+PrintClassHistogram

  26. -XX:+PrintGCDetails

  27. -XX:+PrintGCDateStamps

  28. -XX:+PrintGCTimeStamps

  29. -XX:+PrintHeapAtGC

  30. -XX:ErrorFile=/data/logs/other/hs_err.log

  31. -Dlog.path=/data/logs/other

  32. ...

复制
  • sc命令,可用于查看指定的类加载情况,使用-E选项支持正则表达式查询,使用-d选项可列出详细的类加载明细,如类加载器,对应的jar包路径等,可方便排查jar包冲突引起的问题。

  1. $ sc -d org.springframework.context.support.ClassPathXmlApplicationContext

  2. class-info org.springframework.context.support.ClassPathXmlApplicationContext

  3. code-source /data/yunmi/schedule_package/schedule_20190824160151/lib/spring-context-4.3.17.RELEASE.jar

  4. name org.springframework.context.support.ClassPathXmlApplicationContext

  5. isInterface false

  6. isAnnotation false

  7. isEnum false

  8. isAnonymousClass false

  9. isArray false

  10. isLocalClass false

  11. isMemberClass false

  12. isPrimitive false

  13. isSynthetic false

  14. simple-name ClassPathXmlApplicationContext

  15. modifier public

  16. annotation

  17. interfaces

  18. super-class +-org.springframework.context.support.AbstractXmlApplicationContext

  19. +-org.springframework.context.support.AbstractRefreshableConfigApplicationContext

  20. +-org.springframework.context.support.AbstractRefreshableApplicationContext

  21. +-org.springframework.context.support.AbstractApplicationContext

  22. +-org.springframework.core.io.DefaultResourceLoader

  23. +-java.lang.Object

  24. class-loader +-sun.misc.Launcher$AppClassLoader@4c873330

  25. +-sun.misc.Launcher$ExtClassLoader@6bc248ed

  26. classLoaderHash 4c873330

  27. Affect(row-cnt:1) cost in 6 ms

复制
  • sm命令,用于查看加载到JVM中指定类的方法,使用方法为:sm 类名 方法名,如果不写,则列出所有的方法,同样支持-d,-E等参数

  1. $ sm -d java.lang.String toUpperCase

  2. declaring-class java.lang.String

  3. method-name toUpperCase

  4. modifier public

  5. annotation

  6. parameters

  7. return java.lang.String

  8. exceptions

  9. declaring-class java.lang.String

  10. method-name toUpperCase

  11. modifier public

  12. annotation

  13. parameters java.util.Locale

  14. return java.lang.String

  15. exceptions

  16. Affect(row-cnt:2) cost in 7 ms.

复制
  • jad命令,用于反编译指定的类,或指定类的方法。可在线分析,诊断调用不符合业务逻辑的代码。具体用法为:jad 类名 [方法名] 同样也支持-E选项。

  1. $ jad java.lang.String toUpperCase

  2. ClassLoader:

  3. Location:

  4. public String toUpperCase() {

  5. return this.toUpperCase(Locale.getDefault());

  6. }

  7. public String toUpperCase(Locale locale) {

  8. int n;

  9. int n2;

  10. int n3;

  11. int n4;

  12. block14 : {

  13. int n5;

  14. if (locale == null) {

  15. throw new NullPointerException();

  16. }

  17. n4 = this.value.length;

  18. for (n3 = 0; n3 < n4; n3 += n5) {

  19. n2 = this.value[n3];

  20. if (n2 >= 55296 && n2 <= 56319) {

  21. n2 = this.codePointAt(n3);

  22. n5 = Character.charCount(n2);

  23. } else {

  24. n5 = 1;

  25. }

  26. int n6 = Character.toUpperCaseEx(n2);

  27. if (n6 != -1 && n2 == n6) {

  28. continue;

  29. }

  30. break block14;

  31. }

  32. return this;

  33. }

  34. n2 = 0;

  35. char[] arrc = new char[n4];

  36. System.arraycopy(this.value, 0, arrc, 0, n3);

  37. String string = locale.getLanguage();

  38. boolean bl = string == "tr" || string == "az" || string == "lt";

  39. for (int i = n3; i < n4; i += n) {

  40. int n7 = this.value[i];

  41. if ((char)n7 >= '\ud800' && (char)n7 <= '\udbff') {

  42. n7 = this.codePointAt(i);

  43. n = Character.charCount(n7);

  44. } else {

  45. n = 1;

  46. }

  47. int n8 = bl ? ConditionalSpecialCasing.toUpperCaseEx(this, i, locale) : Character.toUpperCaseEx(n7);

  48. if (n8 == -1 || n8 >= 65536) {

  49. char[] arrc2;

  50. if (n8 == -1) {

  51. arrc2 = bl ? ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale) : Character.toUpperCaseCharArray(n7);

  52. } else {

  53. if (n == 2) {

  54. n2 += Character.toChars(n8, arrc, i + n2) - n;

  55. continue;

  56. }

  57. arrc2 = Character.toChars(n8);

  58. }

  59. int n9 = arrc2.length;

  60. if (n9 > n) {

  61. char[] arrc3 = new char[arrc.length + n9 - n];

  62. System.arraycopy(arrc, 0, arrc3, 0, i + n2);

  63. arrc = arrc3;

  64. }

  65. for (int j = 0; j < n9; ++j) {

  66. arrc[i + n2 + j] = arrc2[j];

  67. }

  68. n2 += n9 - n;

  69. continue;

  70. }

  71. arrc[i + n2] = (char)n8;

  72. }

  73. return new String(arrc, 0, n4 + n2);

  74. }

  75. Affect(row-cnt:2) cost in 1112 ms.

复制
  • getstatic命令,用于查看某个类的静态属性,具体用法:getstatic 类名 指定的属性名称,如果为*,则可查看该类所有的静态属性

  1. $ getstatic java.lang.String *

  2. field: serialVersionUID

  3. @Long[-6849794470754667710]

  4. field: serialPersistentFields

  5. @ObjectStreamField[][isEmpty=true;size=0]

  6. field: CASE_INSENSITIVE_ORDER

  7. @CaseInsensitiveComparator[

  8. serialVersionUID=@Long[8575799808933029326],

  9. ]

  10. Affect(row-cnt:3) cost in 13 ms.

复制
  • monitor命令,用于监控指定类,方法的统计结果。包括调用次数,成功次数,失败次数,平均响应时间,失败比率等。可通过-c指定统计周期,默认是60s。

  1. $ monitor com.yunmicloud.licai.spi.MonitorRestServiceSPI check

  2. Press Q or Ctrl+C to abort.

  3. Affect(class-cnt:8 , method-cnt:4) cost in 199 ms.

  4. timestamp class method total success fail avg-rt(ms) fail-rate

  5. -------------------------------------------------------------------------------------------------------------------

  6. 2019-09-16 18:09:42 org.apache.dubbo.common.bytecode.proxy3 check 17 17 0 1.40 0.00%

  7. timestamp class method total success fail avg-rt(ms) fail-rate

  8. -------------------------------------------------------------------------------------------------------------------

  9. 2019-09-16 18:10:42 org.apache.dubbo.common.bytecode.proxy3 check 15 15 0 0.34 0.00%

复制
  • stack命令,可实时打印出方法调用的堆栈。具体用法:stack 类名 方法名 [条件] 。如果加入了条件,则打印出满足条件的堆栈信息。

  1. [arthas@14149]$ stack com.yunmicloud.licai.spi.MonitorRestServiceSPI check

  2. Press Q or Ctrl+C to abort.

  3. Affect(class-cnt:8 , method-cnt:4) cost in 258 ms.

  4. ts=2019-09-16 18:15:38;thread_name=http-nio-20891-exec-4;id=3f;is_daemon=true;priority=5;TCCL=org.apache.catalina.loader.ParallelWebappClassLoader@5fc8abca

  5. @sun.reflect.GeneratedMethodAccessor152.invoke()

  6. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

  7. ...

复制
  • thread命令,用于查看指定线程信息,或按cpu使用率的top n线程信息。具体用法:thread [-b] [-i] [-n ] [id],-i参数,可指定一个采样的间隔,并输出汇总信息。-n参数,可设定按cpu使用率的top n个线程信息。

  1. [arthas@14149]$ thread -n 5

  2. "cat-netty-tcp-data-sender" Id=21 cpuUsage=58% TIMED_WAITING

  3. at java.lang.Thread.sleep(Native Method)

  4. at com.dianping.cat.message.io.TcpSocketSender.processMessage(TcpSocketSender.java:170)

  5. at com.dianping.cat.message.io.TcpSocketSender.run(TcpSocketSender.java:219)

  6. at java.lang.Thread.run(Thread.java:748)

  7. at com.dianping.cat.util.Threads$RunnableThread.run(Threads.java:300)

  8. ...

复制
  • trace命令,用于跟踪某个指定方法调用栈的执行时间。具体用法:trace 类名 方法名 [条件] 。

  1. [arthas@14149]$ trace com.yunmicloud.licai.spi.MonitorRestServiceSPI check

  2. Press Q or Ctrl+C to abort.

  3. Affect(class-cnt:8 , method-cnt:4) cost in 335 ms.

  4. `---ts=2019-09-17 12:00:15;thread_name=http-nio-20891-exec-5;id=40;is_daemon=true;priority=5;TCCL=org.apache.catalina.loader.ParallelWebappClassLoader@5fc8abca

  5. `---[0.777878ms] org.apache.dubbo.common.bytecode.proxy3:check()

  6. `---[0.5891ms] java.lang.reflect.InvocationHandler:invoke() #0

复制
  • watch命令,用于动态监测某个指定类的方法,调用的请求参数值,返回值,异常信息。具体用法:watch 类名 方法名 值(params target, returnObj,throwExp) [条件]

  1. #重要选项解释

  2. -b 调用之前打印观测的值

  3. -f 调用完成之后打印观测的值,不加参数时,默认都是调用完成之后打印

  4. -x 展开对象的层级,默认为1,有时候有对象嵌套时,需要设置对应的层级

  5. -e 调用之后出现异常打印观测的值

  6. -s 调用成功之后打印观测的值

  7. #使用示例:

  8. 1)查看某个方法调用结束后的返回值,及参数

  9. [arthas@2047]$ watch com.qingbee.system.service.impl.OtherMonitorRestServiceImpl check '{params,returnObj}'

  10. Press Q or Ctrl+C to abort.

  11. Affect(class-cnt:1 , method-cnt:1) cost in 83 ms.

  12. ts=2019-10-10 11:49:54; [cost=0.084521ms] result=@ArrayList[

  13. @Object[][isEmpty=true;size=0],

  14. @String[other],

  15. ]

  16. ts=2019-10-10 11:50:04; [cost=0.04218ms] result=@ArrayList[

  17. @Object[][isEmpty=true;size=0],

  18. @String[other],

  19. ]

  20. 2)满足条件后输出

  21. [arthas@2047]$ watch com.qingbee.system.service.impl.OtherMonitorRestServiceImpl check returnObj 'returnObj.equals("other")'

  22. Press Q or Ctrl+C to abort.

  23. Affect(class-cnt:1 , method-cnt:1) cost in 95 ms.

  24. ts=2019-10-10 11:53:33; [cost=0.140196ms] result=@String[other]

  25. ts=2019-10-10 11:53:34; [cost=0.03513ms] result=@String[other]

复制
  • tt命令,可以记录指定方法每次调用的参数和返回值,与watch命令互补。可快速分析一个方法的调用参数,返回值,异常信息。

  1. #重要选项解释

  2. -t 记录方法调用的明细(返回值,是否执行成功等信息),然后可通过-l选项查看

  3. -l 查看通过-t参数记录方法调用的明细

  4. -i 显示指定记录的调用详情(会显示返回值)

  5. -x 展开返回值对象的明细(与watch的-x参数一样)

  6. -d/--delete-all 删除指定或全部的记录

  7. -i -p 重新调用指定的record记录一次,注意:ThreadLocal的数据会丢失

  8. #使用示例:

  9. [arthas@2047]$ tt -t -x 2 com.qingbee.system.service.impl.OtherMonitorRestServiceImpl check

  10. Press Q or Ctrl+C to abort.

  11. Affect(class-cnt:1 , method-cnt:1) cost in 175 ms.

  12. INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD

  13. ---------------------------------------------------------------------------------------------------------------------------------------------------

  14. 1009 2019-10-10 13:38:33 0.100924 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  15. 1010 2019-10-10 13:38:34 0.052025 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  16. 1011 2019-10-10 13:38:35 0.037695 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  17. 1012 2019-10-10 13:38:37 0.072666 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  18. 1013 2019-10-10 13:38:37 0.038405 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  19. 1014 2019-10-10 13:38:37 0.035231 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  20. 2)查看记录:

  21. [arthas@2047]$ tt -l

  22. INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD

  23. ---------------------------------------------------------------------------------------------------------------------------------------------------

  24. 1008 2019-10-10 13:38:11 0.217115 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  25. 1009 2019-10-10 13:38:33 0.100924 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  26. 1010 2019-10-10 13:38:34 0.052025 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  27. 1011 2019-10-10 13:38:35 0.037695 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  28. 1012 2019-10-10 13:38:37 0.072666 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  29. 1013 2019-10-10 13:38:37 0.038405 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  30. 1014 2019-10-10 13:38:37 0.035231 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  31. 1015 2019-10-10 13:38:38 0.037593 true false 0x11cd6d1e OtherMonitorRestServiceImpl check

  32. 3)查看指定记录的详情:

  33. [arthas@2047]$ tt -i 1008

  34. INDEX 1008

  35. GMT-CREATE 2019-10-10 13:38:11

  36. COST(ms) 0.217115

  37. OBJECT 0x11cd6d1e

  38. CLASS com.qingbee.system.service.impl.OtherMonitorRestServiceImpl

  39. METHOD check

  40. IS-RETURN true

  41. IS-EXCEPTION false

  42. RETURN-OBJ @String[other]

  43. Affect(row-cnt:1) cost in 1 ms.

  44. 4)重新执行指定的记录:

  45. [arthas@2047]$ tt -i 1008 -p

  46. RE-INDEX 1008

  47. GMT-REPLAY 2019-10-10 14:11:20

  48. OBJECT 0x11cd6d1e

  49. CLASS com.qingbee.system.service.impl.OtherMonitorRestServiceImpl

  50. METHOD check

  51. IS-RETURN true

  52. IS-EXCEPTION false

  53. COST(ms) 0.282964

  54. RETURN-OBJ @String[other]

  55. Time fragment[1008] successfully replayed 1 times.

复制
  • 在k8s中使用

  1. # 1,将arthas做到基础镜像中,后续可进入容器,直接进行诊断(推荐)

  2. FROM jdk版本

  3. # copy arthas

  4. COPY --from=hengyunabc/arthas:latest /opt/arthas /opt/arthas

  5. #2,直接使用:

  6. kubectl exec -it ${pod} --container ${containerId} -- /bin/bash -c "wget https://alibaba.github.io/arthas/arthas-boot.jar && java -jar arthas-boot.jar"

复制

总结

Arthas的功能非常完善,熟练掌握后对后续排查线上问题会游刃有余。如有使用中的一些常见问题,可在github提出。https://github.com/alibaba/arthas/issues


文章转载自ItTalk,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论