arthas-通過本地tar包啓動arthas

操作步驟

  1. 上傳arthas工具包

    rz -bey
    
  2. 解壓arthas包

    tar -zxvf arthas3.5.3.tar
    
  3. 進入 arthas-bin目錄

    cd arthas-bin/
    
  4. 啓動arthas

    [work(leiting04)@tjtx167-79-50 arthas-bin]$ ./as.sh
    Arthas script version: 3.5.3
    [INFO] JAVA_HOME: /opt/soft/jdk/jdk1.8.0_231
    Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
    * [1]: 1321 com.bj58.spat.scf.server.bootstrap.Main
      [2]: 1021 lib/magici-agent-1.0-SNAPSHOT.jar
    
    
  5. 選擇需要調試的進程

    1
    Arthas home: /home/work/arthas-bin
    Calculating attach execution time...
    Attaching to 1321 using version /home/work/arthas-bin...
    
    real	0m3.229s
    user	0m0.270s
    sys	0m0.047s
    Attach success.
    telnet connecting to arthas server... current timestamp is 1640051602
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
      ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
     /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
    |  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
    |  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
    `--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'
    
    
    wiki       https://arthas.aliyun.com/doc
    tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
    version    3.5.3
    main_class
    pid        1321
    time       2021-12-21 09:53:21
    
    [arthas@1321]$
    
  6. 查看命令

    [arthas@1321]$ help
     NAME         DESCRIPTION
     help         Display Arthas Help
     auth         Authenticates the current session
     keymap       Display all the available keymap for the specified connection.
     sc           Search all the classes loaded by JVM
     sm           Search the method of classes loaded by JVM
     classloader  Show classloader info
     jad          Decompile class
     getstatic    Show the static field of a class
     monitor      Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.
     stack        Display the stack trace for the specified class and method
     thread       Display thread info, thread stack
     trace        Trace the execution time of specified method invocation.
     watch        Display the input/output parameter, return object, and thrown exception of specified method invocation
     tt           Time Tunnel
     jvm          Display the target JVM information
     perfcounter  Display the perf counter information.
     ognl         Execute ognl expression.
     mc           Memory compiler, compiles java files into bytecode and class files in memory.
     redefine     Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)
     retransform  Retransform classes. @see Instrumentation#retransformClasses(Class...)
     dashboard    Overview of target jvm's thread, memory, gc, vm, tomcat info.
     dump         Dump class byte array from JVM
     heapdump     Heap dump
     options      View and change various Arthas options
     cls          Clear the screen
     reset        Reset all the enhanced classes
     version      Display Arthas version
     session      Display current session information
     sysprop      Display, and change the system properties.
     sysenv       Display the system env.
     vmoption     Display, and update the vm diagnostic options.
     logger       Print logger info, and update the logger level
     history      Display command history
     cat          Concatenate and print files
     base64       Encode and decode using Base64 representation
     echo         write arguments to the standard output
     pwd          Return working directory name
     mbean        Display the mbean information
     grep         grep command for pipes.
     tee          tee command for pipes.
     profiler     Async Profiler. https://github.com/jvm-profiling-tools/async-profiler
     vmtool       jvm tool
     stop         Stop/Shutdown Arthas server and exit the console.
    
  7. 退出

    [arthas@1321]$ stop
    Resetting all enhanced classes ...
    Affect(class count: 0 , method count: 0) cost in 1 ms, listenerId: 0
    Arthas Server is going to shutdown...
    [arthas@1321]$ session (d43cf81c-f1ee-4d79-a373-28c3e47188a6) is closed because server is going to shutdown.
    Connection closed by foreign host.
    [work(leiting04)@tjtx167-79-50 arthas-bin]$
    

小技巧

  1. arthas的默認端口是3658,假設arthas進程已經存在,需要重新進入命令端,可以使用telnet命令
[work(leiting04)@tjtx167-79-50 ~]$ telnet 127.0.0.1 3658
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'


wiki       https://arthas.aliyun.com/doc
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
version    3.5.3
main_class
pid        1321
time       2021-12-21 10:43:46

[arthas@1321]$
  1. 默認情況下在啓動arthas的過程中是需要選擇進程的,但如果已經知道進程名,則在啓動時可以加啓動參數,指定進程,具體流程如下

比如,通過JPS命令,查看進程

[work(leiting04)@tjtx167-79-50 ~]$ jps
415746 Jps
1321 Main
1021 magici-agent-1.0-SNAPSHOT.jar
[work(leiting04)@tjtx167-79-50 ~]$

本次需要調試的進程是 1321 Main,則可以在啓動參數中直接指定

[work(leiting04)@tjtx167-79-50 arthas-bin]$ ./as.sh --select Main
Arthas script version: 3.5.3
[INFO] JAVA_HOME: /opt/soft/jdk/jdk1.8.0_231
Arthas home: /home/work/arthas-bin
Calculating attach execution time...
Attaching to 1321 using version /home/work/arthas-bin...

real	0m3.118s
user	0m0.286s
sys	0m0.035s
Attach success.
telnet connecting to arthas server... current timestamp is 1640067233
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'


wiki       https://arthas.aliyun.com/doc
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
version    3.5.3
main_class
pid        1321
time       2021-12-21 14:13:52

[arthas@1321]$
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章