arthas 安装部署

什么是Arthas(阿尔萨斯)?

Arthas是Alibaba开源的Java诊断工具。支持Linux/Mac/Windows,采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断。

Arthas的用途?

当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:

  1. 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?

  2. 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?

  3. 遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?

  4. 线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!

  5. 是否有一个全局视角来查看系统的运行状况?

  6. 有什么办法可以监控到JVM的实时运行状态?

  7. 怎么快速定位应用的热点,生成火焰图?

Arthas的部署

  •     在线部署

curl -O https://arthas.aliyun.com/arthas-boot.jar  #下载arthas启动包
java -jar arthas-boot.jar  运行arthas
  •     离线部署

  1. 下载jar包;https://arthas.aliyun.com/arthas-boot.jar
  2. 在有网的windows环境下或linux环境下,在线部署arthas-boot.jar,并运行,找到  C:\Users\Administrator\.arthas\lib\3.4.8\arthas目录下的文件,备用。
    C:\Users\Administrator\Downloads>java -jar arthas-boot.jar
    [INFO] arthas-boot version: 3.4.8
    [INFO] Process 6092 already using port 3658
    [INFO] Process 6092 already using port 8563
    [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
    * [1]: 6092 org.jetbrains.jps.cmdline.Launcher
      [2]: 12112
      [3]: 7164
    1
    [INFO] Start download arthas from remote server: https://arthas.aliyun.com/download/3.4.8?mirror=aliyun
    [INFO] File size: 12.21 MB, downloaded size: 8.00 MB, downloading ...
    [INFO] Download arthas success.
    [INFO] arthas home: C:\Users\Administrator\.arthas\lib\3.4.8\arthas
    [INFO] The target process already listen port 3658, skip attach.
    [INFO] arthas-client connect 127.0.0.1 3658
    
    C:\Users\Administrator\Downloads>
    
    
  3. 在离线环境下部署arthas-boot.jar,第一次运行提示异常错误;找到目录/home/hadoop/.arthas/lib/arthas/arthas (如果找不到子目录就创建目录),并把window下载的C:\Users\Administrator\.arthas\lib\3.4.8\arthas目录文件复制到该目录下。
    [hadoop@sx-hadoop-01 home]$ java -jar arthas-boot.jar 
    [INFO] arthas-boot version: 3.4.8
    [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
    * [1]: 32052 org.apache.catalina.startup.Bootstrap
      [2]: 18085 org.apache.hadoop.hdfs.server.namenode.NameNode
      [3]: 18407 org.apache.hadoop.hdfs.tools.DFSZKFailoverController
      [4]: 28845 org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
      [5]: 27967 org.apache.hadoop.yarn.server.resourcemanager.ResourceManager
    1
    [ERROR] Can not read arthas version from: https://arthas.aliyun.com/api/latest_version
    [ERROR] Can not find Arthas under local: /home/hadoop/.arthas/lib/arthas/arthas and remote repo mirror: aliyun
    [ERROR] Unable to download arthas from remote server, please download the full package according to wiki: https://github.com/alibaba/arthas
  4. 重新运行arthas-boot.jar
    [hadoop@sx-hadoop-01 home]$ java -jar arthas-boot.jar 
    [INFO] arthas-boot version: 3.4.8
    [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
    * [1]: 32052 org.apache.catalina.startup.Bootstrap
      [2]: 18085 org.apache.hadoop.hdfs.server.namenode.NameNode
      [3]: 18407 org.apache.hadoop.hdfs.tools.DFSZKFailoverController
      [4]: 28845 org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer
      [5]: 27967 org.apache.hadoop.yarn.server.resourcemanager.ResourceManager
    1
    [ERROR] Can not read arthas version from: https://arthas.aliyun.com/api/latest_version
    [INFO] arthas home: /home/hadoop/.arthas/lib/arthas/arthas
    [INFO] Try to attach process 32052
    [INFO] Attach process 32052 success.
    [INFO] arthas-client connect 127.0.0.1 3658
      ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.                           
     /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'                          
    |  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.                          
    |  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |                         
    `--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'                          
                                                                                    
    
    wiki      https://arthas.aliyun.com/doc                                         
    tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html                   
    version   3.4.8                                                                 
    pid       32052                                                                 
    time      2021-03-08 12:05:06                                                   
    
    [arthas@32052]$ 

     

 

 

 

 

你可能感兴趣的:(java)