# 一、Arthas

依赖包

<dependency>
    <groupId>com.taobao.arthas</groupId>
    <artifactId>arthas-spring-boot-starter</artifactId>
    <version>${arthas.version}</version>
</dependency>
1
2
3
4
5

# 单机版

  • 访问:http://localhost:3658
arthas:
  tunnel-server: ws://127.0.0.1:7777/ws
  app-name: event-management-service

management:
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: always
1
2
3
4
5
6
7
8
9
10
11
12

# 微服务版

  1. 下载并部署arthas tunnel server

    • 下载:链接 (opens new window)

    • 启动:java -jar arthas-tunnel-server.jar启动服务

    • 访问: http://localhost:8080/apps.html 即可看到所有注册的arthas列表

      image-20220727162134132

  2. 其他服务中引入依赖后,加入下列配置(本质为注入服务到arthas tunnel server)

arthas:
  tunnel-server: ws://127.0.0.1:7777/ws
  app-name: event-management-service
  http-port: -1  // -1为关闭监听
  telnet-port: -1
1
2
3
4
5
  1. 部署实战

Arthas由于需要用到jdk的tool工具,不支持通过jre启动,所以启动的时候需要指定jdk的地址下的java程序启动

C:\Program Files\Java\jdk1.8.0_321\bin\java -jar xxxx.jar

项目通过joylau-springboot-daemon-windows插件,每次打包会打包成windows服务,所以修改其根目录下的xml文件即可

image-20220810150248236

# 参考

# 二、VisualVM

VisualVM远程连接:

  1. 远程服务启动时添加以下参数
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=33306 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false
1
2
3
4
  1. 添加JMX远程连接

    image-20220712182846848

  2. 确定连接

    image-20220712182947533

GC记录

1. GC后MAX_HEAP增大,应该MAX和MIN没有设置成一样大小
1

问题记录:

  • 原因:接口请求一直处于pending状态,以为是JVM出了问题,接入VisualVM后发现运行正常

  • 解决:后来在error日志中发现是redis连接错误,需要注意error日志,在out日志并不会打印错误,所以是因为reids一直阻塞导致的问题。

Last Updated: 2022-9-13 1:10:05 ├F10: AM┤