Tunnel Server
通过 Arthas Tunnel Server/Client 来远程管理/连接多个Agent。
Java进程可以是在不同的机器启动的,想要使用Arthas去诊断会比较麻烦,因为用户通常没有机器的权限,即使登陆机器也分不清是哪个Java进程。
这种情况下,可以考虑使用Arthas Tunnel。
下载部署Tunnel
从Github下载arthas-tunnel-server-fatjar.jar
或Maven仓库下载
应用配置
springboot的application.properties配置
properties
# http默认监听端口
server.port=8080
# tunnel server监听地址
arthas.server.host=0.0.0.0
# ws默认监听端口
arthas.server.port=7777
# for all endpoints
management.endpoints.web.exposure.include=*
# default user name
spring.security.user.name=arthas
# 是否开启管理界面
arthas.enable-detail-pages=false
# 缓存配置 默认使用caffeine
spring.cache.type=caffeine
spring.cache.cache-names=inMemoryClusterCache
spring.cache.caffeine.spec=maximumSize=3000,expireAfterAccess=3600s
#arthas.embedded-redis.enabled=true
#arthas.embedded-redis.settings=maxmemory 128M
#spring.redis.host=127.0.0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
提示
Tunnel默认http端口是8080
,ws协议即agent连接端口是7777
,agent通过ws协议和Tunnel Server通信
Tunnel启动
bash
# springboot应用 直接启动
java -jar arthas-tunnel-server-fatjar.jar
# 指定配置启动
java -jar arthas-tunnel-server-fatjar.jar --server.port=8081 --arthas.server.port=8888 --arthas.enable-detail-pages=true
1
2
3
4
2
3
4
启动Arthas连接到Tunnel
bash
# 启动attach成功后记录输出的agentId
java -jar arthas-boot.jar --app-name test --tunnel-server ws://192.168.5.125:7777/ws
1
2
2
建议
在使用Tunnel方式启动Arthas时,建议配置arthas.httpPort
和arthas.telnetPort
端口为-1
,表示禁止telnet和http端口,仅使用Tunnel入口
Tunnel Web Console
Tunnel Web Console类似Arthas Web Console,多了一个AgentId
指定IP、Port、AgentId连接
使用Tunnel管理页面连接
启动Tunnel时,添加参数--arthas.enable-detail-pages=true
,访问http://localhost:8080/apps.html, 点击应用名称,选择相应的agent即可连接。
注意
若使用管理页面连接,建议Arthas添加授权密码,强烈建议不要把Tunnel Server直接暴露到公网上。