配置 arthas 实现远程在线 debug

本文介绍了如何将Arthas集成到SpringBoot应用中进行远程在线debug。首先,通过添加相关依赖并修改application.yml配置文件来完成本地配置。接着,启动应用并在浏览器中验证Arthas配置。然后,部署Arthas Tunnel Server,调整端口,并通过Tunnel Server远程管理多个Agent。最后,提供了远程连接Agent的步骤和参考资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本地配置

arthas 有多种启动方式:

  • java agent 像 skywalking 一样
  • as.sh 利用 arthas 的 shell 启动 或者 java -jar 启动
  • sprintboot starter 集成到应用中启动

我们采用最方便的把 arthas 集成到 springboot-starter 的应用中启动

加入相关依赖

      <dependency>
            <groupId>com.taobao.arthas</groupId>
            <artifactId>arthas-spring-boot-starter</artifactId>
            <version>3.4.8</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

修改 application.yml 配置文件

# arthas tunnel server配置
arthas:
  agent-id: arthasDemo
  tunnel-server: ws://47.75.156.201:7777/ws

# 监控配置
management:
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: always

启动

本地访问 http://localhost:8080/actuator/arthas 查看 arthas 配置信息

其他配置可以参考:https://arthas.aliyun.com/doc/arthas-properties.html

启动项目后,然后在浏览器中输入 http://localhost:3658 地址(web console)。显示如下界面,就代表已经设置成功了。

Arthas Tunnel Server

通过 Arthas Tunnel Server/Client 来远程管理/连接多个 Agent。

部署 Tunnel Server

下载 jar 包 https://github.com/alibaba/arthas/releases

## Arthas tunnel server 是一个 spring boot fat jar应用
## 直接java -jar启动:
java -jar  arthas-tunnel-server.jar

默认情况下,arthas tunnel server 的 web 端口是 8080,arthas agent 连接的端口是 7777
也可以修改端口,比如 java-jar arthas-tunnel-server.jar --server.port=8082

远程连接管理多个 Agent

部署起来后,agent 的配置就可以生效了,比如

arthas:
#  telnetPort: -1
#  httpPort: -1
  tunnel-server: ws://127.0.0.1:7777/ws
  app-name: arthasDemo

此时打开 Tunnel Server http://127.0.0.1:8082/ 是空白的

需要 AgentId, 可以通过 http://127.0.0.1:8082/apps.html 打开连接上的应用,再点击应用名称便可以看到

点击按钮,或输入 AgentId 便可连接上指定的 agent 了

参考:

  • https://arthas.aliyun.com/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值